From 8b12043df72857ab0e7698d995288ef9e7d7c66b Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 28 Feb 2020 12:16:58 +0300 Subject: [PATCH] Issue #3160: Do not use for intersection edges which are parallel to the plane --- src/GeomAPI/GeomAPI_Edge.cpp | 1 + src/SketchPlugin/SketchPlugin_Sketch.cpp | 6 +++++- src/SketchPlugin/SketchPlugin_Sketch.h | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/GeomAPI/GeomAPI_Edge.cpp b/src/GeomAPI/GeomAPI_Edge.cpp index 03868875b..9364605b9 100644 --- a/src/GeomAPI/GeomAPI_Edge.cpp +++ b/src/GeomAPI/GeomAPI_Edge.cpp @@ -403,6 +403,7 @@ void GeomAPI_Edge::intersectWithPlane(const std::shared_ptr thePlan GeomAPI_ExtremaCurveSurface anExtrema(aCurve, aPlane); double aTolerance = BRep_Tool::Tolerance(TopoDS::Edge(aShape)); if (anExtrema.NbExtrema() > 0 && + !anExtrema.Extrema().IsParallel() && anExtrema.LowerDistance() < aTolerance) { // distance is lower than tolerance => tangent case gp_Pnt aPntC, aPntS; diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 692ac5d0e..839d3d961 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -443,7 +443,11 @@ std::shared_ptr SketchPlugin_Sketch::plane(SketchPlugin_Sketch* the std::shared_ptr aNorm = std::dynamic_pointer_cast( aData->attribute(SketchPlugin_Sketch::NORM_ID())); - return std::shared_ptr(new GeomAPI_Ax3(anOrigin->pnt(), aDirX->dir(), aNorm->dir())); + if (aNorm.get() && aNorm->isInitialized() && anOrigin.get() && anOrigin->isInitialized()) + return std::shared_ptr( + new GeomAPI_Ax3(anOrigin->pnt(), aDirX->dir(), aNorm->dir())); + + return std::shared_ptr(); } bool SketchPlugin_Sketch::customAction(const std::string& theActionId) diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index 6feda008d..e2dc9f1f6 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -160,10 +160,10 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature//, public GeomAPI_I std::shared_ptr aNorm = std::dynamic_pointer_cast( data()->attribute(NORM_ID())); - if (!anOrigin || !aNorm) - return std::shared_ptr(); + if (anOrigin.get() && aNorm.get() && anOrigin->isInitialized() && aNorm->isInitialized()) + return std::shared_ptr(new GeomAPI_Pln(anOrigin->pnt(), aNorm->dir())); - return std::shared_ptr(new GeomAPI_Pln(anOrigin->pnt(), aNorm->dir())); + return std::shared_ptr(); } /// Returns currently defined plane as an object of Ax3 -- 2.39.2