------------------------------------------------------------------------------
| 96 | |
| 97 | //------------------------------------------------------------------------------ |
| 98 | int vtkExtractBlock::RequestData(vtkInformation* vtkNotUsed(request), |
| 99 | vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 100 | { |
| 101 | auto input = vtkDataObjectTree::GetData(inputVector[0], 0); |
| 102 | auto output = vtkDataObjectTree::GetData(outputVector, 0); |
| 103 | if (this->Indices->find(0) != this->Indices->end()) |
| 104 | { |
| 105 | // trivial case. |
| 106 | output->CompositeShallowCopy(input); |
| 107 | return 1; |
| 108 | } |
| 109 | |
| 110 | // pruning is unnecessary for vtkPartitionedDataSetCollection and hence we |
| 111 | // skip it. |
| 112 | const bool prune = |
| 113 | vtkPartitionedDataSetCollection::SafeDownCast(input) ? false : (this->PruneOutput != 0); |
| 114 | |
| 115 | output->CopyStructure(input); |
| 116 | |
| 117 | vtkSet activeIndices(*this->Indices); |
| 118 | |
| 119 | // Copy selected blocks over to the output. |
| 120 | vtkDataObjectTreeIterator* iter = input->NewTreeIterator(); |
| 121 | iter->VisitOnlyLeavesOff(); |
| 122 | iter->SkipEmptyNodesOff(); |
| 123 | for (iter->InitTraversal(); !iter->IsDoneWithTraversal() && !activeIndices.empty(); |
| 124 | iter->GoToNextItem()) |
| 125 | { |
| 126 | if (this->CheckAbort()) |
| 127 | { |
| 128 | break; |
| 129 | } |
| 130 | if (activeIndices.find(iter->GetCurrentFlatIndex()) != activeIndices.end()) |
| 131 | { |
| 132 | activeIndices.erase(iter->GetCurrentFlatIndex()); |
| 133 | this->CopySubTree(iter, output, input, activeIndices); |
| 134 | |
| 135 | if (prune) |
| 136 | { |
| 137 | // add a "hint" to the output to help identify visited nodes. |
| 138 | output->GetMetaData(iter)->Set(DONT_PRUNE(), 1); |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | iter->Delete(); |
| 143 | if (prune) |
| 144 | { |
| 145 | this->Prune(output); |
| 146 | } |
| 147 | return 1; |
| 148 | } |
| 149 | |
| 150 | //------------------------------------------------------------------------------ |
| 151 | bool vtkExtractBlock::Prune(vtkDataObject* branch) |
nothing calls this directly
no test coverage detected