[vtkusers] problem with DeletePoint

Petru Pau ppau at risc.uni-linz.ac.at
Tue Jun 8 10:56:33 EDT 2004


In order to extract the visible geometry of an object,
there are two possibilities:
- either to start from the visible points and add cells that are visible;
- or scan the points and remove cells that are not visible.

I tried the second approach, and wrote a function that should remove
a point and all incident cells:
- get all cells incident to the point;
- for each cell in the above set
- - remove the cell
- remove the point.

        void removePoint(int pointIndex, vtkPolyData p)
        {
            vtkIdList adjacentCells = vtkIdList.New();
            p.GetPointCells(pointIndex, adjacentCells);

            int nrPoints = p.GetNumberOfPoints();

            int nrAdjCells = adjacentCells.GetNumberOfIds();
            for (int i=0; i<nrAdjCells; i++)
            {
                int cellId = adjacentCells.GetId(i);
                p.RemoveReferenceToCell(pointIndex, cellId);
                p.RemoveCellReference(cellId);
                p.DeleteCell(cellId);
            }
            p.DeletePoint(pointIndex);

            nrPoints = p.GetNumberOfPoints();
        }

This function does _not_ work To give an idea, I added the variable 
nrPoints.
In the examples that I tried, after the last line, the value of nrPoints 
does not
change - the poly data has the same number of points as before.

In the documentation, DeletePoint _marks_ the point as deleted. What would
that mean?... How can I really remove the point and its adjacent cells?

Petru




More information about the vtkusers mailing list