]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix the changing of fillet radius (issue #1074)
authorazv <azv@opencascade.com>
Tue, 17 Nov 2015 12:47:46 +0000 (15:47 +0300)
committerazv <azv@opencascade.com>
Tue, 17 Nov 2015 12:49:18 +0000 (15:49 +0300)
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_Arc.h
src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp

index 17555b3d417825ba60eb82c00979c45ae797c976..6c8d15b9610ebef27265db5bc362f00310601b1b 100644 (file)
@@ -325,3 +325,9 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID)
     myEndUpdate = false;
   }
 }
+
+void SketchPlugin_Arc::setReversed(bool isReversed)
+{
+  std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(attribute(INVERSED_ID()))->setValue(isReversed);
+  myParamBefore = 0.0;
+}
index efc90f529ca5ea7373e8d65e1dd1e345dab41ce1..121f34916ea99b4fae72c0c958f5caafb63764f8 100644 (file)
@@ -85,6 +85,10 @@ class SketchPlugin_Arc : public SketchPlugin_SketchEntity, public GeomAPI_IPrese
   /// \param theDeltaY the delta for Y coordinate is moved
   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
 
+  /// Updates the "reversed" flag
+  /// \param isReversed  whether the arc will be reversed
+  void setReversed(bool isReversed);
+
   /// Use plugin manager for features creation
   SketchPlugin_Arc();
 
index c870c1ec167367a7fbac49e247d570c3be54b5e0..75f1370ca81e9c4e4c9e0dbe494e0e3401be8a7b 100644 (file)
@@ -70,6 +70,8 @@ void SketchPlugin_ConstraintFillet::initAttributes()
 
 void SketchPlugin_ConstraintFillet::execute()
 {
+  static const double aTol = 1.e-7;
+
   // the viewer update should be blocked in order to avoid the temporaty fillet sub-features visualization
   // before they are processed by the solver
   //std::shared_ptr<Events_Message> aMsg = std::shared_ptr<Events_Message>(
@@ -230,10 +232,16 @@ void SketchPlugin_ConstraintFillet::execute()
     aTangentPntA = aTangentPntB;
     aTangentPntB = aTmp;
   }
-  std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      aNewArc->attribute(SketchPlugin_Arc::START_ID()))->setValue(aTangentPntA->x(), aTangentPntA->y());
-  std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      aNewArc->attribute(SketchPlugin_Arc::END_ID()))->setValue(aTangentPntB->x(), aTangentPntB->y());
+  std::shared_ptr<GeomDataAPI_Point2D> aStartPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      aNewArc->attribute(SketchPlugin_Arc::START_ID()));
+  std::shared_ptr<GeomDataAPI_Point2D> aEndPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      aNewArc->attribute(SketchPlugin_Arc::END_ID()));
+  if (aStartPoint->isInitialized() && aEndPoint->isInitialized() &&
+     (aStartPoint->pnt()->xy()->distance(aTangentPntA) > aTol ||
+      aEndPoint->pnt()->xy()->distance(aTangentPntB) > aTol))
+    std::dynamic_pointer_cast<SketchPlugin_Arc>(aNewArc)->setReversed(false);
+  aStartPoint->setValue(aTangentPntA->x(), aTangentPntA->y());
+  aEndPoint->setValue(aTangentPntB->x(), aTangentPntB->y());
   aNewArc->data()->blockSendAttributeUpdated(false);
   aNewArc->execute();