[vtkusers] How to read out voxels values of a structured grid by x, y, z coordinates?
David Doria
daviddoria+vtk at gmail.com
Thu Feb 4 16:22:36 EST 2010
>
> It's been a while since I played with it, but maybe this will help:
>
>
> http://vtk.org/Wiki/Structured_Grid
>
> If you figure it out and could clean up the example that would be great.
>
> Thanks,
>
> David
>
Actually, I've been meaning to suggest this for a while: can we add the
following function (maybe named differently, and clearly a different
prototype, but this will work for a "non-added-to-VTK" solution):
void GetPoint(vtkStructuredGrid* grid, int x, int y, int z, double p[3])
{
int dims[3];
grid->GetDimensions(dims);
if(x >= dims[0] || y >= dims[1] || z >= dims[2])
{
return; // out of bounds!
}
int ind = z*dims[1]*dims[0] + y*dims[0] + x;
//cout << "x: " << x << " y: " << y << " z: " << z << " ind: " << ind <<
endl;
grid->GetPoint(ind, p);
}
Thanks,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100204/ccc6f45e/attachment.htm>
More information about the vtkusers
mailing list