Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove individual points from vtkPoints

Tags:

vtk

I have a question regarding a VTK class called vtkPoints. The class has the functionality to insert individual points, but doesn't have the functionality to remove individual points. This is inconvenient for the case when the view needs to be updated by calling vtkPoints::Modified() to drive the graphics pipeline again to update/re-render the view. The obvious case of re-initializing vtkPoints, adding all points again and updating/re-rendering the view is too slow and resource intensive.

Is there a possible solution to this problem?

Thanks, timecatcher

like image 489
timecatcher Avatar asked Oct 29 '25 02:10

timecatcher


1 Answers

The example http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/DeletePoint has a rather simple solution. Copy points to another temporary vtkPoints by filtering the id to remove, and shallow-copy it to the original one:

void ReallyDeletePoint(vtkSmartPointer<vtkPoints> points, vtkIdType id)
{
  vtkSmartPointer<vtkPoints> newPoints = 
    vtkSmartPointer<vtkPoints>::New();

  for(vtkIdType i = 0; i < points->GetNumberOfPoints(); i++)
    {
    if(i != id)
      {
      double p[3];
      points->GetPoint(i,p);
      newPoints->InsertNextPoint(p);
      }
    }

  points->ShallowCopy(newPoints);
}
like image 82
CharlesB Avatar answered Oct 31 '25 12:10

CharlesB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!