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

Method RequestData

Filters/General/vtkGradientFilter.cxx:264–380  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

262
263//------------------------------------------------------------------------------
264int vtkGradientFilter::RequestData(vtkInformation* vtkNotUsed(request),
265 vtkInformationVector** inputVector, vtkInformationVector* outputVector)
266{
267 vtkDebugMacro("RequestData");
268
269 vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
270 vtkInformation* outInfo = outputVector->GetInformationObject(0);
271
272 vtkDataSet* input = vtkDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
273 vtkDataSet* output = vtkDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
274 vtkDataArray* array = this->GetInputArrayToProcess(0, inputVector);
275
276 if (input->GetNumberOfCells() == 0)
277 {
278 // need cells to compute the gradient so if we don't have cells. we can't compute anything.
279 // if we have points and an array with values provide a warning letting the user know that
280 // no gradient will be computed because of the lack of cells. otherwise the dataset is
281 // assumed empty and we can skip providing a warning message to the user.
282 if (input->GetNumberOfPoints() && array && array->GetNumberOfTuples())
283 {
284 vtkWarningMacro("Cannot compute gradient for datasets without cells");
285 }
286 output->ShallowCopy(input);
287 return 1;
288 }
289
290 if (array == nullptr)
291 {
292 vtkErrorMacro("No input array. If this dataset is part of a composite dataset"
293 << " check to make sure that all non-empty blocks have this array.");
294 return 0;
295 }
296 if (array->GetNumberOfComponents() == 0)
297 {
298 vtkErrorMacro("Input array must have at least one component.");
299 return 0;
300 }
301
302 // we can only compute vorticity and Q criterion if the input
303 // array has 3 components. if we can't compute them because of
304 // this we only mark internally the we aren't computing them
305 // since we don't want to change the state of the filter.
306 bool computeVorticity = this->ComputeVorticity != 0;
307 bool computeDivergence = this->ComputeDivergence != 0;
308 bool computeQCriterion = this->ComputeQCriterion != 0;
309 if ((this->ComputeQCriterion || this->ComputeVorticity || this->ComputeDivergence) &&
310 array->GetNumberOfComponents() != 3)
311 {
312 vtkWarningMacro("Input array must have exactly three components with "
313 << "ComputeDivergence, ComputeVorticity or ComputeQCriterion flag enabled."
314 << "Skipping divergence, vorticity and Q-criterion computation.");
315 computeVorticity = false;
316 computeQCriterion = false;
317 computeDivergence = false;
318 }
319
320 int fieldAssociation;
321 if (vtkGradientFilterHasArray(input->GetPointData(), array))

Callers

nothing calls this directly

Calls 15

GetInformationObjectMethod · 0.80
IsAMethod · 0.80
GetMethod · 0.45
GetNumberOfCellsMethod · 0.45
GetNumberOfPointsMethod · 0.45
GetNumberOfTuplesMethod · 0.45
ShallowCopyMethod · 0.45
GetNumberOfComponentsMethod · 0.45

Tested by

no test coverage detected