[vtkusers] Volume rendering

Mark Wyszomierski markww at gmail.com
Fri Feb 22 02:53:43 EST 2008


I wish I could be of more help, it looks like you're using a software
based mapper (vtkVolumeRayCastMapper) which for decently sized
datasets on a single CPU system can really hang things up, at least in
my experience. You can try downing the resolution of the volume, or at
least to speed up interactive rendering, you can reduce the sampling
factors (but then you may get a really really blurry blob, as best I
can describe it!).

I've had a lot of success using the software mappers on multicore
systems, the performance is pretty impressive.

In applications where I've used these mappers, I put in the choice to
switch to one of the hardware mappers which are pretty quick.

Since you never know what machine the app may run on, it's good to
have a choice.

Hope that helps somewhat,

Mark


On Fri, Feb 22, 2008 at 2:21 AM, Mohamed Ben Reguiga
<breguiga_mh at yahoo.fr> wrote:
>
> 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
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list