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

Method RequestData

Filters/AMR/vtkImageToAMR.cxx:223–356  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

221
222//------------------------------------------------------------------------------
223int vtkImageToAMR::RequestData(vtkInformation* vtkNotUsed(request),
224 vtkInformationVector** inputVector, vtkInformationVector* outputVector)
225{
226 vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
227
228 vtkImageData* input = vtkImageData::GetData(inputVector[0], 0);
229 vtkOverlappingAMR* amr = vtkOverlappingAMR::GetData(outputVector);
230
231 if (input->GetDataDimension() < 2)
232 {
233 vtkErrorMacro("Image dimension must be at least two.");
234 return 0;
235 }
236
237 int whole_extent[6];
238 inInfo->Get(vtkCompositeDataPipeline::WHOLE_EXTENT(), whole_extent);
239
240 int dims[3] = { whole_extent[1] - whole_extent[0] + 1, whole_extent[3] - whole_extent[2] + 1,
241 whole_extent[5] - whole_extent[4] + 1 };
242
243 double inputBounds[6];
244 input->GetBounds(inputBounds);
245
246 double inputOrigin[3] = { inputBounds[0], inputBounds[2], inputBounds[4] };
247
248 double inputSpacing[3];
249 input->GetSpacing(inputSpacing);
250
251 int gridDescription = vtkStructuredData::GetDataDescription(dims);
252
253 // check whether the parameters are valid
254 // and compute the base image resolution
255 int dims0[3];
256 double spacing0[3];
257 for (int d = 0; d < 3; d++)
258 {
259 if (dims[d] <= 1)
260 {
261 if (dims[d] == 0)
262 {
263 vtkWarningMacro("Zero dimension? Really?");
264 }
265 dims0[d] = 1;
266 spacing0[d] = 1.0;
267 }
268 else
269 {
270 int r = (int)(pow(static_cast<double>(this->RefinementRatio), this->NumberOfLevels - 1));
271 if ((dims[d] - 1) % r != 0)
272 {
273 vtkErrorMacro("Image cannot be refined");
274 return 0;
275 }
276 dims0[d] = 1 + (dims[d] - 1) / r;
277 spacing0[d] = r * inputSpacing[d];
278 }
279 }
280

Callers

nothing calls this directly

Calls 15

ConstructGridFunction · 0.85
GetInformationObjectMethod · 0.80
CheckAbortMethod · 0.80
GetAMRBoxMethod · 0.80
SplitFunction · 0.70
DeleteMethod · 0.65
GetDataFunction · 0.50
powFunction · 0.50
minFunction · 0.50
GetDataDimensionMethod · 0.45
GetMethod · 0.45
GetBoundsMethod · 0.45

Tested by

no test coverage detected