[vtkusers] Assigning cell values on structured grid
David Doria
daviddoria+vtk at gmail.com
Fri Feb 19 08:01:48 EST 2010
On Fri, Feb 19, 2010 at 6:30 AM, Sebastian Gatzka <
sebastian.gatzka at stud.tu-darmstadt.de> wrote:
> Hello.
>
> This time I'm trying to set cell (centroid) values (scalar and vector) to a
> structured grid.
> All the examples I have found set values to the grid points - not the
> cell-centroids.
>
> This should lead to a classical CFD / finite-volume representation of field
> data like temperature, density or velocities.
> So beside the actual assignment to the field I need to know how to display
> the field data, and maybe how to switch between them.
>
> Have a nice day.
> Sebastian
>
>
Sebastian,
You can access cells via their (i,j,k) coordinates using this function:
vtkCell* GetCell(vtkStructuredGrid* grid, int i, int j, int k)
{
int dims[3];
grid->GetDimensions(dims);
if(i < 0 || i > dims[0] - 1 ||
j < 0 || j > dims[1] - 1 ||
k < 0 || k > dims[2] - 1 )
{
return NULL; // out of bounds!
}
int pos[3];
pos[0] = i;
pos[1] = j;
pos[2] = k;
vtkIdType id;
id = vtkStructuredData::ComputeCellId(dims, pos);
return grid->GetCell(id);
}
I'm working on adding it to vtk so you can directly call
grid->GetCell(i,j,k)
Hope this helps,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100219/2656fc54/attachment.htm>
More information about the vtkusers
mailing list