[vtkusers] How to set color of a clipped mesh?
pnt1614
minpu.code at gmail.com
Tue Mar 20 22:28:50 EDT 2018
I am using vtkSelectPolyData to clip a region using a contour. But the
clipped region is rendered in unexpected color. Is there anyway to get the
original mesh's color after clipping?
// A contour generated using points
vtkSmartPointer<vtkContourRepresentation> rep =
vtkContourRepresentation::SafeDownCast(g_contourWidget->GetRepresentation());
vtkSmartPointer<vtkPoints> selectionPoints =
rep->GetContourRepresentationAsPolyData()->GetPoints();
vtkSmartPointer<vtkSelectPolyData> loop =
vtkSmartPointer<vtkSelectPolyData>::New();
loop->SetInputData(mesh->GetOutput());
loop->SetLoop(selectionPoints);
loop->GenerateSelectionScalarsOn();
loop->SetSelectionModeToLargestRegion();
vtkSmartPointer<vtkClipPolyData> clip =
vtkSmartPointer<vtkClipPolyData>::New();
clip->SetInputConnection(loop->GetOutputPort());
vtkSmartPointer<vtkPolyDataMapper> clipMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
clipMapper->SetInputConnection(clip->GetOutputPort());
vtkSmartPointer<vtkLODActor> clipActor =
vtkSmartPointer<vtkLODActor>::New();
clipActor->SetMapper(clipMapper);
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindowInteractor> interactor =
m_vtkWindow->GetInteractor();
// Add the actors to the renderer, set the background and size
renderer->AddActor(clipActor);
renderer->SetBackground(0.5, 0.5, 0.5);
m_vtkWindow->RemoveRenderer(contour_renderer);
m_vtkWindow->AddRenderer(renderer);
m_vtkWindow->Render();
interactor->Start();
--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
More information about the vtkusers
mailing list