[vtkusers] vtkSelectVisiblePoints output has 0 points

Ioana Barcan ioana.barcan at ymail.com
Mon Sep 5 02:08:02 EDT 2016


The answer was right there, in the documentation of the filter:
"Warning:You must carefully synchronize the execution of this filter. The filter refers to a renderer, which is modified every time a render occurs. Therefore, the filter is always out of date, and always executes. You may have to perform two rendering passes."
It worked as expected if I added the //new lines:
  vtkSmartPointer<vtkSelectVisiblePoints> selectVisiblePoints =     vtkSmartPointer<vtkSelectVisiblePoints>::New();  selectVisiblePoints->SetInput(originalData);  selectVisiblePoints->SetRenderer(renderer);  selectVisiblePoints->Update();
  renderWindow->Render(); // new  selectVisiblePoints->Update(); // new
  std::cout << "Visible nr of points = " << selectVisiblePoints->GetOutput()->GetNumberOfPoints() << std::endl;


      From: Ioana Barcan via vtkusers <vtkusers at vtk.org>
 To: VTK Users <vtkusers at vtk.org> 
 Sent: Thursday, September 1, 2016 5:48 PM
 Subject: [vtkusers] vtkSelectVisiblePoints output has 0 points
   
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
_______________________________________________
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:
http://public.kitware.com/mailman/listinfo/vtkusers


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


More information about the vtkusers mailing list