[vtkusers] Problem with invisibilty of Points when rendering Polydata
MemoreX
karsten.klompmaker at gmail.com
Thu May 30 07:24:24 EDT 2013
Hello,
i'm fairly new to VTK and facing a few problems with the rendering of
PolyData.
I have a 3D-PolyDataSet with Scalar values i've created via a
vtkImageDataGeometryFilter from vtkImageData and i'm trying to make the
Points with a value of zero invisible. Currently i'm doing so by creating a
lookuptable and setting the opacity of those Points to zero, as can be seen
in the Code at the end.
This works fine when looking at the object from the front. But when i turn
the camera so that the object can be seen from behind, the Points that
should be invisible are visible and black(the color i assigned for a value
of zero in the lookuptable). So it appears to me, that for some reason the
opacity i set is being ignored.
I've been searching the Internet for quite a while now for a solution, but
can't get it to work. I hope one of you can help me.
Thanks in advance for all replies.
vtkSmartPointer<vtkLookupTable> table =
vtkSmartPointer<vtkLookupTable>::New();
table->SetNumberOfColors(numberOfColors);
table->SetHueRange(0.0, 0.888);
table->SetValueRange(0.4, 1.0);
table->Build();
table->SetTableValue(0, 0.0, 0.0, 0.0, 0.0);
// Convert the image to a polydata
vtkSmartPointer<vtkImageDataGeometryFilter> imageDataGeometryFilter =
vtkSmartPointer<vtkImageDataGeometryFilter>::New();
imageDataGeometryFilter->SetInputConnection(vtkImport->GetOutputPort());
imageDataGeometryFilter->Update();
// Create a mapper and actor
vtkSmartPointer<vtkOpenGLPolyDataMapper> mapper =
vtkSmartPointer<vtkOpenGLPolyDataMapper>::New();
mapper->SetInputConnection(imageDataGeometryFilter->GetOutputPort());
mapper->SetLookupTable(table);
mapper->SetScalarRange(imageDataGeometryFilter->GetOutput()->GetScalarRange());
mapper->SetScalarModeToUsePointData();
mapper->ImmediateModeRenderingOn();
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
vtkProperty* prop = vtkProperty::New();
prop->SetPointSize(4);
prop->FrontfaceCullingOff();
prop->BackfaceCullingOff();
prop->SetRepresentationToPoints();
actor->SetProperty(prop);
actor->SetBackfaceProperty(prop);
// Visualization
vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New();
camera->SetPosition(0.0, 0.5, 0.5);
camera->SetFocalPoint(0.5, 0.5, 0.5);
renderer->AddActor(actor);
renderer->AddActor(cubeAxesActor);
renderer->SetBackground(0, 0, 0); // Background color white
renderer->SetActiveCamera(camera);
renderer->ResetCamera();
renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
vtkRrenderWindowInteractor->SetRenderWindow(renderWindow);
renderWindow->Render();
renderWindowInteractor->Start();
--
View this message in context: http://vtk.1045678.n5.nabble.com/Problem-with-invisibilty-of-Points-when-rendering-Polydata-tp5721073.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list