[Insight-users] problems with rendering using ray casting
Prathamesh Kulkarni
prathameshmkulkarni at gmail.com
Wed Sep 21 00:02:13 EDT 2011
Hello,
I am trying to render a volume (mhd file read as ITKImage<float, 3>) using
VTK ray casting. I have tried to use the different available mappers, but
the output is always only background. For the mappers using OpenGL, I get
the error: line 100 vtkOpenGLVolumeTextureMapper3D (0000000003270440):
required extensions not supported. Below is my code. Any help would be very
useful.
typedef itk::ImageToVTKImageFilter<ImageType3D>
ITKToVTKConnectorType;
ITKToVTKConnectorType::Pointer ITK_to_VTK_connector =
ITKToVTKConnectorType::New();
ITK_to_VTK_connector->SetInput(data_ptr);
ITK_to_VTK_connector->Update();
vtkSmartPointer<vtkImageData> vtk_image = ITK_to_VTK_connector->GetOutput();
// Testing vtk image
vtk_image->PrintSelf(std::cout, vtkIndent(0));
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->SetBackground(1.0, 1.0, 1.0);
vtkSmartPointer<vtkRenderWindow> render_window =
vtkSmartPointer<vtkRenderWindow>::New();
render_window->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> render_window_interactor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
render_window_interactor->SetRenderWindow(render_window);
vtkSmartPointer<vtkPiecewiseFunction> opacity_transfer_function =
vtkSmartPointer<vtkPiecewiseFunction>::New();
/*opacity_transfer_function->AddPoint(20, 0.0);
opacity_transfer_function->AddPoint(25, 0.2);
*/
vtkSmartPointer<vtkColorTransferFunction> color_transfer_function =
vtkSmartPointer<vtkColorTransferFunction>::New();
/*color_transfer_function->AddRGBPoint(0.0, 0.0, 0.0, 0.0);
color_transfer_function->AddRGBPoint(64.0, 1.0, 0.0, 0.0);
color_transfer_function->AddRGBPoint(128.0, 0.0, 0.0, 1.0);
color_transfer_function->AddRGBPoint(192.0, 0.0, 1.0, 0.0);
color_transfer_function->AddRGBPoint(255.0, 0.0, 0.2, 0.0);
*/
vtkSmartPointer<vtkVolumeProperty> volume_property =
vtkSmartPointer<vtkVolumeProperty>::New();
volume_property->SetColor(color_transfer_function);
volume_property->SetScalarOpacity(opacity_transfer_function);
volume_property->ShadeOn();
volume_property->SetInterpolationTypeToLinear();
volume_property->SetIndependentComponents(1);
vtkSmartPointer<vtkVolumeRayCastCompositeFunction> composite_function =
vtkSmartPointer<vtkVolumeRayCastCompositeFunction>::New();
//vtkSmartPointer<vtkVolumeRayCastMapper> volume_mapper =
vtkSmartPointer<vtkVolumeRayCastMapper>::New();
//vtkSmartPointer<vtkFixedPointVolumeRayCastMapper> volume_mapper =
vtkSmartPointer<vtkFixedPointVolumeRayCastMapper>::New();
vtkSmartPointer<vtkOpenGLVolumeTextureMapper3D> volume_mapper =
vtkSmartPointer<vtkOpenGLVolumeTextureMapper3D>::New();
//vtkSmartPointer<vtkGPUVolumeRayCastMapper> volume_mapper =
vtkSmartPointer<vtkGPUVolumeRayCastMapper>::New();
//vtkSmartPointer<vtkOpenGLGPUVolumeRayCastMapper> volume_mapper =
vtkSmartPointer<vtkOpenGLGPUVolumeRayCastMapper>::New();
//volume_mapper->SetVolumeRayCastFunction(composite_function);
volume_mapper->SetInput(vtk_image);
volume_mapper->SetBlendModeToComposite();
//volume_mapper->SetBlendModeToMaximumIntensity();
//volume_mapper->SetScalarMode(1);
volume_mapper->SetSampleDistance(0.2);
vtkSmartPointer<vtkVolume> volume = vtkSmartPointer<vtkVolume>::New();
volume->SetMapper(volume_mapper);
volume->SetProperty(volume_property);
volume->Update();
render_window->Render();
renderer->AddVolume(volume);
renderer->ResetCamera();
render_window_interactor->Initialize();
render_window->Render();
render_window_interactor->Start();
Thanks,
Prathamesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110920/03add6ba/attachment-0001.htm>
More information about the Insight-users
mailing list