From: azv Date: Thu, 6 Jun 2019 13:00:57 +0000 (+0300) Subject: Improve intersection of edge with plane in the tangent case. X-Git-Tag: VEDF2019Lot4~114^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cc832c4563b6a1eb6303f8ff17a4e1507c9bdf0a;p=modules%2Fshaper.git Improve intersection of edge with plane in the tangent case. --- 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); + } + } } }