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

Method RequestData

Filters/Extraction/vtkExtractBlock.cxx:98–148  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

96
97//------------------------------------------------------------------------------
98int 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//------------------------------------------------------------------------------
151bool vtkExtractBlock::Prune(vtkDataObject* branch)

Callers

nothing calls this directly

Calls 15

CopySubTreeMethod · 0.95
PruneMethod · 0.95
NewTreeIteratorMethod · 0.80
CheckAbortMethod · 0.80
GetCurrentFlatIndexMethod · 0.80
DeleteMethod · 0.65
GetDataFunction · 0.50
findMethod · 0.45
endMethod · 0.45
CompositeShallowCopyMethod · 0.45
CopyStructureMethod · 0.45
InitTraversalMethod · 0.45

Tested by

no test coverage detected