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

Method StripGhostLayersFromGrid

Common/DataModel/vtkAMRUtilities.cxx:215–260  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

213
214//------------------------------------------------------------------------------
215vtkUniformGrid* vtkAMRUtilities::StripGhostLayersFromGrid(vtkUniformGrid* grid, int ghost[6])
216{
217 assert("pre: input grid is nullptr" && (grid != nullptr));
218
219 // STEP 0: Get the grid properties, i.e., origin, dims, extent, etc.
220 double origin[3];
221 double spacing[3];
222 int dims[3];
223 int ghostedGridDims[3];
224
225 grid->GetOrigin(origin);
226 grid->GetSpacing(spacing);
227 grid->GetDimensions(ghostedGridDims);
228 grid->GetDimensions(dims);
229
230 int copyExtent[6];
231 grid->GetExtent(copyExtent);
232
233 // STEP 1: Adjust origin, copyExtent, dims according to the supplied ghost
234 // vector.
235 for (int i = 0; i < 3; ++i)
236 {
237 if (ghost[i * 2] > 0)
238 {
239 copyExtent[i * 2] += ghost[i * 2];
240 dims[i] -= ghost[i * 2];
241 origin[i] += ghost[i * 2] * spacing[i];
242 }
243 if (ghost[i * 2 + 1] > 0)
244 {
245 dims[i] -= ghost[i * 2 + 1];
246 copyExtent[i * 2 + 1] -= ghost[i * 2 + 1];
247 }
248 } // END for all dimensions
249
250 // STEP 2: Initialize the unghosted grid
251 vtkUniformGrid* myGrid = vtkUniformGrid::New();
252 myGrid->Initialize();
253 myGrid->SetOrigin(origin);
254 myGrid->SetSpacing(spacing);
255 myGrid->SetDimensions(dims);
256
257 // STEP 3: Copy the field data within the real extent
258 vtkAMRUtilities::CopyFieldsWithinRealExtent(copyExtent, grid, myGrid);
259 return (myGrid);
260}
261
262//------------------------------------------------------------------------------
263void vtkAMRUtilities::StripGhostLayers(

Callers

nothing calls this directly

Calls 10

assertFunction · 0.50
NewFunction · 0.50
GetOriginMethod · 0.45
GetSpacingMethod · 0.45
GetDimensionsMethod · 0.45
GetExtentMethod · 0.45
InitializeMethod · 0.45
SetOriginMethod · 0.45
SetSpacingMethod · 0.45
SetDimensionsMethod · 0.45

Tested by

no test coverage detected