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

Method CopyStructure

Common/DataModel/vtkDataObjectTree.cxx:136–208  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

134
135//------------------------------------------------------------------------------
136void vtkDataObjectTree::CopyStructure(vtkCompositeDataSet* compositeSource)
137{
138 if (!compositeSource)
139 {
140 return;
141 }
142 auto dObjTree = vtkDataObjectTree::SafeDownCast(compositeSource);
143 if (dObjTree == this)
144 {
145 return;
146 }
147
148 this->Superclass::CopyStructure(compositeSource);
149 this->Internals->Children.clear();
150
151 if (dObjTree)
152 {
153 this->Internals->Children.resize(dObjTree->Internals->Children.size());
154
155 for (auto dObjTreeIter = dObjTree->Internals->Children.begin(),
156 thisIter = this->Internals->Children.begin();
157 dObjTreeIter != dObjTree->Internals->Children.end(); ++dObjTreeIter, ++thisIter)
158 {
159 vtkDataObjectTree* subDObjTree = vtkDataObjectTree::SafeDownCast(dObjTreeIter->DataObject);
160 if (subDObjTree)
161 {
162 if (vtkDataObjectTree* copy = this->CreateForCopyStructure(subDObjTree))
163 {
164 thisIter->DataObject.TakeReference(copy);
165 copy->CopyStructure(subDObjTree);
166 }
167 else
168 {
169 vtkErrorMacro("CopyStructure has encountered an error and will fail!");
170 }
171 }
172
173 // shallow copy meta data.
174 if (dObjTreeIter->MetaData)
175 {
176 vtkNew<vtkInformation> info;
177 info->Copy(dObjTreeIter->MetaData, /*deep=*/0);
178 thisIter->MetaData = info;
179 }
180 }
181 }
182 else
183 {
184 // WARNING:
185 // If we copy the structure from a non-tree composite data set
186 // we create a special structure of two levels, the first level
187 // is just a single partitioned dataSet and the second level are all the data sets.
188 // This is likely to change in the future!
189 vtkNew<vtkPartitionedDataSet> tempPds;
190 auto pds = vtk::TakeSmartPointer(this->CreateForCopyStructure(tempPds));
191 this->SetChild(0, pds);
192
193 vtkNew<vtkInformation> info;

Callers

nothing calls this directly

Calls 15

SetChildMethod · 0.95
SetChildMetaDataMethod · 0.95
SetNumberOfChildrenMethod · 0.80
clearMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
TakeReferenceMethod · 0.45
CopyMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected