[vtkusers] vtkPolyData RemoveDeletedCells() reorders vtkIdType cellid, so my indexes to them are no longer correct.

Yang, Jinzhong jinzhong76 at gmail.com
Thu Aug 13 10:33:22 EDT 2009


The cells in vtkPolyData is stored as an array of int. Once you call
RemoveDeleteCells(), the array will be rearranged and compacted to release
unused memory. If you want to keep the original indices, the easiest way is
not to call RemoveDeleteCells() and just mark those cells as deleted.

 

-Jinzhong

 

From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf
Of da xu
Sent: Wednesday, August 12, 2009 8:04 PM
To: vtkusers at vtk.org
Subject: [vtkusers] vtkPolyData RemoveDeletedCells() reorders vtkIdType
cellid, so my indexes to them are no longer correct.

 

Hi all,
I have some cells in a vtkPolyData where I also have a std::list of their
index in my program. Sometimes, I want to delete some of these cells, but
when I call RemoveDeletedCells the cells in my vtkPolyData get re-ordered,
so my std::list index to them are no longer correct. 

My question is there another way to keep track of which cell is which cell
if I do call RemoveDeletedCells and get rid of some of them? Such as a
pointer to each cell within my vtkPolyData...

Relevant code below:

pointArray is of vtkPoints
cellArray is of vtkCellArray

I keep a list of actorIndex to refer to each cell. (each cell is basically
just the point i want to display on the render window). So when I delete
actorIndex 10, the old actorIndex 11 becomes 10, and when I try to delete 11
I get an error....

AddPoint(double pt[3]) {

    int actorIndex = pointArray->InsertNextPoint(pt);
    polyData->SetPoints(pointArray);

    int n = pointArray->GetNumberOfPoints() - 1; // Subtract one for the
correct array index
    cellArray->InsertNextCell(1, &n);

    polyData->SetVerts(cellArray);
    if (n==0) {
        polyMapper->SetInput(polyData);
        actor->SetMapper(polyMapper);
        actor->GetProperty()->SetRepresentationToPoints();
        renderer->AddActor(actor);
    }
    polyData->Modified();
...

Any help/clue/pointer is appreciated! 

-Will

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090813/94dadcfb/attachment.htm>


More information about the vtkusers mailing list