[vtkusers] Assigning cell values on structured grid

Sebastian Gatzka sebastian.gatzka at stud.tu-darmstadt.de
Mon Feb 22 07:02:15 EST 2010


I think setting setting up the vector data is the problem.
I have done it like this:
*
vtkDoubleArray *v = vtkDoubleArray::New();
v->SetNumberOfComponents(3);
v->SetNumberOfTuples(noCells);    // noCells = 16000
for (unsigned i = 0; i < noCells; i++){
     v->InsertNextTuple3(i,i,i);
}*

and set it to the structuredGrid like this:

*sGrid->GetCellData()->SetVectors(v);*

When running the code I get the following error:

*Cell array with 3 components has 32000 tuples but there are only 16000 
cells.
*
Whats wrong?
I think there is a basic misunderstand between cellData, Array, 
DoubleArray and Vector here?!

Am 19.02.2010 14:49, schrieb David Doria:
> On Fri, Feb 19, 2010 at 8:41 AM, Sebastian Gatzka 
> <sebastian.gatzka at stud.tu-darmstadt.de 
> <mailto:sebastian.gatzka at stud.tu-darmstadt.de>> wrote:
>
>     As far as I am concerned accessing is not the problem.
>
>     But how to set a specific value (may is be scalar or vector) to
>     the cell is what I want to do!
>
> You have to add an array containing the data for all the cells to the 
> CellData of the grid. Here is an example (uses PolyData instead of 
> StructuredGrid, but it should work the same):
>
> http://www.vtk.org/Wiki/VTK/Examples/MiscCellData
>
> The key line is
>
>  polydata->GetCellData()->AddArray(triangleData);
>
> Hope that helps,
>
> David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100222/3fef5eca/attachment.htm>


More information about the vtkusers mailing list