MCPcopy Create free account
hub / github.com/Kitware/VTK / GetCellNeighbors

Method GetCellNeighbors

Common/DataModel/vtkExplicitStructuredGrid.cxx:234–263  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

232
233//------------------------------------------------------------------------------
234void 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
265namespace
266{

Callers 1

Calls 8

BuildLinksMethod · 0.95
GetExtentMethod · 0.45
ResetMethod · 0.45
GetNumberOfIdsMethod · 0.45
GetPointerMethod · 0.45
GetMethod · 0.45
DispatchMethod · 0.45

Tested by

no test coverage detected