| 1595 | //------------------------------------------------------------------------------ |
| 1596 | |
| 1597 | void vtkIntersectionPolyDataFilter::Impl ::SetLoopOrientation(vtkPolyData* pd, simPolygon* loop, |
| 1598 | vtkIdType* nextCell, vtkIdType nextPt, vtkIdType prevPt, vtkIdList* pointCells) |
| 1599 | { |
| 1600 | // Set the orientation of this loop! |
| 1601 | double mincell = 0; |
| 1602 | double minangle = VTK_DOUBLE_MAX; |
| 1603 | for (vtkIdType i = 0; i < pointCells->GetNumberOfIds(); i++) |
| 1604 | { |
| 1605 | vtkIdType cellId = pointCells->GetId(i); |
| 1606 | // If the next line is not equal to the current line, check the angle |
| 1607 | // it makes with the previous line |
| 1608 | if (*nextCell != cellId) |
| 1609 | { |
| 1610 | double l0pt0[3], l0pt1[3], l1pt0[3], l1pt1[3]; |
| 1611 | pd->GetPoint(prevPt, l0pt0); |
| 1612 | pd->GetPoint(nextPt, l0pt1); |
| 1613 | vtkSmartPointer<vtkIdList> specialCellPoints = vtkSmartPointer<vtkIdList>::New(); |
| 1614 | pd->GetCellPoints(cellId, specialCellPoints); |
| 1615 | if (specialCellPoints->GetId(0) == nextPt) |
| 1616 | { |
| 1617 | pd->GetPoint(specialCellPoints->GetId(1), l1pt0); |
| 1618 | pd->GetPoint(specialCellPoints->GetId(0), l1pt1); |
| 1619 | } |
| 1620 | else |
| 1621 | { |
| 1622 | pd->GetPoint(specialCellPoints->GetId(0), l1pt0); |
| 1623 | pd->GetPoint(specialCellPoints->GetId(1), l1pt1); |
| 1624 | } |
| 1625 | double edge1[3], edge2[3]; |
| 1626 | for (int j = 0; j < 2; j++) |
| 1627 | { |
| 1628 | edge1[j] = l0pt1[j] - l0pt0[j]; |
| 1629 | edge2[j] = l1pt1[j] - l1pt0[j]; |
| 1630 | } |
| 1631 | edge1[2] = 0.; |
| 1632 | edge2[2] = 0.; |
| 1633 | vtkMath::Normalize(edge1); |
| 1634 | vtkMath::Normalize(edge2); |
| 1635 | double dot = vtkMath::Dot(edge1, edge2); |
| 1636 | if (dot > 1.0) |
| 1637 | { |
| 1638 | dot = 1.0; |
| 1639 | } |
| 1640 | else if (dot < -1.0) |
| 1641 | { |
| 1642 | dot = -1.0; |
| 1643 | } |
| 1644 | double angle = vtkMath::DegreesFromRadians(acos(dot)); |
| 1645 | |
| 1646 | if (angle < minangle) |
| 1647 | { |
| 1648 | minangle = angle; |
| 1649 | mincell = cellId; |
| 1650 | } |
| 1651 | } |
| 1652 | } |
| 1653 | // Set the next line as the line that makes the minimum angle with the |
| 1654 | // previous cell and set the orientation of the loop |
no test coverage detected