[vtk-developers] vtkStructuredGrid::GetCell(i,j,k)
Francois Bertel
francois.bertel at kitware.com
Fri Feb 19 11:48:02 EST 2010
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).
On Fri, Feb 19, 2010 at 8:00 AM, David Doria <daviddoria+vtk at gmail.com> wrote:
> If you'll recall, we recently added a GetPoint(i,j,k,p[3], bool
> adjustForExtent) function to vtkStructuredGrid. A question on the users list
> last night made me realize that it should also be possible to access cells
> in this style.
> While I was writing a
> vtkCell* vtkStructuredGrid::GetCell(int i, int j, int k)
> I noticed that in vtkStructuredData there is a ComputeCellId as well as a
> ComputeCellIdForExtent. I don't understand what the extent has anything to
> do with the cell index? In ComputePointId vs ComputePointIdForExtent, the
> difference is do we interpert (i,j,k) explicitly (as coordinates in the
> grid) or as an offset from the grid origin. The cells, however, seem like
> they should simply be numbered according to this (from the vtkStructuredGrid
> documentation):
> "The cell order increases in i fastest (from 0<=i<(dims[0]-1)), then j
> (0<=j<(dims[1]-1)), then k (0<=k<(dims[2]-1)) The number of cells is
> (dims[0]-1)*(dims[1]-1)*(dims[2]-1)."
> So I don't understand when you would need to call vtkComputeCellForExtent?
> If I'm right, here is my proposed function:
> vtkCell* vtkStructuredGrid::GetCell(int i, int j, int k)
> {
> int dims[3];
> this->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 this->GetCell(id);
> }
> Thanks,
>
> David
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>
>
--
François Bertel, PhD | Kitware Inc. Suite 204
1 (518) 371 3971 x113 | 28 Corporate Drive
| Clifton Park NY 12065, USA
More information about the vtk-developers
mailing list