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

Method RequestData

Filters/GeometryPreview/vtkPointSetToOctreeImageFilter.cxx:238–415  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

236
237//------------------------------------------------------------------------------
238int vtkPointSetToOctreeImageFilter::RequestData(
239 vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
240{
241 // get the input
242 vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
243 vtkPointSet* input = vtkPointSet::GetData(inInfo);
244
245 // get the output
246 vtkInformation* outInfo = outputVector->GetInformationObject(0);
247 vtkPartitionedDataSet* outputPDS = vtkPartitionedDataSet::GetData(outInfo);
248
249 if (!input || input->GetNumberOfPoints() == 0)
250 {
251 vtkErrorMacro("No input or empty input.");
252 return 0;
253 }
254
255 if (this->NumberOfPointsPerCell > input->GetNumberOfPoints())
256 {
257 vtkErrorMacro("NumberOfPointsPerCell must be less than or equal to the number of points.");
258 return 0;
259 }
260
261 // get input points information
262 double pointSetBounds[6];
263 input->GetBounds(pointSetBounds);
264
265 // compute output image information as it's done in vtkStaticPointLocator when Automatic is on.
266 double imageBounds[6];
267 int nDivs[3];
268 vtkIdType numBuckets = static_cast<vtkIdType>(static_cast<double>(input->GetNumberOfPoints()) /
269 static_cast<double>(this->NumberOfPointsPerCell));
270 vtkBoundingBox bbox(pointSetBounds);
271 bbox.ComputeDivisions(numBuckets, imageBounds, nDivs);
272 const double origin[3] = { imageBounds[0], imageBounds[2], imageBounds[4] };
273 const double spacing[3] = { (imageBounds[1] - imageBounds[0]) / static_cast<double>(nDivs[0]),
274 (imageBounds[3] - imageBounds[2]) / static_cast<double>(nDivs[1]),
275 (imageBounds[5] - imageBounds[4]) / static_cast<double>(nDivs[2]) };
276 const int dimensions[3] = { 1 + nDivs[0], 1 + nDivs[1], 1 + nDivs[2] };
277 const vtkIdType numberOfCells = nDivs[0] * nDivs[1] * nDivs[2];
278
279 // create output image octree array
280 vtkNew<vtkUnsignedCharArray> octree;
281 octree->SetName("octree");
282 octree->SetNumberOfValues(numberOfCells);
283 vtkSMPTools::Fill(octree->GetPointer(0), octree->GetPointer(0) + numberOfCells, 0);
284
285 // create output image field array
286 vtkSmartPointer<vtkFloatArray> outField = nullptr;
287 vtkDataArray* inField = nullptr;
288 std::vector<FieldFunctions> functions;
289 if (this->ProcessInputPointArray)
290 {
291 inField = this->GetInputArrayToProcess(0, inputVector);
292 if (!inField)
293 {
294 vtkErrorMacro("Array to process is null.");
295 return 0;

Callers

nothing calls this directly

Calls 15

GetInformationObjectMethod · 0.80
ComputeDivisionsMethod · 0.80
SetComponentNameMethod · 0.80
SetScalarsMethod · 0.80
GetDataFunction · 0.50
FillFunction · 0.50
NewFunction · 0.50
maxFunction · 0.50
ForFunction · 0.50
copyFunction · 0.50
ExecuteFunction · 0.50

Tested by

no test coverage detected