<div>If you'll recall, we recently added a GetPoint(i,j,k,p[3], bool adjustForExtent) function to vtkStructuredGrid. A question on the users list last night made me realize that it should also be possible to access cells in this style.</div>
<div><br></div><div>While I was writing a </div><div><br></div><div>vtkCell* vtkStructuredGrid::GetCell(int i, int j, int k)</div><div><br></div><div>I noticed that in vtkStructuredData there is a ComputeCellId as well as a ComputeCellIdForExtent. I don't understand what the extent has anything to do with the cell index? In ComputePointId vs ComputePointIdForExtent, the difference is do we interpert (i,j,k) explicitly (as coordinates in the grid) or as an offset from the grid origin. The cells, however, seem like they should simply be numbered according to this (from the vtkStructuredGrid documentation):</div>
<div><br></div><div>"The cell order increases in i fastest (from 0<=i<(dims[0]-1)), then j (0<=j<(dims[1]-1)), then k (0<=k<(dims[2]-1)) The number of cells is (dims[0]-1)*(dims[1]-1)*(dims[2]-1)."</div>
<div><br></div><div>So I don't understand when you would need to call vtkComputeCellForExtent?</div><div><br></div><div>If I'm right, here is my proposed function:</div><div><br></div><div><div>vtkCell* vtkStructuredGrid::GetCell(int i, int j, int k)</div>
<div>{</div><div> int dims[3];</div><div> this->GetDimensions(dims);</div><div><br></div><div> if(i < 0 || i > dims[0] - 1 || </div><div> j < 0 || j > dims[1] - 1 || </div><div> k < 0 || k > dims[2] - 1 )</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> id = vtkStructuredData::ComputeCellId(dims, pos);</div><div> </div><div> return this->GetCell(id); </div><div>}</div></div><div><br></div>Thanks,<br><br>David<br>