------------------------------------------------------------------------------
| 48 | |
| 49 | //------------------------------------------------------------------------------ |
| 50 | int vtkHyperTreeGridToUnstructuredGrid::ProcessTrees( |
| 51 | vtkHyperTreeGrid* input, vtkDataObject* outputDO) |
| 52 | { |
| 53 | // Downcast output data object to hyper tree grid |
| 54 | vtkUnstructuredGrid* output = vtkUnstructuredGrid::SafeDownCast(outputDO); |
| 55 | if (!output) |
| 56 | { |
| 57 | vtkErrorMacro("Incorrect type of output: " << outputDO->GetClassName()); |
| 58 | return 0; |
| 59 | } |
| 60 | |
| 61 | // Set instance variables needed for this conversion |
| 62 | this->Points = vtkPoints::New(); |
| 63 | this->Cells = vtkCellArray::New(); |
| 64 | this->Dimension = input->GetDimension(); |
| 65 | this->Orientation = input->GetOrientation(); |
| 66 | this->Axes = input->GetAxes(); |
| 67 | |
| 68 | // Initialize output cell data |
| 69 | this->InData = input->GetCellData(); |
| 70 | this->OutData = output->GetCellData(); |
| 71 | this->OutData->CopyAllocate(this->InData); |
| 72 | |
| 73 | if (this->AddOriginalIds) |
| 74 | { |
| 75 | this->OriginalIds = vtkIdTypeArray::New(); |
| 76 | this->OriginalIds->SetName("OriginalIds"); |
| 77 | this->OriginalIds->SetNumberOfComponents(1); |
| 78 | this->OriginalIds->SetNumberOfTuples(input->GetNumberOfLeaves()); |
| 79 | } |
| 80 | |
| 81 | // Iterate over all hyper trees |
| 82 | vtkIdType index; |
| 83 | vtkHyperTreeGrid::vtkHyperTreeGridIterator it; |
| 84 | input->InitializeTreeIterator(it); |
| 85 | vtkNew<vtkHyperTreeGridNonOrientedGeometryCursor> cursor; |
| 86 | while (it.GetNextTree(index)) |
| 87 | { |
| 88 | if (this->CheckAbort()) |
| 89 | { |
| 90 | break; |
| 91 | } |
| 92 | // Initialize new geometric cursor at root of current tree |
| 93 | input->InitializeNonOrientedGeometryCursor(cursor, index); |
| 94 | |
| 95 | // Convert hyper tree into unstructured mesh recursively |
| 96 | this->RecursivelyProcessTree(cursor); |
| 97 | } // it |
| 98 | |
| 99 | // Set output geometry and topology |
| 100 | output->SetPoints(this->Points); |
| 101 | switch (this->Dimension) |
| 102 | { |
| 103 | case 1: |
| 104 | // 1D cells are lines |
| 105 | output->SetCells(VTK_LINE, this->Cells); |
| 106 | break; |
| 107 | case 2: |
nothing calls this directly
no test coverage detected