[vtkusers] vtkCellArray - efficient use
Paul Harris
harris.pc at gmail.com
Sun Jan 18 22:40:50 EST 2009
Thanks Burlen,
Another question, I checked the code for CSCS's vtkPointSpriteMapper and it
will work just fine if I put all the verticies into one cell...
Is there any reason why I should put one vertex per cell ? EG, I imagine it
may be required when adding support for point-picking ?
thanks,
Paul
2009/1/17 Burlen Loring <burlen.loring at kitware.com>
> Here is an example using vertex cells.
>
>
> vtkIdTypeArray *va=vtkIdTypeArray::New();
> va->SetNumberOfTuples(2*nCells);
> vtkIdType *verts=va->GetPointer(0);
> vtkPoints *pts=vtkPoints::New();
> pts->SetData(xyzArray);
> for (int i=0; i<nCells; ++i)
> {
> verts[0]=1;
> verts[1]=i;
> verts+=2;
> }
> polydataset->SetPoints(pts);
> pts->Delete();
> vtkCellArray *cells=vtkCellArray::New();
> cells->SetCells(static_cast<vtkIdType>(nCells),va);
> polydataset->SetVerts(cells);
> cells->Delete();
> va->Delete();
>
>
> Paul Harris wrote:
>
>> 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/20090119/c68abd7e/attachment.htm>
More information about the vtkusers
mailing list