[vtkusers] StruturedGrid and CellData

David E DeMarle dave.demarle at kitware.com
Mon Nov 30 08:17:39 EST 2009


You can't easily.

vtkDataSet::GetCellData() will return the cell associated arrays, but
those are defined to have values for every cell. There are some new
sparse array types in vtk, but I haven't personally tried them. I
suspect they are not allowed in the Cell/Point Data containers.

An alternative is to use vtkDataSet::GetFieldData(), which returns
general purpose (ie not cell or point associated arrays), and make up
your own indexing scheme there.

David E DeMarle
Kitware, Inc.
R&D Engineer
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-371-3971 x109



On Tue, Nov 24, 2009 at 8:17 AM, Didier Roissé <didier.roisse at gmail.com> wrote:
> Hello,
> I have a structured grid , and I want to put data on the different cells
> inside the structured grid. I know how to do for unstructured grid, but for
> structured grid I don't know.
>
> For example i define my structured grid like this:
>     vtkStructuredGrid *sgrid = vtkStructuredGrid::New();
>     sgrid->SetDimensions(x.nbnodes,y.nbnodes,z.nbnodes);
>     vtkPoints *points = vtkPoints::New();
>     for(int k=0;k<z.nbnodes;k++)
>         for(int j=0;j<y.nbnodes;j++)
>             for(int i=0;i<x.nbnodes;i++)
>                 points->InsertNextPoint(x.nodes[i],y.nodes[j],z.nodes[k]);
>
>     sgrid->SetPoints(points);
>
>     vtkCell *cell3D = sgrid->GetCell(10);
>
> cell3D is a vtkHexaedron cell. So my problem is : How can I put a data value
> only on one of the quad cell which define cell3D ?
>
> Thanks in advance for your help
>
> Regards,
> Didier
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list