[vtkusers] Traverse cells in unstructured grid, keep cellId

Markus Ringlander makkan at gmail.com
Thu Jun 1 13:51:26 EDT 2006


Hi,

I am traversing cells in an unstructured grid the following way:

vtkCellArray *cells = vtkCellArray::New();
cells->InitTraversal();

int npts, *pts;

while(cells->GetNextCell(npts, pts))
{
...
}

This way I obtain the cell with points "pts" in constant time O(1), but I
lose any kind of direct cell identification. I need to use many of the
functions where I need cellId's, like GetCellNeighbors(cellId, ...).

I could use another approach with the function ugrid->GetCell(cellId) in a
for-loop to get my cells, where I simply loop over an increasing index
"cellId", and later obtain the pointId's and coordinates, etc. But the call
to GetCell is supposed to be worst case O(n) (really true?) in time, and if
I traverse a grid of n cells, this might end up being worst case O(n^2) in
time. With a large number of cells this probably is not a good idea.

So my question is, is there a (fast) way to keep an identification of which
cell I just got the points from in the above GetNextCell-method using a
vtkCellArray? Or any other recommendation.

Thanks,

/Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060601/54a229ed/attachment.htm>


More information about the vtkusers mailing list