[vtkusers] Volume Rendering

Cory Jones cjayjones at gmail.com
Tue Oct 14 19:11:25 EDT 2014


I am using vtkSmartVolumeMapper to render a volume and it is only rendering
a portion of the volume when the volume is not moving. When I click to
rotate the volume, the entire area of interest becomes visible, but as soon
as I stop the rotation, the majority of the volume disappears. Has anyone
encountered an issue like this before? Previously I was getting an error
about using more than one thread causing inconsistent rendering from
vtkFixedPointVolumeRayCastMapper but have since forced it to use only one
thread and the problem persists. My rendering code is below.

vtkSmartPointer<vtkRenderer> aRenderer =
    vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renWin =
    vtkSmartPointer<vtkRenderWindow>::New();
renWin->AddRenderer(aRenderer);

vtkSmartPointer<vtkRenderWindowInteractor> iren =
    vtkSmartPointer<vtkRenderWindowInteractor>::New();
iren->SetRenderWindow(renWin);
vtkSmartPointer<vtkImageData> testImage;
testImage = mrc.GetRegionImageDesc();

vtkSmartPointer<vtkSmartVolumeMapper> volumeMapper =
vtkSmartPointer<vtkSmartVolumeMapper>::New();
volumeMapper->SetBlendModeToComposite(); // composite first
volumeMapper->SetInputData(testImage);

vtkSmartPointer<vtkVolumeProperty> volumeProperty =
vtkSmartPointer<vtkVolumeProperty>::New();
volumeProperty->ShadeOff();
volumeProperty->SetInterpolationType(VTK_LINEAR_INTERPOLATION);
volumeProperty->IndependentComponentsOff();
vtkSmartPointer<vtkPiecewiseFunction> compositeOpacity =
vtkSmartPointer<vtkPiecewiseFunction>::New();
compositeOpacity->AddPoint(0,0.5);
compositeOpacity->AddPoint(254.0,0.5);
compositeOpacity->AddPoint(255.0,0.0);
volumeProperty->SetScalarOpacity(compositeOpacity);
vtkSmartPointer<vtkVolume> volume =
vtkSmartPointer<vtkVolume>::New();
volume->SetMapper(volumeMapper);
volume->SetProperty(volumeProperty);
vtkSmartPointer<vtkCamera> cam3D;
cam3D = vtkSmartPointer<vtkCamera>::New();
cam3D->SetViewUp (0, 0, -1);
cam3D->SetPosition (0, 0, 1);
cam3D->SetFocalPoint (0, 0, 0);
cam3D->ComputeViewPlaneNormal();
cam3D->Azimuth(30.0);
cam3D->Elevation(30.0);
cam3D->ParallelProjectionOn();

aRenderer->AddViewProp(volume);
aRenderer->SetActiveCamera(cam3D);
aRenderer->ResetCamera ();
aRenderer->SetBackground(1,1,1);
aRenderer->TwoSidedLightingOn();

renWin->Render();
iren->Initialize();
iren->Start();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20141014/f317bc11/attachment.html>


More information about the vtkusers mailing list