]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #3055: Fatal error when setting angle
authorazv <azv@opencascade.com>
Thu, 17 Oct 2019 12:04:30 +0000 (15:04 +0300)
committervsv <vsv@opencascade.com>
Wed, 6 Nov 2019 08:27:35 +0000 (11:27 +0300)
Improve calculation of flyout point position to avoid the crash.

src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp

index e769c019cbc17e1364328ab0f7305efca13f569f..137acd0cdebab5ef7d9d51b737bba25ce6fd5d6f 100644 (file)
@@ -310,9 +310,19 @@ bool SketchPlugin_ConstraintAngle::compute(const std::string& theAttributeId)
   if (aStartA->distance(aEndA) < tolerance)
     return false;
 
+  std::shared_ptr<GeomDataAPI_Point2D> aPointB1 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      aLineB->attribute(SketchPlugin_Line::START_ID()));
+  std::shared_ptr<GeomDataAPI_Point2D> aPointB2 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      aLineB->attribute(SketchPlugin_Line::END_ID()));
+
+  std::shared_ptr<GeomAPI_Pnt2d> aStartB = aPointB1->pnt();
+  std::shared_ptr<GeomAPI_Pnt2d> aEndB = aPointB2->pnt();
+  if (aStartB->distance(aEndB) < tolerance)
+    return false;
+
   myFlyoutUpdate = true;
-  double aX = (aStartA->x() + aEndA->x()) / 2.;
-  double aY = (aStartA->y() + aEndA->y()) / 2.;
+  double aX = (aStartA->x() + aEndA->x() + aStartB->x() + aEndB->x()) / 4.;
+  double aY = (aStartA->y() + aEndA->y() + aStartB->y() + aEndB->y()) / 4.;
 
   aFlyOutAttr->setValue(aX, aY);
   myFlyoutUpdate = false;