[vtkusers] Opacity problems with vtkOSPRayPass
Martina Litterio
mlitterio at pccube.com
Mon Nov 6 09:44:11 EST 2017
Hi all!
I have a problem using vtkOSPRayPass. I'm reading a DICOM series with
vtkDICOMImageReader.
My code is :
..bla bla bla
vtkNew<vtkGPUVolumeRayCastMapper> volumeMapper;
volumeMapper->SetAutoAdjustSampleDistances(0);
volumeMapper->SetSampleDistance(0.5);
vtkDICOMImageReader* reader = vtkDICOMImageReader::New();
reader->SetDirectoryName("Path/to/my/DICOM");
reader->Update();
volumeMapper->SetInputConnection(reader->GetOutputPort());
volumeMapper->AddObserver(vtkCommand::ErrorEvent, errorObserver);
vtkNew<vtkPiecewiseFunction> pwf;
pwf->AddPoint(-3024, 0.0);
pwf->AddPoint(-16, 0.0);
pwf->AddPoint(641, 0.05);
pwf->AddPoint(3071, 0.1);
ctf->AddRGBPoint( -3024, 0, 0, 0, 0.5, 0.0 );
ctf->AddRGBPoint( -16, 0.73, 0.25, 0.30, 0.49, .61 );
ctf->AddRGBPoint( 641, .90, .82, .56, .5, 0.0 );
ctf->AddRGBPoint( 3071, 1, 1, 1, .5, 0.0 );
volumeProperty->SetColor(ctf);
volumeProperty->SetScalarOpacity(pwf);
volumeProperty->SetShade(0);
volumeProperty->SetScalarOpacityUnitDistance(1.732);
vtkNew<vtkVolume> volume;
volume->SetMapper(volumeMapper);
volume->SetProperty(volumeProperty);
// Create the renderwindow, interactor and renderer
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->SetMultiSamples(0);
renderWindow->SetSize(401, 399); // NPOT size
vtkNew<vtkRenderer> renderer;
renderer->SetBackground(0.3, 0.3, 0.4);
renderWindow->AddRenderer(renderer);
renderer->AddVolume(volume);
renderer->ResetCamera();
renderWindow->Render();
// Attach OSPRay render pass
vtkNew<vtkOSPRayPass> osprayPass;
if (useOSP)
{
renderer->SetPass(osprayPass);
}
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renderWindow);
vtkNew<vtkInteractorStyleTrackballCamera> style;
iren->SetInteractorStyle(style);
iren->Start();
... bla bla bla
Now, the problem is the following. If "useOSP"==FALSE, I have a certain
opacity (the which one I would like to have in my results); if
"useOSP"==TRUE, I have a different opacity and I'm not able to manage it as
I want.
Can you please tell me what's wrong in my code?
Thanks to everyone!
*Martina Li**tterio*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171106/2d7918ec/attachment.html>
More information about the vtkusers
mailing list