------------------------------------------------------------------------------
| 393 | |
| 394 | //------------------------------------------------------------------------------ |
| 395 | bool vtkHyperTreeGridThreshold::RecursivelyProcessTree( |
| 396 | vtkHyperTreeGridNonOrientedCursor* inCursor, vtkHyperTreeGridNonOrientedCursor* outCursor) |
| 397 | { |
| 398 | // Retrieve global index of input cursor |
| 399 | vtkIdType inId = inCursor->GetGlobalNodeIndex(); |
| 400 | |
| 401 | // Increase index count on output: postfix is intended |
| 402 | vtkIdType outId = this->CurrentId++; |
| 403 | |
| 404 | // Copy out cell data from that of input cell |
| 405 | if (!this->Internal->CDManager) |
| 406 | { |
| 407 | vtkErrorMacro("Must set the CellDataManager before processing trees"); |
| 408 | return false; |
| 409 | } |
| 410 | (*(this->Internal->CDManager))(inId, outId); |
| 411 | |
| 412 | // Retrieve output tree and set global index of output cursor |
| 413 | vtkHyperTree* outTree = outCursor->GetTree(); |
| 414 | outTree->SetGlobalIndexFromLocal(outCursor->GetVertexId(), outId); |
| 415 | |
| 416 | // Flag to recursively decide whether a tree node should discarded |
| 417 | bool discard = true; |
| 418 | |
| 419 | if (this->InMask && this->InMask->GetValue(inId)) |
| 420 | { |
| 421 | // Mask output cell if necessary |
| 422 | this->OutMask->InsertTuple1(outId, discard); |
| 423 | |
| 424 | // Return whether current node is within range |
| 425 | return discard; |
| 426 | } |
| 427 | |
| 428 | // Descend further into input trees only if cursor is not at leaf |
| 429 | if (!inCursor->IsLeaf()) |
| 430 | { |
| 431 | // Cursor is not at leaf, subdivide output tree one level further |
| 432 | outCursor->SubdivideLeaf(); |
| 433 | |
| 434 | // If input cursor is neither at leaf nor at maximum depth, recurse to all children |
| 435 | int numChildren = inCursor->GetNumberOfChildren(); |
| 436 | for (int ichild = 0; ichild < numChildren; ++ichild) |
| 437 | { |
| 438 | if (this->CheckAbort()) |
| 439 | { |
| 440 | break; |
| 441 | } |
| 442 | // Descend into child in input grid as well |
| 443 | inCursor->ToChild(ichild); |
| 444 | // Descend into child in output grid as well |
| 445 | outCursor->ToChild(ichild); |
| 446 | // Recurse and keep track of whether some children are kept |
| 447 | discard &= this->RecursivelyProcessTree(inCursor, outCursor); |
| 448 | // Return to parent in input grid |
| 449 | outCursor->ToParent(); |
| 450 | // Return to parent in output grid |
| 451 | inCursor->ToParent(); |
| 452 | } // child |
no test coverage detected