[vtkusers] Simple ray casting failed at vtkFixedPointVolumeRayCastMapper
Summer Sun
sunxiasx at foxmail.com
Thu Mar 30 10:25:42 EDT 2017
Hello vtk users,
My sample code is very simple as this:
When it runs, it throw an exception at line 706 of
vtkFixedPointVolumeRayCastMapper.cxx
"this->ImageDisplayHelper was nullptr."
code here, very simple,
Thank you for your help!
---
vtkSmartPointer<vtkImageData> imageData =
vtkSmartPointer<vtkImageData>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow1 =
vtkSmartPointer<vtkRenderWindow>::New();
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkInteractorStyleTrackballCamera> interactorStyle =
vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
vtkSmartPointer<vtkSmartVolumeMapper> volumeMapper =
vtkSmartPointer<vtkSmartVolumeMapper>::New();
vtkSmartPointer<vtkVolumeProperty> volumeProperty =
vtkSmartPointer<vtkVolumeProperty>::New();
vtkSmartPointer<vtkPiecewiseFunction> gradientOpacity =
vtkSmartPointer<vtkPiecewiseFunction>::New();
vtkSmartPointer<vtkPiecewiseFunction> scalarOpacity =
vtkSmartPointer<vtkPiecewiseFunction>::New();
vtkSmartPointer<vtkColorTransferFunction> color =
vtkSmartPointer<vtkColorTransferFunction>::New();
vtkSmartPointer<vtkVolume> volume = vtkSmartPointer<vtkVolume>::New();
imageData->ShallowCopy(dicomReader->GetOutput());
renderer->SetBackground(0.1, 0.2, 0.3);
renderWindow1->AddRenderer(renderer);
renderWindow1->SetSize(500, 500);
renderWindowInteractor->SetInteractorStyle(interactorStyle);
renderWindowInteractor->SetRenderWindow(renderWindow1);
volumeMapper->SetBlendModeToComposite();
volumeMapper->SetRequestedRenderModeToGPU();
volumeMapper->SetInputData(imageData);
volumeProperty->ShadeOn();
volumeProperty->SetInterpolationTypeToLinear();
volumeProperty->SetAmbient(0.1);
volumeProperty->SetDiffuse(0.9);
volumeProperty->SetSpecular(0.2);
volumeProperty->SetSpecularPower(10.0);
gradientOpacity->AddPoint(0.0, 0.0);
gradientOpacity->AddPoint(2000.0, 1.0);
volumeProperty->SetGradientOpacity(gradientOpacity);
scalarOpacity->AddPoint(-800.0, 0.0);
scalarOpacity->AddPoint(-750.0, 1.0);
scalarOpacity->AddPoint(-350.0, 1.0);
scalarOpacity->AddPoint(-300.0, 0.0);
scalarOpacity->AddPoint(-200.0, 0.0);
scalarOpacity->AddPoint(-100.0, 1.0);
scalarOpacity->AddPoint(1000.0, 0.0);
scalarOpacity->AddPoint(2750.0, 0.0);
scalarOpacity->AddPoint(2976.0, 1.0);
scalarOpacity->AddPoint(3000.0, 0.0);
volumeProperty->SetScalarOpacity(scalarOpacity);
color->AddRGBPoint(-750.0, 0.08, 0.05, 0.03);
color->AddRGBPoint(-350.0, 0.39, 0.25, 0.16);
color->AddRGBPoint(-200.0, 0.80, 0.80, 0.80);
color->AddRGBPoint(2750.0, 0.70, 0.70, 0.70);
color->AddRGBPoint(3000.0, 0.35, 0.35, 0.35);
volumeProperty->SetColor(color);
volume->SetMapper(volumeMapper);
volume->SetProperty(volumeProperty);
renderer->AddVolume(volume);
renderer->ResetCamera();
renderWindow1->Render();
renderWindowInteractor->Start();
---
--
View this message in context: http://vtk.1045678.n5.nabble.com/Simple-ray-casting-failed-at-vtkFixedPointVolumeRayCastMapper-tp5742679.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list