| 1319 | } |
| 1320 | |
| 1321 | int vtkIntersectionPolyDataFilter::Impl ::GetLoops(vtkPolyData* pd, std::vector<simPolygon>* loops) |
| 1322 | { |
| 1323 | vtkSmartPointer<vtkIdList> pointCells = vtkSmartPointer<vtkIdList>::New(); |
| 1324 | vtkSmartPointer<vtkIdList> cellPoints = vtkSmartPointer<vtkIdList>::New(); |
| 1325 | simPoint nextPt; |
| 1326 | vtkIdType nextCell; |
| 1327 | |
| 1328 | int numPoints = pd->GetNumberOfPoints(); |
| 1329 | int numCells = pd->GetNumberOfCells(); |
| 1330 | |
| 1331 | std::vector<bool> ptBool(numPoints, false); |
| 1332 | // Add one for the cell that could be added in GetSingleLoop |
| 1333 | std::vector<bool> lineBool(numCells + 1, false); |
| 1334 | |
| 1335 | // For each point in triangle and additional lines |
| 1336 | for (vtkIdType ptId = 0; ptId < numPoints; ptId++) |
| 1337 | { |
| 1338 | // if the point hasn't already been touch and put in a loop |
| 1339 | if (!ptBool[ptId]) |
| 1340 | { |
| 1341 | nextPt.id = ptId; |
| 1342 | pd->GetPoint(nextPt.id, nextPt.pt); |
| 1343 | simPolygon interloop; |
| 1344 | interloop.points.push_back(nextPt); |
| 1345 | |
| 1346 | ptBool[nextPt.id] = true; |
| 1347 | pd->GetPointCells(nextPt.id, pointCells); |
| 1348 | nextCell = pointCells->GetId(0); |
| 1349 | lineBool[nextCell] = true; |
| 1350 | |
| 1351 | // Get one loop for untouched point |
| 1352 | if (this->GetSingleLoop(pd, &interloop, nextCell, ptBool, lineBool) != 1) |
| 1353 | { |
| 1354 | return 0; |
| 1355 | } |
| 1356 | // Add new loop |
| 1357 | loops->push_back(interloop); |
| 1358 | } |
| 1359 | } |
| 1360 | // Check now for untouched lines, possible to still have |
| 1361 | for (vtkIdType lineId = 0; lineId < pd->GetNumberOfCells(); lineId++) |
| 1362 | { |
| 1363 | if (!lineBool[lineId]) |
| 1364 | { |
| 1365 | vtkDebugWithObjectMacro(this->ParentFilter, << "LINE FALSE: Find extra loop/s"); |
| 1366 | pd->GetCellPoints(lineId, cellPoints); |
| 1367 | nextPt.id = cellPoints->GetId(0); |
| 1368 | pd->GetPoint(nextPt.id, nextPt.pt); |
| 1369 | simPolygon interloop; |
| 1370 | interloop.points.push_back(nextPt); |
| 1371 | |
| 1372 | lineBool[lineId] = true; |
| 1373 | nextCell = lineId; |
| 1374 | |
| 1375 | // Get single loop if the line is still untouched |
| 1376 | if (this->GetSingleLoop(pd, &interloop, nextCell, ptBool, lineBool) != 1) |
| 1377 | { |
| 1378 | return 0; |
no test coverage detected