------------------------------------------------------------------------------
| 252 | |
| 253 | //------------------------------------------------------------------------------ |
| 254 | void vtkBooleanOperationPolyDataFilter ::CopyCells(vtkPolyData* in, vtkPolyData* out, int idx, |
| 255 | vtkDataSetAttributes::FieldList& pointFieldList, vtkDataSetAttributes::FieldList& cellFieldList, |
| 256 | vtkIdList* cellIds, bool reverseCells) |
| 257 | { |
| 258 | // Largely copied from vtkPolyData::CopyCells, but modified to |
| 259 | // use the special form of CopyData that uses a field list to |
| 260 | // determine which data values to copy over. |
| 261 | |
| 262 | vtkPointData* outPD = out->GetPointData(); |
| 263 | vtkCellData* outCD = out->GetCellData(); |
| 264 | |
| 265 | vtkFloatArray* outNormals = nullptr; |
| 266 | if (reverseCells) |
| 267 | { |
| 268 | outNormals = vtkArrayDownCast<vtkFloatArray>(outPD->GetArray("Normals")); |
| 269 | } |
| 270 | |
| 271 | vtkIdType numPts = in->GetNumberOfPoints(); |
| 272 | |
| 273 | if (out->GetPoints() == nullptr) |
| 274 | { |
| 275 | vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New(); |
| 276 | out->SetPoints(points); |
| 277 | } |
| 278 | |
| 279 | vtkPoints* newPoints = out->GetPoints(); |
| 280 | |
| 281 | vtkSmartPointer<vtkIdList> pointMap = vtkSmartPointer<vtkIdList>::New(); |
| 282 | pointMap->SetNumberOfIds(numPts); |
| 283 | for (vtkIdType i = 0; i < numPts; i++) |
| 284 | { |
| 285 | pointMap->SetId(i, -1); |
| 286 | } |
| 287 | |
| 288 | // Filter the cells |
| 289 | vtkSmartPointer<vtkGenericCell> cell = vtkSmartPointer<vtkGenericCell>::New(); |
| 290 | vtkSmartPointer<vtkIdList> newCellPts = vtkSmartPointer<vtkIdList>::New(); |
| 291 | for (vtkIdType cellId = 0; cellId < cellIds->GetNumberOfIds(); cellId++) |
| 292 | { |
| 293 | if (this->CheckAbort()) |
| 294 | { |
| 295 | break; |
| 296 | } |
| 297 | in->GetCell(cellIds->GetId(cellId), cell); |
| 298 | vtkIdList* cellPts = cell->GetPointIds(); |
| 299 | vtkIdType numCellPts = cell->GetNumberOfPoints(); |
| 300 | |
| 301 | for (vtkIdType i = 0; i < numCellPts; i++) |
| 302 | { |
| 303 | vtkIdType ptId = cellPts->GetId(i); |
| 304 | vtkIdType newId = pointMap->GetId(ptId); |
| 305 | if (newId < 0) |
| 306 | { |
| 307 | double x[3]; |
| 308 | in->GetPoint(ptId, x); |
| 309 | newId = newPoints->InsertNextPoint(x); |
| 310 | pointMap->SetId(ptId, newId); |
| 311 | outPD->CopyData(pointFieldList, in->GetPointData(), idx, ptId, newId); |
no test coverage detected