[vtkusers] How to set color of a clipped mesh?

Bill Lorensen bill.lorensen at gmail.com
Wed Mar 21 01:38:22 EDT 2018


Try
clipMapper->ScalarVisibiltyOff();


On Tue, Mar 20, 2018 at 7:28 PM, pnt1614 <minpu.code at gmail.com> wrote:
> 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
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://vtk.org/mailman/listinfo/vtkusers



-- 
Unpaid intern in BillsParadise at noware dot com


More information about the vtkusers mailing list