------------------------------------------------------------------------------
| 523 | |
| 524 | //------------------------------------------------------------------------------ |
| 525 | void vtkSelectPolyData::FillMarksInRegion(vtkPolyData* mesh, vtkIdList* edgePointIds, |
| 526 | vtkIntArray* pointMarks, vtkIntArray* cellMarks, vtkIdType cellIdInSelectedRegion) |
| 527 | { |
| 528 | // We do the fill as a moving front. This is an alternative to recursion. The |
| 529 | // fill negates one region of the mesh on one side of the loop. |
| 530 | // In contrast to ComputeTopologicalDistance, current and next front |
| 531 | // in this method contain cell IDs. |
| 532 | vtkSmartPointer<vtkIdList> currentFront = vtkSmartPointer<vtkIdList>::New(); |
| 533 | vtkSmartPointer<vtkIdList> nextFront = vtkSmartPointer<vtkIdList>::New(); |
| 534 | currentFront->InsertNextId(cellIdInSelectedRegion); |
| 535 | |
| 536 | // Initialize the front with the received cell ID |
| 537 | constexpr int fillValue = -1; |
| 538 | constexpr int boundaryValue = 0; |
| 539 | cellMarks->SetValue(cellIdInSelectedRegion, fillValue); |
| 540 | |
| 541 | vtkNew<vtkIdList> neighbors; |
| 542 | neighbors->Allocate(10000); |
| 543 | vtkIdType numCellsInFront; |
| 544 | while ((numCellsInFront = currentFront->GetNumberOfIds()) > 0) |
| 545 | { |
| 546 | // Iterate through all the triangles and visit all the neighbor triangles |
| 547 | for (vtkIdType i = 0; i < numCellsInFront; i++) |
| 548 | { |
| 549 | vtkIdType id = currentFront->GetId(i); |
| 550 | |
| 551 | const vtkIdType* pts; |
| 552 | vtkIdType npts; |
| 553 | mesh->GetCellPoints(id, npts, pts); |
| 554 | for (vtkIdType j = 0; j < 3; j++) |
| 555 | { |
| 556 | vtkIdType cellPointId1 = pts[j]; |
| 557 | vtkIdType cellPointId2 = pts[(j + 1) % 3]; |
| 558 | int cellPointValue1 = pointMarks->GetValue(cellPointId1); |
| 559 | int cellPointValue2 = pointMarks->GetValue(cellPointId2); |
| 560 | |
| 561 | if (cellPointValue1 != boundaryValue) |
| 562 | { |
| 563 | pointMarks->SetValue(cellPointId1, fillValue); |
| 564 | } |
| 565 | |
| 566 | if (cellPointValue1 == boundaryValue && cellPointValue2 == boundaryValue) |
| 567 | { |
| 568 | // This may be a boundary edge or just an edge that connects two boundary points. |
| 569 | // Do a full search in the boundary edge list to find out. |
| 570 | if (vtkSelectPolyData::IsBoundaryEdge(cellPointId1, cellPointId2, edgePointIds)) |
| 571 | { |
| 572 | // cannot cross boundary |
| 573 | continue; |
| 574 | } |
| 575 | } |
| 576 | |
| 577 | // add neighbors of this edge to the advancing front |
| 578 | mesh->GetCellEdgeNeighbors(id, cellPointId1, cellPointId2, neighbors); |
| 579 | vtkIdType numNei = neighbors->GetNumberOfIds(); |
| 580 | for (vtkIdType k = 0; k < numNei; k++) |
| 581 | { |
| 582 | vtkIdType neiId = neighbors->GetId(k); |
no test coverage detected