------------------------------------------------------------------------------
| 301 | |
| 302 | //------------------------------------------------------------------------------ |
| 303 | vtkDataObject* 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 |
nothing calls this directly
no test coverage detected