[vtkusers] Volume rendering
Mohamed Ben Reguiga
breguiga_mh at yahoo.fr
Fri Feb 22 02:21:14 EST 2008
Hello all,
I'm using VTK in my project to make a 3D reconstruction from a stack of medical images ( CT, and MRI).
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%.
I followed the example given in the book Visual Toolkit (4th edition).
I'm developping using Vtk 5.0.2 , VC++ 2008 under WinXP.
this is the code I'm using :
//acreation of the volume
data2=vtkStructuredPoints::New();
data2->SetDimensions(WdthVlm,HghtVlm,DpthVlm);
data2->SetScalarType(VTK_UNSIGNED_SHORT);
data2->AllocateScalars();
.....
//rendering
vtkRenderer *aRender3D = vtkRenderer::New();
vtkRenderWindow * renWin = vtkRenderWindow::New();
renWin->AddRenderer(aRender3D);
renWin->SetSize(800,600);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetInteractorStyle(vtkInteractorStyleTrackballCamera::New());
iren->SetRenderWindow(renWin);
vtkPiecewiseFunction *tPcWs = vtkPiecewiseFunction::New();
tPcWs ->AddPoint(0, 0.0);
tPcWs ->AddPoint(600.0, 0);
tPcWs ->AddPoint(1195.0, 0);
tPcWs ->AddPoint(1200, .2);
tPcWs ->AddPoint(1300, .3);
tPcWs ->AddPoint(4095, 1);
vtkColorTransferFunction *ctfun = vtkColorTransferFunction::New();
ctfun->AddRGBPoint(0.0, 0.6, 0.2, 0.3);
ctfun->AddRGBPoint(600.0, 1.0, 0.2, 0.3);
ctfun->AddRGBPoint(1280.0, 0.9, 0.5, 0.7);
ctfun->AddRGBPoint(1960.0, 0.81, 0.3, 0.3);
ctfun->AddRGBPoint(4095.0, 0.5, 0.5, 0.5);
vtkVolumeRayCastCompositeFunction* compositeFunction = vtkVolumeRayCastCompositeFunction::New();
vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New();
volumeMapper->SetInput(data2);
volumeMapper->SetVolumeRayCastFunction(compositeFunction);
vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
volumeProperty->SetAmbient(0.2);
volumeProperty->SetDiffuse(0.8);
volumeProperty->SetSpecular(0.5);
volumeProperty->SetSpecularPower(10);
volumeProperty->SetColor(ctfun);
volumeProperty->SetScalarOpacity(tfun);
volumeProperty->SetInterpolationTypeToLinear();
volumeProperty->ShadeOn();
vtkVolume *newvol = vtkVolume::New();
newvol->SetMapper(volumeMapper);
newvol->SetProperty(volumeProperty);
aCamera=vtkCamera::New();
aCamera->SetViewUp(0,1,0);
aCamera->SetPosition(0.0,0.0,1);
aCamera->SetFocalPoint(0,0,0);
aCamera->SetRoll(180);
aCamera->SetParallelProjection(true);
aRender3D->AddVolume(newvol);
aRender3D->SetActiveCamera(aCamera);
aRender3D->ResetCamera();
iren->Initialize();
renWin->Render();
iren->Start();
...
}
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.
I've seen Osirix making the same but faster.
thank you for your help.
_____________________________________________________________________________
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail http://mail.yahoo.fr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080222/23422b58/attachment.htm>
More information about the vtkusers
mailing list