<div class="gmail_quote">On Fri, Feb 19, 2010 at 11:48 AM, Francois Bertel <span dir="ltr"><<a href="mailto:francois.bertel@kitware.com">francois.bertel@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Bbviously the documentation is wrong. Cell extent can be negative.<br>
<br>
a cell (voxel) of extent (i,j,k) is a cube with points going from<br>
extent (i,j,k) to extent (i+1,j+1,k+1).<br>
<div><div></div><div class="h5"></div></div></blockquote></div><br><div>Ok, here is the updated description paragraph (using extents instead of indices starting at 0:</div><div><br></div><div><div>// The order and number of points must match that specified by the dimensions</div>
<div>// of the grid. The point order increases in i fastest (from extent[0]<=i<=extent[1]),</div><div>// then j (extent[2]<=j<=extent[3]), then k (extent[4]<=k<=extent[5]). The number of</div><div>// points is dims[0]*dims[1]*dims[2]. The same is true for the cells of the</div>
<div>// grid. The order and number of cells must match that specified by the</div><div>// dimensions of the grid. The cell order increases in i fastest (from</div><div>// extent[0]<=i<=(extent[1]-1)), then j (extent[2]<=j<=(extent[3]-1)), </div>
<div>// then k (extent[4]<=k<=(extent[5]-1)).</div><div>// The number of cells is (dims[0]-1)*(dims[1]-1)*(dims[2]-1).</div></div><div><br></div><div>And here is the function:</div><div><br></div><div><div>vtkCell* vtkStructuredGrid::GetCell(int i, int j, int k, bool adjustForExtent)</div>
<div>{</div><div> int extent[6];</div><div> this->GetExtent(extent); </div><div><br></div><div> if(i < extent[0] || i > extent[1] || </div><div> j < extent[2] || j > extent[3] || </div><div> k < extent[4] || k > extent[5])</div>
<div> {</div><div> return NULL; // out of bounds!</div><div> }</div><div> </div><div> int pos[3];</div><div> pos[0] = i;</div><div> pos[1] = j;</div><div> pos[2] = k;</div><div><br></div><div> vtkIdType id;</div>
<div><br></div><div> if(adjustForExtent)</div><div> {</div><div> id = vtkStructuredData::ComputeCellIdForExtent(extent, pos);</div><div> }</div><div> else</div><div> {</div><div> int dim[3];</div><div> this->GetDimensions(dim); </div>
<div> id = vtkStructuredData::ComputeCellId(dim, pos);</div><div> }</div><div><br></div><div> return this->GetCell(id); </div><div>}</div><div><br></div><div>If someone could please check it out and give me the go ahead to commit that would be great.</div>
<div><br></div>Thanks,<br><br>David</div>