[vtkusers] problem with DeletePoint

Goodwin Lawlor goodwin.lawlor at ucd.ie
Tue Jun 8 14:51:04 EDT 2004


Petru,

When vtkPolyData::BuildLinks is called a vtkCellLinks object is created
which contains, for each point, a list of cells that use that point.
When vtkPolyData::DeletePoint is called, it in turn calls
vtkCellLinks::DeletePoint which just cuts the links... deletes the cells
list associated with the point. Nothing has changed in the vtkPolyData
object.

Similarly, when vtkPolyData::BuildCells is called a vtkCellTypes object
is created which contains , for each cell, its cell type and where its
located in its cell array (ie if it's a vert where it is located in the
verts array). When vtkPolyData::DeleteCell is called, it in turn calls
vtkCellTypes::DeleteCell(cellid) which just changes the cell type to
VTK_EMPTY_CELL. So now when you call vtkPolyData::GetCell(cellid) you'll
get an vtkEmptyCell returned. But if you traverse the Verts or Polys
cell arrays nothing will have actually have been deleted.

Have a look at vtkDecimate.cxx or vtkDecimatePro.cxx to get an idea of
how to use these methods. In particular, look how
vtkDecimate::CreateOutput() creates an output vtkPolyData object that
actually reflects the changes made by ::DeletePoint() and
::DeleteCell().

Another way of deleting a cell is by using vtkPolyData::CopyCells. Have
a look at vtkRemoveCellsFilter to see how its done:
http://www.bioengineering-research.com/vtk/vtkRemoveCellsFilter.htm

Hth,

Goodwin



Date: Tue, 08 Jun 2004 16:56:33 +0200
From: Petru Pau <ppau at risc.uni-linz.ac.at>
Subject: [vtkusers] problem with DeletePoint
To: vtkusers at vtk.org
Message-ID: <40C5D3A1.7040207 at risc.uni-linz.ac.at>
Content-Type: text/plain; charset=us-ascii; format=flowed

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