[vtkusers] How visualize 3D image with transparencies correctly

Juan Bueno Losada juanl3l at gmail.com
Tue Nov 8 07:25:14 EST 2011


Hi,

I'm a new user of VTK library. I'm creating a 3D image as vtkImageData.
This image is a cube consisting of a dense group of points. Well, the
problem is when I try to visualize it using lookup tables with
transparencies and I can watch only the extern peel. The transparencies
work fine, but only the extern points are visualized and across the
transparencies only the points of the opposite peel can be watched whereas
the inside points also should be rendered.

Could Anybody say me if this fact is normal because VTK can't control the
transparencies of several peels at the same time?

Here, I append part of my code:

vtkSmartPointer<vtkImageData> imageData =
vtkSmartPointer<vtkImageData>::New();
vtkSmartPointer<vtkXMLImageDataReader> reader =
vtkSmartPointer<vtkXMLImageDataReader>::New();
reader->SetFileName("3Dimage.vti");

vtkSmartPointer<vtkLookupTable> lut =
vtkSmartPointer<vtkLookupTable>::New();

double *minMax = imageData->GetScalarRange();
lut->SetNumberOfColors(256);
lut->SetRange(minMax);
lut->SetHueRange(0.0, 0.667);
lut->Build(); //effectiv

float airRange[]={-0.03, 0.051};

double rgba[4];
for(int i=lut->GetIndex(airRange[0])+1;i<=lut->GetIndex(airRange[i]);i++)
{
    float alpha=0.0;
    lut->GetTableValue(i, rgba);
    rgba[3]=alpha;
    lut->SetTableValue(i, rgba);
}

vtkSmartPointer<vtkDataSetMapper> mapper =
vtkSmartPointer<vtkDataSetMapper>::New();

mapper->SetInputConnection(extractor->GetOutputPort());
mapper->SetLookupTable(lut);
mapper->SetScalarRange(minMax);
mapper->ScalarVisibilityOn();

vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);

vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor(actor);
renderer->ResetCamera();
renderer->SetBackground(1,1,1);

vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);

vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);
renderWindowInteractor->Initialize();

renderWindowInteractor->Start();

--
Juan Bueno Losada
Universidad de Salamanca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111108/b3269bee/attachment.htm>


More information about the vtkusers mailing list