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

Method ProcessTrees

Filters/HyperTree/vtkHyperTreeGridCellCenters.cxx:142–204  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

140
141//------------------------------------------------------------------------------
142void vtkHyperTreeGridCellCenters::ProcessTrees()
143{
144 // Create storage for corners of leaf cells
145 this->Points = vtkPoints::New();
146
147 // Retrieve material mask
148 this->InMask = this->Input->HasMask() ? this->Input->GetMask() : nullptr;
149
150 // Iterate over all hyper trees
151 vtkIdType index;
152 vtkHyperTreeGrid::vtkHyperTreeGridIterator it;
153 this->Input->InitializeTreeIterator(it);
154 vtkNew<vtkHyperTreeGridNonOrientedGeometryCursor> cursor;
155 while (it.GetNextTree(index))
156 {
157 if (this->CheckAbort())
158 {
159 break;
160 }
161 // Initialize new geometric cursor at root of current tree
162 this->Input->InitializeNonOrientedGeometryCursor(cursor, index);
163 // Generate leaf cell centers recursively
164 this->RecursivelyProcessTree(cursor);
165 } // it
166
167 // Set output geometry and topology if required
168 this->Output->SetPoints(this->Points);
169 if (this->VertexCells)
170 {
171 vtkIdType np = this->Points->GetNumberOfPoints();
172 vtkCellArray* vertices = vtkCellArray::New();
173 vertices->AllocateEstimate(np, 1);
174 for (vtkIdType i = 0; i < np; ++i)
175 {
176 vertices->InsertNextCell(1, &i);
177 } // i
178 this->Output->SetVerts(vertices);
179 vertices->Delete();
180 } // this->VertexCells
181
182 if (this->VertexCells)
183 {
184 vtkIdType numPoints = this->Points->GetNumberOfPoints();
185 vtkNew<vtkIdTypeArray> iArray;
186 iArray->SetNumberOfComponents(1);
187 iArray->SetNumberOfTuples(numPoints * 2);
188 for (vtkIdType i = 0; i < numPoints; i++)
189 {
190 iArray->SetValue(2 * i, 1);
191 iArray->SetValue(2 * i + 1, i);
192 }
193
194 vtkNew<vtkCellArray> verts;
195 verts->AllocateEstimate(numPoints, 1);
196 verts->ImportLegacyFormat(iArray);
197 this->Output->SetVerts(verts);
198 this->Output->GetCellData()->ShallowCopy(this->OutData);
199 }

Callers 1

RequestDataMethod · 0.95

Calls 15

HasMaskMethod · 0.80
GetNextTreeMethod · 0.80
CheckAbortMethod · 0.80
AllocateEstimateMethod · 0.80
SetVertsMethod · 0.80
ImportLegacyFormatMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
GetMaskMethod · 0.45

Tested by

no test coverage detected