From cc832c4563b6a1eb6303f8ff17a4e1507c9bdf0a Mon Sep 17 00:00:00 2001 From: azv Date: Thu, 6 Jun 2019 16:00:57 +0300 Subject: [PATCH] Improve intersection of edge with plane in the tangent case. --- src/GeomAPI/GeomAPI_Edge.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/GeomAPI/GeomAPI_Edge.cpp b/src/GeomAPI/GeomAPI_Edge.cpp index ede977f30..379bdab86 100644 --- a/src/GeomAPI/GeomAPI_Edge.cpp +++ b/src/GeomAPI/GeomAPI_Edge.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -306,8 +307,9 @@ void GeomAPI_Edge::intersectWithPlane(const std::shared_ptr thePlan double A, B, C, D; thePlane->coefficients(A, B, C, D); gp_Pln aPln(A, B, C, D); - Handle(Geom_Plane) aPlane = new Geom_Plane(aPln); + + // intersect the plane with the curve GeomAPI_IntCS aIntersect; aIntersect.Perform(aCurve, aPlane); if (aIntersect.IsDone() && (aIntersect.NbPoints() > 0)) { @@ -326,6 +328,18 @@ void GeomAPI_Edge::intersectWithPlane(const std::shared_ptr thePlan theResult.push_back(aPntPtr); } } + else { + // find minimal distance between the plane and the curve + GeomAPI_ExtremaCurveSurface anExtrema(aCurve, aPlane); + double aTolerance = BRep_Tool::Tolerance(TopoDS::Edge(aShape)); + if (anExtrema.LowerDistance() < aTolerance) { + // distance is lower than tolerance => tangent case + gp_Pnt aPntC, aPntS; + anExtrema.NearestPoints(aPntC, aPntS); + std::shared_ptr aPntPtr(new GeomAPI_Pnt(aPntS.X(), aPntS.Y(), aPntS.Z())); + theResult.push_back(aPntPtr); + } + } } } -- 2.39.2