[vtk-developers] vtkStructuredGrid::GetCell(i,j,k)
David Doria
daviddoria+vtk at gmail.com
Fri Feb 19 13:47:38 EST 2010
On Fri, Feb 19, 2010 at 11:48 AM, Francois Bertel <
francois.bertel at kitware.com> wrote:
> Bbviously the documentation is wrong. Cell extent can be negative.
>
> a cell (voxel) of extent (i,j,k) is a cube with points going from
> extent (i,j,k) to extent (i+1,j+1,k+1).
>
Ok, here is the updated description paragraph (using extents instead of
indices starting at 0:
// The order and number of points must match that specified by the
dimensions
// of the grid. The point order increases in i fastest (from
extent[0]<=i<=extent[1]),
// then j (extent[2]<=j<=extent[3]), then k (extent[4]<=k<=extent[5]). The
number of
// points is dims[0]*dims[1]*dims[2]. The same is true for the cells of the
// grid. The order and number of cells must match that specified by the
// dimensions of the grid. The cell order increases in i fastest (from
// extent[0]<=i<=(extent[1]-1)), then j (extent[2]<=j<=(extent[3]-1)),
// then k (extent[4]<=k<=(extent[5]-1)).
// The number of cells is (dims[0]-1)*(dims[1]-1)*(dims[2]-1).
And here is the function:
vtkCell* vtkStructuredGrid::GetCell(int i, int j, int k, bool
adjustForExtent)
{
int extent[6];
this->GetExtent(extent);
if(i < extent[0] || i > extent[1] ||
j < extent[2] || j > extent[3] ||
k < extent[4] || k > extent[5])
{
return NULL; // out of bounds!
}
int pos[3];
pos[0] = i;
pos[1] = j;
pos[2] = k;
vtkIdType id;
if(adjustForExtent)
{
id = vtkStructuredData::ComputeCellIdForExtent(extent, pos);
}
else
{
int dim[3];
this->GetDimensions(dim);
id = vtkStructuredData::ComputeCellId(dim, pos);
}
return this->GetCell(id);
}
If someone could please check it out and give me the go ahead to commit that
would be great.
Thanks,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100219/d767c492/attachment.html>
More information about the vtk-developers
mailing list