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

Method GetDataSet

Common/DataModel/vtkDataObjectTree.cxx:303–370  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

301
302//------------------------------------------------------------------------------
303vtkDataObject* vtkDataObjectTree::GetDataSet(vtkCompositeDataIterator* compositeIter)
304{
305 if (!compositeIter || compositeIter->IsDoneWithTraversal())
306 {
307 vtkErrorMacro("Invalid iterator location.");
308 return nullptr;
309 }
310
311 if (auto dObjTreeIter = vtkDataObjectTreeIterator::SafeDownCast(compositeIter))
312 {
313 vtkDataObjectTreeIndex index = dObjTreeIter->GetCurrentIndex();
314
315 if (index.empty())
316 {
317 // Sanity check.
318 vtkErrorMacro("Invalid index returned by iterator.");
319 return nullptr;
320 }
321
322 vtkDataObjectTree* parent = this;
323 int numIndices = static_cast<int>(index.size());
324 for (int cc = 0; cc < numIndices - 1; cc++)
325 {
326 if (!parent || parent->GetNumberOfChildren() <= index[cc])
327 {
328 vtkErrorMacro("Structure is not expected. Did you forget to use copy structure?");
329 return nullptr;
330 }
331 parent = vtkDataObjectTree::SafeDownCast(parent->GetChild(index[cc]));
332 }
333
334 if (!parent || parent->GetNumberOfChildren() <= index.back())
335 {
336 vtkErrorMacro("Structure is not expected. Did you forget to use copy structure?");
337 return nullptr;
338 }
339
340 return parent->GetChild(index.back());
341 }
342 else
343 {
344 // WARNING: We are doing something special here. See comments
345 // in CopyStructure()
346 // To do: More clear check of structures here. At least something like this->Depth()==1
347 unsigned int currentFlatIndex = compositeIter->GetCurrentFlatIndex();
348
349 if (this->GetNumberOfChildren() != 1)
350 {
351 vtkErrorMacro("Structure is not expected. Did you forget to use copy structure?");
352 return nullptr;
353 }
354 auto parent = vtkPartitionedDataSet::SafeDownCast(this->GetChild(0));
355 if (!parent)
356 {
357 vtkErrorMacro("Structure is not expected. Did you forget to use copy structure?");
358 return nullptr;
359 }
360

Callers

nothing calls this directly

Calls 8

GetNumberOfChildrenMethod · 0.95
GetChildMethod · 0.95
backMethod · 0.80
GetCurrentFlatIndexMethod · 0.80
IsDoneWithTraversalMethod · 0.45
GetCurrentIndexMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected