Quantcast

vtkSelectVisiblePoints output has 0 points

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

vtkSelectVisiblePoints output has 0 points

VTK - Users mailing list
Hello,
 
I’m trying to obtain a polyData with only the visible part of a 3D model.
To that extent, I’m passing the original data through a vtkSelectVisiblePoints filter. I’m using a mock renderer, mapper and actor because I want to post-process the visible points before displaying them.
 
However, the output of the vtkSelectVisiblePoints filter contains “0” points for some reason…
 
Using the following example:
 
I came up with the following piece of code:
 
  // Render window and interactor
  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 the correct 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: vtkSelectVisiblePoints output has 0 points

VTK - Users mailing list
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 <[hidden email]>
To: VTK Users <[hidden email]>
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 part of a 3D model.
To that extent, I’m passing the original data through a vtkSelectVisiblePoints filter. I’m using a mock renderer, mapper and actor because I want to post-process the visible points before displaying them.
 
However, the output of the vtkSelectVisiblePoints filter contains “0” points for some reason…
 
Using the following example:
 
I came up with the following piece of code:
 
  // Render window and interactor
  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 the correct 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



_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: vtkSelectVisiblePoints output has 0 points

alanwsx
In reply to this post by VTK - Users mailing list
Same question here. Did you find the solution?

Thanks,
Shangxuan
Loading...