| 1516 | //------------------------------------------------------------------------------ |
| 1517 | |
| 1518 | int vtkIntersectionPolyDataFilter::Impl ::FollowLoopOrientation(vtkPolyData* pd, simPolygon* loop, |
| 1519 | vtkIdType* nextCell, vtkIdType nextPt, vtkIdType prevPt, vtkIdList* pointCells) |
| 1520 | { |
| 1521 | // Follow the orientation of this loop |
| 1522 | int foundcell = 0; |
| 1523 | double newcell = 0; |
| 1524 | double minangle = VTK_DOUBLE_MAX; |
| 1525 | for (vtkIdType i = 0; i < pointCells->GetNumberOfIds(); i++) |
| 1526 | { |
| 1527 | vtkIdType cellId = pointCells->GetId(i); |
| 1528 | if (*nextCell != cellId) |
| 1529 | { |
| 1530 | // Get orientation for newly selected line |
| 1531 | int neworient = this->GetLoopOrientation(pd, cellId, prevPt, nextPt); |
| 1532 | |
| 1533 | // If the orientation of the newly selected line is correct, check |
| 1534 | // the angle of this it will make with the previous line |
| 1535 | if (neworient == loop->orientation) |
| 1536 | { |
| 1537 | foundcell = 1; |
| 1538 | double l0pt0[3], l0pt1[3], l1pt0[3], l1pt1[3]; |
| 1539 | pd->GetPoint(prevPt, l0pt0); |
| 1540 | pd->GetPoint(nextPt, l0pt1); |
| 1541 | vtkSmartPointer<vtkIdList> specialCellPoints = vtkSmartPointer<vtkIdList>::New(); |
| 1542 | pd->GetCellPoints(cellId, specialCellPoints); |
| 1543 | if (specialCellPoints->GetId(0) == nextPt) |
| 1544 | { |
| 1545 | pd->GetPoint(specialCellPoints->GetId(1), l1pt0); |
| 1546 | pd->GetPoint(specialCellPoints->GetId(0), l1pt1); |
| 1547 | } |
| 1548 | else |
| 1549 | { |
| 1550 | pd->GetPoint(specialCellPoints->GetId(0), l1pt0); |
| 1551 | pd->GetPoint(specialCellPoints->GetId(1), l1pt1); |
| 1552 | } |
| 1553 | double edge1[3], edge2[3]; |
| 1554 | for (int j = 0; j < 2; j++) |
| 1555 | { |
| 1556 | edge1[j] = l0pt1[j] - l0pt0[j]; |
| 1557 | edge2[j] = l1pt1[j] - l1pt0[j]; |
| 1558 | } |
| 1559 | edge1[2] = 0.; |
| 1560 | edge2[2] = 0.; |
| 1561 | vtkMath::Normalize(edge1); |
| 1562 | vtkMath::Normalize(edge2); |
| 1563 | double dot = vtkMath::Dot(edge1, edge2); |
| 1564 | if (dot > 1.0) |
| 1565 | { |
| 1566 | dot = 1.0; |
| 1567 | } |
| 1568 | else if (dot < -1.0) |
| 1569 | { |
| 1570 | dot = -1.0; |
| 1571 | } |
| 1572 | double angle = vtkMath::DegreesFromRadians(acos(dot)); |
| 1573 | if (angle < minangle) |
| 1574 | { |
| 1575 | minangle = angle; |
no test coverage detected