------------------------------------------------------------------------------
| 232 | |
| 233 | //------------------------------------------------------------------------------ |
| 234 | void vtkExplicitStructuredGrid::GetCellNeighbors( |
| 235 | vtkIdType cellId, vtkIdType neighbors[6], int* wholeExtent) |
| 236 | { |
| 237 | int ci, cj, ck; |
| 238 | this->ComputeCellStructuredCoords(cellId, ci, cj, ck, true); |
| 239 | int* extent = wholeExtent; |
| 240 | if (!wholeExtent) |
| 241 | { |
| 242 | // If the whole extent have not been defined, use own extent |
| 243 | extent = new int[6]; |
| 244 | this->GetExtent(extent); |
| 245 | } |
| 246 | int dims[3]; |
| 247 | vtkStructuredData::GetDimensionsFromExtent(extent, dims); |
| 248 | dims[0]--; |
| 249 | dims[1]--; |
| 250 | dims[2]--; |
| 251 | for (int faceId = 0; faceId < 6; faceId++) |
| 252 | { |
| 253 | int c[] = { ci - extent[0], cj - extent[2], ck - extent[4] }; |
| 254 | c[faceId / 2] += (faceId % 2) ? 1 : -1; |
| 255 | bool invalidCellId = |
| 256 | (c[0] < 0 || c[1] < 0 || c[2] < 0 || c[0] >= dims[0] || c[1] >= dims[1] || c[2] >= dims[2]); |
| 257 | neighbors[faceId] = invalidCellId ? -1 : (c[0] + c[1] * dims[0] + c[2] * dims[0] * dims[1]); |
| 258 | } |
| 259 | if (!wholeExtent) |
| 260 | { |
| 261 | delete[] extent; |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | namespace |
| 266 | { |
no test coverage detected