| 1659 | //------------------------------------------------------------------------------ |
| 1660 | |
| 1661 | int vtkIntersectionPolyDataFilter::Impl::GetLoopOrientation( |
| 1662 | vtkPolyData* pd, vtkIdType cell, vtkIdType ptId1, vtkIdType ptId2) |
| 1663 | { |
| 1664 | // Calculate the actual orientation of this loop, by calculating the signed |
| 1665 | // area of the triangle made by the three points |
| 1666 | vtkSmartPointer<vtkIdList> cellPoints = vtkSmartPointer<vtkIdList>::New(); |
| 1667 | pd->GetCellPoints(cell, cellPoints); |
| 1668 | |
| 1669 | vtkIdType ptId3; |
| 1670 | if (cellPoints->GetId(0) == ptId2) |
| 1671 | { |
| 1672 | ptId3 = cellPoints->GetId(1); |
| 1673 | } |
| 1674 | else |
| 1675 | { |
| 1676 | ptId3 = cellPoints->GetId(0); |
| 1677 | } |
| 1678 | |
| 1679 | double pt1[3], pt2[3], pt3[3]; |
| 1680 | pd->GetPoint(ptId1, pt1); |
| 1681 | pd->GetPoint(ptId2, pt2); |
| 1682 | pd->GetPoint(ptId3, pt3); |
| 1683 | |
| 1684 | double area = 0; |
| 1685 | area = area + (pt1[0] * pt2[1]) - (pt2[0] * pt1[1]); |
| 1686 | area = area + (pt2[0] * pt3[1]) - (pt3[0] * pt2[1]); |
| 1687 | area = area + (pt3[0] * pt1[1]) - (pt1[0] * pt3[1]); |
| 1688 | |
| 1689 | int orientation = 1; |
| 1690 | |
| 1691 | if (fabs(area) < 1e-10) |
| 1692 | { |
| 1693 | // The area is very small for these three based upon the transformed pd |
| 1694 | // from the cells original three points. Get a new transform from these |
| 1695 | // interior three points to make sure the area is correct |
| 1696 | vtkDebugWithObjectMacro(this->ParentFilter, << "Very Small Area Triangle"); |
| 1697 | vtkDebugWithObjectMacro( |
| 1698 | this->ParentFilter, << "Double check area with more accurate transform"); |
| 1699 | vtkSmartPointer<vtkPoints> testPoints = vtkSmartPointer<vtkPoints>::New(); |
| 1700 | vtkSmartPointer<vtkPolyData> testPD = vtkSmartPointer<vtkPolyData>::New(); |
| 1701 | vtkSmartPointer<vtkCellArray> testCells = vtkSmartPointer<vtkCellArray>::New(); |
| 1702 | testPoints->InsertNextPoint(this->SplittingPD->GetPoint(ptId1)); |
| 1703 | testPoints->InsertNextPoint(this->SplittingPD->GetPoint(ptId2)); |
| 1704 | testPoints->InsertNextPoint(this->SplittingPD->GetPoint(ptId3)); |
| 1705 | for (int i = 0; i < 3; i++) |
| 1706 | { |
| 1707 | testCells->InsertNextCell(2); |
| 1708 | testCells->InsertCellPoint(i); |
| 1709 | testCells->InsertCellPoint((i + 1) % 3); |
| 1710 | } |
| 1711 | testPD->SetPoints(testPoints); |
| 1712 | testPD->SetLines(testCells); |
| 1713 | testPD->BuildLinks(); |
| 1714 | |
| 1715 | vtkSmartPointer<vtkTransform> newTransform = vtkSmartPointer<vtkTransform>::New(); |
| 1716 | int sign = this->GetTransform(newTransform, testPoints); |
| 1717 | if (sign != this->TransformSign) |
| 1718 | { |
no test coverage detected