[vtkusers] Inverse of vtkStructuredData::ComputeCellIdForExtent?

George Zagaris george.zagaris at kitware.com
Mon Nov 28 19:24:28 EST 2011


Hi David,

I don't believe we have such a method, but, it will be very useful.

Given a linear index, l, with respect to a grid with dimensions [Ni Nj
Nk] you can compute the corresponding i-j-k triplet with something
like the following:

k = l / (Ni*Nj)
j = (l - (k - 1) * Ni*Nj) / Ni
i = l - (k - 1) * Ni*Nj - (j - 1) *Ni

Note, that the i-j-k triplet must be computed in that order. This
should work for IJK- and IJ- ordered datasets and with minor
modification (shifting) for IK- and JK- ordered data.

Further, given the linear index, l,  you may find the following
operations useful which would alleviate the need for mapping back to
the i-j-k triplet (e.g., in FD approximations):

i-1 , j,    k   => l - Nj
i,     j-1, k   => l - 1
i,     j+1,k   => l + 1
i+1, j,    k   => l + Nj
i,     j, k-1   => l  - Ni*Nj
i,     j, k+1  => l + Ni*Nj

Hope this helps.

Best,
George

On Mon, Nov 28, 2011 at 3:52 PM, David Doria <daviddoria at gmail.com> wrote:
> There are functions to get a cell/point id from the structured grid location:
>
> http://www.vtk.org/doc/nightly/html/classvtkStructuredData.html#a9bb9486010fa7aa394148bdc8b330cc8
>
> vtkIdType vtkStructuredData::ComputeCellIdForExtent     (int extent[6],
> int ijk[3] )
>
> Are there inverse functions somewhere? Something like
>
> void vtkStructuredData::ComputeStructuredIndexFromCellId(vtkIdType
> cellId, int ijk[3] )
>
> ?
>
> David
> _______________________________________________
> 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