------------------------------------------------------------------------------
| 140 | |
| 141 | //------------------------------------------------------------------------------ |
| 142 | void 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 | } |
no test coverage detected