<div dir="ltr"><br><div>Hello, </div><div><br></div><div>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.</div>
<div><br></div><div><br></div><div><div> typedef itk::ImageToVTKImageFilter<ImageType3D> ITKToVTKConnectorType;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>ITKToVTKConnectorType::Pointer ITK_to_VTK_connector = ITKToVTKConnectorType::New();</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>ITK_to_VTK_connector->SetInput(data_ptr);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>ITK_to_VTK_connector->Update();</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkImageData> vtk_image = ITK_to_VTK_connector->GetOutput();</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// Testing vtk image</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>vtk_image->PrintSelf(std::cout, vtkIndent(0));</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>renderer->SetBackground(1.0, 1.0, 1.0);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div> vtkSmartPointer<vtkRenderWindow> render_window = vtkSmartPointer<vtkRenderWindow>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>render_window->AddRenderer(renderer);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkRenderWindowInteractor> render_window_interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>render_window_interactor->SetRenderWindow(render_window);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkPiecewiseFunction> opacity_transfer_function = vtkSmartPointer<vtkPiecewiseFunction>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>/*opacity_transfer_function->AddPoint(20, 0.0);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>opacity_transfer_function->AddPoint(25, 0.2);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>*/</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkColorTransferFunction> color_transfer_function = vtkSmartPointer<vtkColorTransferFunction>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>/*color_transfer_function->AddRGBPoint(0.0, 0.0, 0.0, 0.0);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>color_transfer_function->AddRGBPoint(64.0, 1.0, 0.0, 0.0);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>color_transfer_function->AddRGBPoint(128.0, 0.0, 0.0, 1.0);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>color_transfer_function->AddRGBPoint(192.0, 0.0, 1.0, 0.0);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>color_transfer_function->AddRGBPoint(255.0, 0.0, 0.2, 0.0);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>*/</div><div><br></div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkVolumeProperty> volume_property = vtkSmartPointer<vtkVolumeProperty>::New();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>volume_property->SetColor(color_transfer_function);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>volume_property->SetScalarOpacity(opacity_transfer_function);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>volume_property->ShadeOn();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>volume_property->SetInterpolationTypeToLinear();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>volume_property->SetIndependentComponents(1);</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkVolumeRayCastCompositeFunction> composite_function = vtkSmartPointer<vtkVolumeRayCastCompositeFunction>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//vtkSmartPointer<vtkVolumeRayCastMapper> volume_mapper = vtkSmartPointer<vtkVolumeRayCastMapper>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>//vtkSmartPointer<vtkFixedPointVolumeRayCastMapper> volume_mapper = vtkSmartPointer<vtkFixedPointVolumeRayCastMapper>::New();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div>
<div> vtkSmartPointer<vtkOpenGLVolumeTextureMapper3D> volume_mapper = vtkSmartPointer<vtkOpenGLVolumeTextureMapper3D>::New();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//vtkSmartPointer<vtkGPUVolumeRayCastMapper> volume_mapper = vtkSmartPointer<vtkGPUVolumeRayCastMapper>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>//vtkSmartPointer<vtkOpenGLGPUVolumeRayCastMapper> volume_mapper = vtkSmartPointer<vtkOpenGLGPUVolumeRayCastMapper>::New();</div><div><br></div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>//volume_mapper->SetVolumeRayCastFunction(composite_function);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>volume_mapper->SetInput(vtk_image);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>volume_mapper->SetBlendModeToComposite();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//volume_mapper->SetBlendModeToMaximumIntensity();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>//volume_mapper->SetScalarMode(1);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>volume_mapper->SetSampleDistance(0.2);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkVolume> volume = vtkSmartPointer<vtkVolume>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>volume->SetMapper(volume_mapper);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>volume->SetProperty(volume_property);</div><div>
<span class="Apple-tab-span" style="white-space:pre">        </span>volume->Update();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>render_window->Render();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>renderer->AddVolume(volume);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>renderer->ResetCamera();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>render_window_interactor->Initialize();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>render_window->Render();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>render_window_interactor->Start();</div>
</div><div><br></div><div><br></div><div>Thanks,</div><div>Prathamesh</div></div>