------------------------------------------------------------------------------ This uses a very simple, serial implementation that makes repeated passes over the triangles using a swap buffer approach.
| 129 | // This uses a very simple, serial implementation that makes repeated passes |
| 130 | // over the triangles using a swap buffer approach. |
| 131 | int vtkAdaptiveSubdivisionFilter::RequestData(vtkInformation* vtkNotUsed(request), |
| 132 | vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 133 | { |
| 134 | // get the info objects |
| 135 | vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); |
| 136 | vtkInformation* outInfo = outputVector->GetInformationObject(0); |
| 137 | |
| 138 | // get the input and output and check its validity |
| 139 | vtkPolyData* input = vtkPolyData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 140 | vtkPolyData* output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 141 | |
| 142 | vtkIdType numPts = input->GetNumberOfPoints(); |
| 143 | vtkCellArray* inTris = input->GetPolys(); |
| 144 | vtkIdType numTris = inTris->GetNumberOfCells(); |
| 145 | if (numPts < 1 || numTris < 1) |
| 146 | { |
| 147 | vtkDebugMacro(<< "No data to subdivide!"); |
| 148 | return 1; |
| 149 | } |
| 150 | vtkPointData* inPointData = input->GetPointData(); |
| 151 | vtkCellData* inCellData = input->GetCellData(); |
| 152 | |
| 153 | if (inTris->IsHomogeneous() != 3) |
| 154 | { |
| 155 | vtkDebugMacro(<< "Filter operates only on triangles!"); |
| 156 | return 1; |
| 157 | } |
| 158 | |
| 159 | // Need a locator |
| 160 | if (!this->Locator) |
| 161 | { |
| 162 | this->CreateDefaultLocator(); |
| 163 | } |
| 164 | |
| 165 | // The first thing is to take the existing points and push them into the |
| 166 | // incremental point locator. We know that we are going to use the original |
| 167 | // points. Note that points are only created and are not swapped as each |
| 168 | // pass is invoked. |
| 169 | vtkPoints* inPts = input->GetPoints(); |
| 170 | vtkPoints* newPts = vtkPoints::New(); |
| 171 | vtkPointData *swapPointData, *newPointData = vtkPointData::New(); |
| 172 | newPointData->CopyAllocate(inPointData); |
| 173 | |
| 174 | // set precision for the points in the output |
| 175 | if (this->OutputPointsPrecision == vtkAlgorithm::DEFAULT_PRECISION) |
| 176 | { |
| 177 | newPts->SetDataType(inPts->GetDataType()); |
| 178 | } |
| 179 | else if (this->OutputPointsPrecision == vtkAlgorithm::SINGLE_PRECISION) |
| 180 | { |
| 181 | newPts->SetDataType(VTK_FLOAT); |
| 182 | } |
| 183 | else if (this->OutputPointsPrecision == vtkAlgorithm::DOUBLE_PRECISION) |
| 184 | { |
| 185 | newPts->SetDataType(VTK_DOUBLE); |
| 186 | } |
| 187 | this->Locator->InitPointInsertion(newPts, input->GetBounds(), input->GetNumberOfPoints()); |
| 188 | // Load in the already existing points. Also load in the point data |
nothing calls this directly
no test coverage detected