<div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div class="h5">Close but still no cigar. Don't use "int", use vtkIdType instead.</div>
</div>
Otherwise your code will not be 64-bit safe. In fact, to make it<br>
64-bit safe you need to do this:<br>
<br>
vtkIdType xrel = x - extent[0];<br>
vtkIdType yrel = y - extent[2];<br>
vtkIdType zrel = z - extent[4];<br>
vtkIdType ind = zrel*dims[1]*dims[0] + yrel*dims[0] + xrel;<br>
<br>
Unless xrel, yrel, and zrel are also vtkIdType, the mathematical<br>
computation of "zrel*dims[1]*dims[0] + yrel*dims[0] + xrel" will be<br>
done in 32-bit regardless the type of the variable it gets stored in.<br>
<br>
This is all kind of moot, though, because you are kinda reinventing<br>
the wheel here. After you do the bounds check you should just call<br>
the following function that will do the rest for you:<br>
<br>
vtkStructuredData::ComputePointIdForExtent(int extent[6], int ijk[3]);<br>
<br>
It already does everything but the bounds check.<br>
<font color="#888888"><br>
David<br>
</font></blockquote></div><br></div><div><br></div><div>Ah, even better. What about something like this (surely the flag name should change...):<div><br></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><div class="im" style="color: rgb(80, 0, 80); ">
<div>void vtkStructuredGrid::GetPoint(int x, int y, int z, bool adjustForNonZeroExtentBeginning, double p[3])</div><div>{</div></div><div> int extent[6];</div><div> this->GetExtent(extent); </div><div><br></div><div>
if(x < extent[0] || x > extent[1] || </div><div> y < extent[2] || y > extent[3] || </div><div> z < extent[4] || z > extent[5])</div><div> {</div><div> return; // out of bounds!</div><div>
}</div><div> </div><div> int pos[3];</div><div> pos[0] = x;</div><div> pos[1] = y;</div><div> pos[2] = z;</div><div><br></div><div> vtkIdType id;</div><div><br></div><div> if(<span class="Apple-style-span" style="color: rgb(80, 0, 80); ">adjustForNonZeroExtentBeginning)</span></div>
<div><span class="Apple-style-span" style="color: rgb(80, 0, 80); "> {</span></div><div><span class="Apple-style-span" style="color: rgb(80, 0, 80); "><span class="Apple-style-span" style="color: rgb(0, 0, 0); "> id = <span class="Apple-style-span" style="border-collapse: separate; font-family: arial; font-size: small; ">vtkStructuredData::ComputePointIdForExtent(extent, pos);</span></span></span></div>
<div><span class="Apple-style-span" style="color: rgb(80, 0, 80); "> }</span></div><div><span class="Apple-style-span" style="color: rgb(80, 0, 80); "> else</span></div><div><span class="Apple-style-span" style="color: rgb(80, 0, 80); "> {</span></div>
<div><span class="Apple-style-span" style="color: rgb(80, 0, 80); "><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><div> int dim[3];</div><div> this->GetDimensions(dim); </div></span></span></div><div>
<font class="Apple-style-span" color="#500050"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "> id = <span class="Apple-style-span" style="border-collapse: separate; font-family: arial; font-size: small; ">vtkStructuredData::ComputePointId(dim, pos);</span></span></font></div>
<div><span class="Apple-style-span" style="color: rgb(80, 0, 80); "> }</span></div><div><span class="Apple-style-span" style="border-collapse: separate; font-size: small;"><span class="Apple-style-span" style="border-collapse: collapse;"><br>
</span></span></div><div> grid->GetPoint(id, p); </div><div>}</div><div><br></div><div>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.</div>
<div><font class="Apple-style-span" face="'Lucida Grande', Verdana, Geneva, Arial, sans-serif" size="3"><span class="Apple-style-span" style="border-collapse: separate; font-size: 12px;"><font class="Apple-style-span" face="arial, sans-serif" size="3"><span class="Apple-style-span" style="border-collapse: collapse; font-size: 13px;"><br>
</span></font></span></font></div></span>Thanks,<br><br>David</div></div>