[vtk-developers] Add GetPoint function to vtkStructuredGrid

Berk Geveci berk.geveci at kitware.com
Fri Feb 5 21:34:44 EST 2010


I wouldn't have the flag but if I was forced to have it, I'd have it as the
last argument with a default value set to false (I think) so that one can
still do

GetPoint(i, j, k, pt);

I think that it is better to force people to think in terms of extents
because that is the way they need to implement their algorithms if they want
them to work when streaming. So, if they are going to loop over all points,
I'd rather they did:

for (i=extent[0]; i<extent[1]; i++)
  for (j=extent[2]; j<extent[2]; k++)
    for (k=extent[3]; k<extent[4]; k++)

than

for (i=0; i<dims[1]; i++)
  for (j=0; j<dims[2]; k++)
    for (k=0; k<dims[4]; k++)

Also, I wouldn't use x, y and z for variable names as many people associate
those names with position rather than index (nitpicking here).

-berk

On Fri, Feb 5, 2010 at 7:27 PM, David Gobbi <david.gobbi at gmail.com> wrote:

> On Fri, Feb 5, 2010 at 4:06 PM, David Doria <daviddoria+vtk at gmail.com<daviddoria%2Bvtk at gmail.com>>
> wrote:
>
> > Ah, even better. What about something like this (surely the flag name
> should
> > change...):
> > void vtkStructuredGrid::GetPoint(int x, int y, int z, bool
> > adjustForNonZeroExtentBeginning, double p[3])
> > {
> >   int extent[6];
> >   this->GetExtent(extent);
> >   if(x < extent[0] || x > extent[1] ||
> >      y < extent[2] || y > extent[3] ||
> >      z < extent[4] || z > extent[5])
> >     {
> >     return; // out of bounds!
> >     }
> >
> >   int pos[3];
> >   pos[0] = x;
> >   pos[1] = y;
> >   pos[2] = z;
> >   vtkIdType id;
> >   if(adjustForNonZeroExtentBeginning)
> >     {
> >     id = vtkStructuredData::ComputePointIdForExtent(extent, pos);
> >     }
> >   else
> >     {
> >     int dim[3];
> >     this->GetDimensions(dim);
> >     id = vtkStructuredData::ComputePointId(dim, pos);
> >     }
> >   grid->GetPoint(id, p);
> > }
> > The point is just to access the point via GetPoint as you would with
> > PolyData and UnstructuredGrid, but rather than a linear index, here (as
> with
> > ImageData) a (x,y,z) index is needed. This is opposed to using static
> > vtkStructuredData functions, which don't seem to be pointed to anywhere
> in
> > the vtkStructuredGrid documentation.
>
> Personally, I think that's fine.  The flag will make people stop and
> think instead of just assuming that it works one way or another.
>
> Honestly the structured data types are a bit confused about what the
> (x,y,z) integer structured coordinates are defined.  Originally
> (meaning 15+ years ago, before vtkImageData even existed) the indices
> started at zero by definition, and all the "structured" data classes
> were written under the assumption that the the indices would always
> start at zero.
>
> Then came vtkImageData and a bunch of changes to the pipeline that
> added some great new features and also messed things up a bit.  And
> after that came the merging of vtkImageData and vtkStructuredPoints,
> which was necessary, but also problematic because the two classes
> weren't quite compatible with each other.
>
> To make a long story short, I think you are correct to have that flag
> there, because it allows people to choose between the "original" way
> of indexing into structured data (could I call it "as Bill
> intended??"), and the "new" way of indexing that was introduced to VTK
> with vtkImageData.
>
>  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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100205/9bf1936d/attachment.html>


More information about the vtk-developers mailing list