[vtkusers] vtkSelectVisiblePoints output has 0 points

Ioana Barcan ioana.barcan at ymail.com
Thu Sep 1 10:48:10 EDT 2016


Hello,


 
I’m trying to obtain a polyData with only the visible partof a 3D model.

To that extent, I’m passing the original data through a vtkSelectVisiblePointsfilter. I’m using a mock renderer, mapper and actor because I want topost-process the visible points before displaying them.


 
However, the output of the vtkSelectVisiblePoints filtercontains “0” points for some reason…


 
Using the following example:

http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/SelectVisiblePoints


 
I came up with the following piece of code:


 
  // Render window andinteractor

  vtkSmartPointer<vtkRenderWindow>renderWindow = 

   vtkSmartPointer<vtkRenderWindow>::New();

 renderWindow->SetSize(800, 800);


 
 vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor= 

   vtkSmartPointer<vtkRenderWindowInteractor>::New();


 
  renderWindowInteractor->SetRenderWindow(renderWindow);


 

 
  // Mock renderer,mapper and actor

 vtkSmartPointer<vtkRenderer> mockRenderer = 

    vtkSmartPointer<vtkRenderer>::New();


 
 renderWindow->AddRenderer(mockRenderer);


 
 vtkSmartPointer<vtkPolyDataMapper> mockMapper = 

   vtkSmartPointer<vtkPolyDataMapper>::New();

 mockMapper->SetInput(reader->GetOutput());


 
 vtkSmartPointer<vtkActor> mockActor =vtkSmartPointer<vtkActor>::New();

 mockActor->SetMapper(mockMapper);

 mockRenderer->AddActor(mockActor);


 
  // Set camera to thecorrect position

 mockRenderer->GetActiveCamera()->SetPosition(0, -1, 0);

 mockRenderer->GetActiveCamera()->SetFocalPoint(0, 0, 0);

 mockRenderer->GetActiveCamera()->SetViewUp(0, 1, 0);

 mockRenderer->ResetCamera();


 
 vtkSmartPointer<vtkSelectVisiblePoints> selectVisiblePoints = 

   vtkSmartPointer<vtkSelectVisiblePoints>::New();

 selectVisiblePoints->SetInput(reader->GetOutput());

 selectVisiblePoints->SetRenderer(mockRenderer);

 selectVisiblePoints->Update();


 
  std::cout <<"Visible nr of points = " <<selectVisiblePoints->GetOutput()->GetNumberOfPoints() << std::endl;
  renderWindow->RemoveRenderer(mockRenderer);






 
… prints 0.


 
Is it anything that I’m missing?


 
Thank you,
Ioana

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160901/fef75512/attachment.html>


More information about the vtkusers mailing list