<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV>Hello all,</DIV>
<DIV> </DIV>
<DIV>I'm using VTK in my project to make a 3D reconstruction from a stack of medical images ( CT, and MRI).</DIV>
<DIV>the problem I'm facing doesn't concern the reconstruction itself, because it's done well, but the problem is when I want to manipulate the rendered Volume (rotate, zoom..) using the mouse, it take allaways 100% af CPU charge and somteimes it stopps reacting to the mouse events and the CPU charge still at 100%.</DIV>
<DIV>I followed the example given in the book Visual Toolkit (4th edition).</DIV>
<DIV>I'm developping using Vtk 5.0.2 , VC++ 2008 under WinXP.</DIV>
<DIV>this is the code I'm using :</DIV>
<DIV> </DIV>
<DIV>//acreation of the volume</DIV>
<DIV>
<P>data2=vtkStructuredPoints::New();</P></DIV>
<DIV>
<P>data2->SetDimensions(WdthVlm,HghtVlm,DpthVlm); </P>
<P>data2->SetScalarType(VTK_UNSIGNED_SHORT);</P>
<P>data2->AllocateScalars();</P>
<P>.....</P>
<P> </P></DIV>
<DIV>
<P>//rendering</P>
<P> </P>
<P>vtkRenderer *aRender3D = vtkRenderer::New(); </P>
<P> </P></DIV>
<DIV><FONT color=#008000 size=2>
<P><FONT color=#000000 size=3>vtkRenderWindow * renWin = vtkRenderWindow::New();</FONT></P>
<P><FONT color=#000000 size=3>renWin->AddRenderer(aRender3D);</FONT></P>
<P><FONT color=#000000 size=3>renWin->SetSize(800,600);</FONT></P>
<P><FONT color=#000000 size=3></FONT> </P>
<P><FONT color=#000000 size=3>vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();</FONT></P>
<P><FONT color=#000000 size=3>iren->SetInteractorStyle(vtkInteractorStyleTrackballCamera::New());</FONT></P>
<P><FONT color=#000000 size=3>iren->SetRenderWindow(renWin);</FONT></P>
<P><FONT color=#000000 size=3></FONT> </P><FONT color=#000000 size=2>
<P><FONT size=3>vtkPiecewiseFunction *tPcWs = vtkPiecewiseFunction::New();</FONT></P><FONT size=2><FONT size=2>
<P><FONT size=3>tPcWs ->AddPoint(0, 0.0);</FONT></P>
<P><FONT size=3>tPcWs ->AddPoint(600.0, 0);</FONT></P>
<P><FONT size=3>tPcWs ->AddPoint(1195.0, 0);</FONT></P>
<P><FONT size=3>tPcWs ->AddPoint(1200, .2);</FONT></P>
<P><FONT size=3>tPcWs ->AddPoint(1300, .3);</FONT></P>
<P><FONT size=3>tPcWs ->AddPoint(4095, 1);</FONT></P>
<P><FONT size=3></FONT> </P>
<P><FONT size=3>vtkColorTransferFunction *ctfun = vtkColorTransferFunction::New();</FONT></P>
<P><FONT size=3>ctfun->AddRGBPoint(0.0, 0.6, 0.2, 0.3);</FONT></P>
<P><FONT size=3>ctfun->AddRGBPoint(600.0, 1.0, 0.2, 0.3);</FONT></P>
<P><FONT size=3>ctfun->AddRGBPoint(1280.0, 0.9, 0.5, 0.7);</FONT></P>
<P><FONT size=3>ctfun->AddRGBPoint(1960.0, 0.81, 0.3, 0.3);</FONT></P>
<P><FONT size=3>ctfun->AddRGBPoint(4095.0, 0.5, 0.5, 0.5);</FONT></P>
<P><FONT size=3></FONT> </P>
<P><FONT size=3>vtkVolumeRayCastCompositeFunction* compositeFunction = vtkVolumeRayCastCompositeFunction::New();</FONT></P>
<P><FONT size=3></FONT> </P>
<P><FONT size=3>vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New();</FONT></P>
<P><FONT size=3>volumeMapper->SetInput(data2);</FONT></P>
<P><FONT size=3></FONT> </P>
<P><FONT size=3>volumeMapper->SetVolumeRayCastFunction(compositeFunction);</FONT></P>
<P><FONT size=3></FONT> </P>
<P><FONT size=3>vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();</FONT></P>
<P><FONT size=3>volumeProperty->SetAmbient(0.2);</FONT></P>
<P><FONT size=3>volumeProperty->SetDiffuse(0.8);</FONT></P>
<P><FONT size=3>volumeProperty->SetSpecular(0.5);</FONT></P>
<P><FONT size=3>volumeProperty->SetSpecularPower(10);</FONT></P>
<P><FONT size=3>volumeProperty->SetColor(ctfun);</FONT></P>
<P><FONT size=3>volumeProperty->SetScalarOpacity(tfun);</FONT></P>
<P><FONT size=3>volumeProperty->SetInterpolationTypeToLinear();</FONT></P>
<P><FONT size=3>volumeProperty->ShadeOn();</FONT></P>
<P><FONT size=3></FONT> </P>
<P><FONT size=3>vtkVolume *newvol = vtkVolume::New();</FONT></P>
<P><FONT size=3>newvol->SetMapper(volumeMapper);</FONT></P>
<P><FONT size=3>newvol->SetProperty(volumeProperty);</FONT></P>
<P><FONT size=3></FONT> </P>
<P><FONT size=3>aCamera=vtkCamera::New();</FONT></P>
<P><FONT size=3>aCamera->SetViewUp(0,1,0);</FONT></P>
<P><FONT size=3>aCamera->SetPosition(0.0,0.0,1);</FONT></P>
<P><FONT size=3>aCamera->SetFocalPoint(0,0,0);</FONT></P>
<P><FONT size=3>aCamera->SetRoll(180);</FONT></P>
<P><FONT size=3>aCamera->SetParallelProjection(<FONT color=#0000ff>true</FONT>);</FONT></P>
<P><FONT size=3></FONT> </P>
<P><FONT size=3>aRender3D->AddVolume(newvol);</FONT></P>
<P><FONT size=3>aRender3D->SetActiveCamera(aCamera);</FONT></P>
<P><FONT size=3>aRender3D->ResetCamera();</FONT></P>
<P><FONT size=3></FONT> </P><FONT color=#008000 size=2>
<P><FONT color=#000000 size=3>iren->Initialize(); </FONT></P>
<P><FONT color=#000000 size=3>renWin->Render();</FONT></P>
<P><FONT color=#000000 size=3>iren->Start();</FONT></P>
<P><FONT color=#000000 size=3>...</FONT></P>
<P><FONT color=#000000>}</FONT></P>
<P><FONT color=#000000></FONT> </P>
<P><FONT color=#000000 size=3>what's wrong with this code , is it usefull only whith low Volume capacity or is there somthing to do to make the interaction easier and faster.</FONT></P>
<P><FONT color=#000000 size=3>I've seen Osirix making the same but faster.</FONT></P>
<P><FONT color=#000000 size=3></FONT> </P>
<P><FONT color=#000000 size=3>thank you for your help.</FONT></P></FONT></FONT></FONT></FONT></FONT></DIV></div><br>
<hr size="1">
Ne gardez plus qu'une seule adresse mail ! <a href="http://fr.rd.yahoo.com/mail/mail_taglines/trueswitch/SIG=11gshn0bu/**http%3A%2F%2Fwww.trueswitch.com%2Fyahoo-fr%2F">Copiez vos mails</a> vers Yahoo! Mail </body></html>