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<br><br>GetPoint(i, j, k, pt);<br><br>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:<br>
<br>for (i=extent[0]; i<extent[1]; i++)<br> for (j=extent[2]; j<extent[2]; k++)<br>
for (k=extent[3]; k<extent[4]; k++)<br><br>than<br><br>for (i=0; i<dims[1]; i++)<br>
for (j=0; j<dims[2]; k++)<br>
for (k=0; k<dims[4]; k++)<br>
<br>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).<br><br>-berk<br><br><div class="gmail_quote">On Fri, Feb 5, 2010 at 7:27 PM, David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">On Fri, Feb 5, 2010 at 4:06 PM, David Doria <<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>> wrote:<br>
<br>
> Ah, even better. What about something like this (surely the flag name should<br>
> change...):<br>
> void vtkStructuredGrid::GetPoint(int x, int y, int z, bool<br>
> adjustForNonZeroExtentBeginning, double p[3])<br>
> {<br>
> int extent[6];<br>
> this->GetExtent(extent);<br>
> if(x < extent[0] || x > extent[1] ||<br>
> y < extent[2] || y > extent[3] ||<br>
> z < extent[4] || z > extent[5])<br>
> {<br>
> return; // out of bounds!<br>
> }<br>
><br>
> int pos[3];<br>
> pos[0] = x;<br>
> pos[1] = y;<br>
> pos[2] = z;<br>
> vtkIdType id;<br>
> if(adjustForNonZeroExtentBeginning)<br>
> {<br>
> id = vtkStructuredData::ComputePointIdForExtent(extent, pos);<br>
> }<br>
> else<br>
> {<br>
> int dim[3];<br>
> this->GetDimensions(dim);<br>
> id = vtkStructuredData::ComputePointId(dim, pos);<br>
> }<br>
> grid->GetPoint(id, p);<br>
> }<br>
> The point is just to access the point via GetPoint as you would with<br>
> PolyData and UnstructuredGrid, but rather than a linear index, here (as with<br>
> ImageData) a (x,y,z) index is needed. This is opposed to using static<br>
> vtkStructuredData functions, which don't seem to be pointed to anywhere in<br>
> the vtkStructuredGrid documentation.<br>
<br>
</div></div>Personally, I think that's fine. The flag will make people stop and<br>
think instead of just assuming that it works one way or another.<br>
<br>
Honestly the structured data types are a bit confused about what the<br>
(x,y,z) integer structured coordinates are defined. Originally<br>
(meaning 15+ years ago, before vtkImageData even existed) the indices<br>
started at zero by definition, and all the "structured" data classes<br>
were written under the assumption that the the indices would always<br>
start at zero.<br>
<br>
Then came vtkImageData and a bunch of changes to the pipeline that<br>
added some great new features and also messed things up a bit. And<br>
after that came the merging of vtkImageData and vtkStructuredPoints,<br>
which was necessary, but also problematic because the two classes<br>
weren't quite compatible with each other.<br>
<br>
To make a long story short, I think you are correct to have that flag<br>
there, because it allows people to choose between the "original" way<br>
of indexing into structured data (could I call it "as Bill<br>
intended??"), and the "new" way of indexing that was introduced to VTK<br>
with vtkImageData.<br>
<div><div></div><div class="h5"><br>
David<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
<br>
</div></div></blockquote></div><br>