------------------------------------------------------------------------------
| 117 | |
| 118 | //------------------------------------------------------------------------------ |
| 119 | int vtkRandomHyperTreeGridSource::RequestData( |
| 120 | vtkInformation*, vtkInformationVector**, vtkInformationVector* outInfos) |
| 121 | { |
| 122 | using SDDP = vtkStreamingDemandDrivenPipeline; |
| 123 | |
| 124 | vtkInformation* outInfo = outInfos->GetInformationObject(0); |
| 125 | const int piece = outInfo->Get(SDDP::UPDATE_PIECE_NUMBER()); |
| 126 | int* updateExtent = outInfo->Get(SDDP::UPDATE_EXTENT()); |
| 127 | |
| 128 | // Refresh masking cost per level if maxDepth did change |
| 129 | if (this->MaxDepth + 1 != static_cast<vtkIdType>(this->MaskingCostPerLevel.size())) |
| 130 | { |
| 131 | this->InitializeMaskingNodeCostPerLevel(); |
| 132 | } |
| 133 | |
| 134 | // Create dataset: |
| 135 | auto fillArray = [](vtkDoubleArray* array, vtkIdType numPoints, double minBound, double maxBound) |
| 136 | { |
| 137 | array->SetNumberOfComponents(1); |
| 138 | array->SetNumberOfTuples(numPoints); |
| 139 | // We differentiate the pathological case at one point from the other cases |
| 140 | if (numPoints == 1) |
| 141 | { |
| 142 | array->SetTypedComponent(0, 0, 0.); |
| 143 | } |
| 144 | else |
| 145 | { |
| 146 | // Compute step for more than one point |
| 147 | double step = (maxBound - minBound) / static_cast<double>(numPoints - 1); |
| 148 | for (int i = 0; i < numPoints; ++i) |
| 149 | { |
| 150 | array->SetTypedComponent(i, 0, minBound + step * i); |
| 151 | } |
| 152 | } |
| 153 | }; |
| 154 | |
| 155 | vtkHyperTreeGrid* htg = vtkHyperTreeGrid::GetData(outInfo); |
| 156 | htg->Initialize(); |
| 157 | htg->SetDimensions(this->Dimensions); |
| 158 | if (htg->GetDimension() == 0) |
| 159 | { |
| 160 | // No HyperTrees, we don't need to create anything |
| 161 | return 1; |
| 162 | } |
| 163 | htg->SetBranchFactor(::BRANCHING_FACTOR); |
| 164 | { |
| 165 | vtkNew<vtkDoubleArray> coords; |
| 166 | fillArray(coords, this->Dimensions[0], this->OutputBounds[0], this->OutputBounds[1]); |
| 167 | htg->SetXCoordinates(coords); |
| 168 | } |
| 169 | |
| 170 | { |
| 171 | vtkNew<vtkDoubleArray> coords; |
| 172 | fillArray(coords, this->Dimensions[1], this->OutputBounds[2], this->OutputBounds[3]); |
| 173 | htg->SetYCoordinates(coords); |
| 174 | } |
| 175 | |
| 176 | { |
nothing calls this directly
no test coverage detected