[vtkusers] How to delete cells from vtkPolyData
Alexandre gouaillard
alexandre.gouaillard at insa-lyon.fr
Thu Jul 8 21:43:03 EDT 2004
dear Zhong
the internal structure of a polydata has several arrays and inherits the
point arrays from it parent class.
For explanation's sake, let say you are using only polygons.
the point array and the "Polys" array thus contains the data. both point
and Polys array contains the data in a straightforward way :
point array is organyzed as follows
x1,
y1,
z1,
x2,
y2,
z2, ....
and the poly array as follows :
NumberOfPointsOfCell_1,
Point_1_Cell_1,
Point_2_Cell_2,
...... ,
NumberOfPointsOfCell_2,
.....
This limit the memory footprint of those arrays but unfortunatly random
access to the cell is not possible. Indeed, you generally don't know the
offset of one cell in the Polys array, so if you want to acces cell number
N you have to go through all the N-1 previous cells in the array.
To have random access to cells , independently of cell type , there is a
"Cells" array in the polydata with the following architecture :
Cell_1_Type
Cell_1_offset_in_its_type_Array
Cell_2_type
...
Here, the size of one object in the table being constant , you can directly
access cell number N.
Finally , there is a "Link" array which stocks the links from points to cells.
vtkPolyData's methods all use those last two arrays to access and process
the data. They don't access directly the first arrays. I suppose that it
would reorder the cells / points and thus require another call to
BuildLink() or BuildCells() which one would avoid as it is quite time
consuming.
When you use vtkPolyData's own method like "DeleteCell()" you only delete
that cell entries in the "Cells" and "Link" arrays.
This is usually not a problem as for all polydata's methods, this cell
(same works for points) doesn't exist anymore.
By the way, when you want to delete a cell, if you want the data structure
to stay consistant , you are suppose to call "RemoveReferenceToCell()"
method once for each point that used to be used by this cell, and then
resize the cell list of the point in the "Link" table (or remove the point
if it s size is down to zero).
If your problem is to generate a new surface which doesn't contains this
cell, you should consider building a new polydata (empty) making an array
of points, an array of cell and building it manually. It would be less
difficult than updating the internal structure of a polydata :-)
alex.
A 04:55 09/07/2004 -0400, Hualiang Zhong a écrit :
>Hi all,
>
>I am wondering anybody know how to delete a cell from vtkPolyData?
>Its DeleteCell(i) method only marks the cell type as VTK_EMPTY_CELL, but I
>still don't know how to really remove the cell from the polydata before I
>visualize it.
>
>Thanks for all sugestions!
>
>Hualiang Zhong
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at:
><http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list