Salome HOME
Issue #3160: Do not use for intersection edges which are parallel to the plane
authorvsv <vsv@opencascade.com>
Fri, 28 Feb 2020 09:16:58 +0000 (12:16 +0300)
committervsv <vsv@opencascade.com>
Fri, 28 Feb 2020 09:17:10 +0000 (12:17 +0300)
src/GeomAPI/GeomAPI_Edge.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h

index 03868875ba53de38688ae1abddfed3e399a942e7..9364605b9b1b95c6cc6862e8145285e6024ff76b 100644 (file)
@@ -403,6 +403,7 @@ void GeomAPI_Edge::intersectWithPlane(const std::shared_ptr<GeomAPI_Pln> 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;
index 692ac5d0ed2be3377aad617f6744f1ca75773a5d..839d3d96193df5376033321f5c030850cac60442 100644 (file)
@@ -443,7 +443,11 @@ std::shared_ptr<GeomAPI_Ax3> SketchPlugin_Sketch::plane(SketchPlugin_Sketch* the
   std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
       aData->attribute(SketchPlugin_Sketch::NORM_ID()));
 
-  return std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(anOrigin->pnt(), aDirX->dir(), aNorm->dir()));
+  if (aNorm.get() && aNorm->isInitialized() && anOrigin.get() && anOrigin->isInitialized())
+    return std::shared_ptr<GeomAPI_Ax3>(
+      new GeomAPI_Ax3(anOrigin->pnt(), aDirX->dir(), aNorm->dir()));
+
+  return std::shared_ptr<GeomAPI_Ax3>();
 }
 
 bool SketchPlugin_Sketch::customAction(const std::string& theActionId)
index 6feda008dd89d3a607d48306566c0f362184592f..e2dc9f1f6c45aab7c49673ecd4211069f914b105 100644 (file)
@@ -160,10 +160,10 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature//, public GeomAPI_I
     std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
         data()->attribute(NORM_ID()));
 
-    if (!anOrigin || !aNorm)
-      return std::shared_ptr<GeomAPI_Pln>();
+    if (anOrigin.get() && aNorm.get() && anOrigin->isInitialized() && aNorm->isInitialized())
+      return std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(anOrigin->pnt(), aNorm->dir()));
 
-    return std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(anOrigin->pnt(), aNorm->dir()));
+    return std::shared_ptr<GeomAPI_Pln>();
   }
 
   /// Returns currently defined plane as an object of Ax3