------------------------------------------------------------------------------
| 78 | |
| 79 | //------------------------------------------------------------------------------ |
| 80 | int vtkHyperTreeGridToDualGrid::ProcessTrees(vtkHyperTreeGrid* input, vtkDataObject* outputDO) |
| 81 | { |
| 82 | // Downcast output data object to hyper tree grid |
| 83 | vtkUnstructuredGrid* output = vtkUnstructuredGrid::SafeDownCast(outputDO); |
| 84 | if (!output) |
| 85 | { |
| 86 | vtkErrorMacro("Incorrect type of output: " << outputDO->GetClassName()); |
| 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | // Check if we can break out early |
| 91 | // TODO: this isn't right, we need to trust the pipeline tell us when |
| 92 | // we need to reexecute, or upstream grid will change and output of this filter will be stale. |
| 93 | if (this->Points) |
| 94 | { |
| 95 | return 1; |
| 96 | } |
| 97 | |
| 98 | // TODO: we shouldn't be using persistent internal Points and Connectivity, just populate the |
| 99 | // output. |
| 100 | // Create arrays needed by dual mesh |
| 101 | this->Points = vtkPoints::New(); |
| 102 | this->Connectivity = vtkIdTypeArray::New(); |
| 103 | |
| 104 | // Primal cell centers are dual points |
| 105 | // TODO: We cannot only dimension the point array as the number of vertices, |
| 106 | // especially if we want to keep a 1:1 mapping between HTG nodes and the dual mesh. |
| 107 | // If we define a specific GlobalIndex or IndexStart, it would be too small, |
| 108 | // because GetGlobalIndex returns a value greater than the number of cells. |
| 109 | this->Points->SetNumberOfPoints(input->GetGlobalNodeIndexMax() + 1); |
| 110 | |
| 111 | // TODO: find out why we get some uninitialized point coords instead |
| 112 | this->Points->GetData()->Fill(0.0); |
| 113 | |
| 114 | int numVerts = 1 << input->GetDimension(); |
| 115 | this->Connectivity->SetNumberOfComponents(numVerts); |
| 116 | |
| 117 | // Initialize grid depth |
| 118 | unsigned int gridDepth = 0; |
| 119 | |
| 120 | // Compute and assign scales of all tree roots |
| 121 | // double scale[3] = { 1., 1., 1. }; |
| 122 | |
| 123 | // Check whether coordinate arrays match grid size |
| 124 | // If coordinates array are complete, compute all tree scales |
| 125 | // SEB: int* dims = input->GetDimensions(); |
| 126 | // SEB: if ( dims[0] == input->GetXCoordinates()->GetNumberOfTuples() |
| 127 | // SEB: && dims[1] == input->GetYCoordinates()->GetNumberOfTuples() |
| 128 | // SEB: && dims[2] == input->GetZCoordinates()->GetNumberOfTuples() ) |
| 129 | if (static_cast<int>(input->GetDimensions()[0]) == |
| 130 | input->GetXCoordinates()->GetNumberOfTuples() && |
| 131 | static_cast<int>(input->GetDimensions()[1]) == input->GetYCoordinates()->GetNumberOfTuples() && |
| 132 | static_cast<int>(input->GetDimensions()[2]) == input->GetZCoordinates()->GetNumberOfTuples()) |
| 133 | { |
| 134 | gridDepth = input->GetNumberOfLevels(); |
| 135 | } |
| 136 | |
| 137 | // Compute and store reduction factors for speed |
nothing calls this directly
no test coverage detected