[vtkusers] vtkCellArray - efficient use
Paul Harris
harris.pc at gmail.com
Thu Jan 15 19:38:52 EST 2009
Hi,
I have the following code:
vtkCellArray * p_cells = vtkCellArray::New();
p_cells->Allocate( ids.size() );
for ( vector<vtkIdType>::const_iterator id = ids.begin(), id_end =
ids.end(); id != id_end; ++id )
p_cells->InsertNextCell(1,&*c);
But, I am not sure that my Allocate() call is correct. Should it be:
Allocate(ids.size()*2);
... the reason I ask is that I wanted to try and use p_cells->WritePointer()
to do the copying with a memcpy, but it looks like the format of a CellArray
is something like:
[cellid, pointid, cellid, pointid, cellid, pointid]
if i had 2 points per cell it would be
[cellid, point1, point2, cellid, point1, point2, etc]
if this is so, then in order to create a cellarray of 20 points, each in
their own cells, i'd need to alloc room for 40.
Am I reading the code correctly?
Does anyone do efficient copies, or does everyone use InsertNextEtc()
methods?
thanks,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090116/c9249f67/attachment.htm>
More information about the vtkusers
mailing list