]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2387: Sketcher conservation of constraints in fillet feature
authorazv <azv@opencascade.com>
Fri, 12 Jan 2018 13:48:25 +0000 (16:48 +0300)
committerazv <azv@opencascade.com>
Fri, 12 Jan 2018 13:48:25 +0000 (16:48 +0300)
1. Make the apex point auxiliary
2. Keep positions of constraints.

src/SketchPlugin/SketchPlugin_Fillet.cpp
src/SketchPlugin/SketchPlugin_Tools.cpp
src/SketchPlugin/SketchPlugin_Tools.h

index b38352be8d2a28726c086e7cd5693f337676b99b..106b3a7cf45b5441efbd6a6291c5347fe9676f77 100644 (file)
@@ -332,6 +332,7 @@ FeaturePtr SketchPlugin_Fillet::createFilletApex(const GeomPnt2dPtr& theCoordina
   AttributePoint2DPtr aCoord = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
       anApex->attribute(SketchPlugin_Point::COORD_ID()));
   aCoord->setValue(theCoordinates);
+  anApex->boolean(SketchPlugin_Point::AUXILIARY_ID())->setValue(true);
 
   // additional coincidence constraints
   static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
@@ -416,7 +417,7 @@ void SketchPlugin_Fillet::removeReferencesButKeepDistances(
           AttributePoint2DPtr aFlyoutAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
               aLength->attribute(SketchPlugin_ConstraintLength::FLYOUT_VALUE_PNT()));
           if (aFlyoutAttr && aFlyoutAttr->isInitialized())
-            aNewLength.myFlyoutPoint = aFlyoutAttr->pnt();
+            aNewLength.myFlyoutPoint = SketchPlugin_Tools::flyoutPointCoordinates(aLength);
           AttributeIntegerPtr aLocationAttr =
               aLength->integer(SketchPlugin_ConstraintLength::LOCATION_TYPE_ID());
           if (aLocationAttr && aLocationAttr->isInitialized())
index d0c13c069755c25c0da3ddd7a209373cad34b87d..758de8b293b4edafe817b8f727f59a8b615509dd 100644 (file)
@@ -21,7 +21,9 @@
 #include "SketchPlugin_Tools.h"
 
 #include "SketchPlugin_ConstraintCoincidence.h"
+#include "SketchPlugin_ConstraintLength.h"
 #include "SketchPlugin_ConstraintTangent.h"
+#include "SketchPlugin_Line.h"
 #include "SketchPlugin_Point.h"
 #include "SketchPlugin_SketchEntity.h"
 
 
 #include <ModelAPI_AttributeDouble.h>
 
+#include <GeomAPI_Dir2d.h>
+#include <GeomAPI_Pnt2d.h>
+#include <GeomAPI_XY.h>
+
 #include <GeomDataAPI_Point.h>
 #include <GeomDataAPI_Point2D.h>
 
@@ -390,4 +396,35 @@ FeaturePtr createConstraintObjectObject(SketchPlugin_Sketch* theSketch,
   return aConstraint;
 }
 
+GeomPnt2dPtr flyoutPointCoordinates(const ConstraintPtr& theConstraint)
+{
+  // currently process Length constraints only
+  if (theConstraint->getKind() != SketchPlugin_ConstraintLength::ID())
+    return GeomPnt2dPtr();
+
+  AttributeRefAttrPtr aLineAttr = theConstraint->refattr(SketchPlugin_Constraint::ENTITY_A());
+  if (!aLineAttr || !aLineAttr->isObject())
+    return GeomPnt2dPtr();
+  FeaturePtr aLine = ModelAPI_Feature::feature(aLineAttr->object());
+  if (!aLine || aLine->getKind() != SketchPlugin_Line::ID())
+    return GeomPnt2dPtr();
+
+  std::shared_ptr<GeomAPI_XY> aStartPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      aLine->attribute(SketchPlugin_Line::START_ID()))->pnt()->xy();
+  std::shared_ptr<GeomAPI_XY> aEndPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      aLine->attribute(SketchPlugin_Line::END_ID()))->pnt()->xy();
+
+  std::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr =
+      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      theConstraint->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
+  std::shared_ptr<GeomAPI_Pnt2d> aFltPnt = aFlyoutAttr->pnt();
+
+  std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
+
+  double X = aStartPnt->x() + aFltPnt->x() * aLineDir->x() - aFltPnt->y() * aLineDir->y();
+  double Y = aStartPnt->y() + aFltPnt->x() * aLineDir->y() + aFltPnt->y() * aLineDir->x();
+
+  return GeomPnt2dPtr(new GeomAPI_Pnt2d(X, Y));
+}
+
 } // namespace SketchPlugin_Tools
index 42c2f439f217627546124d1afdd3f7dd9cdda167..d889b3d616e299149634d1b177b3507f7eecc979 100644 (file)
@@ -28,6 +28,7 @@
 #include <ModelAPI_AttributeRefAttr.h>
 #include <GeomDataAPI_Point2D.h>
 
+class SketchPlugin_Constraint;
 class SketchPlugin_Feature;
 class SketchPlugin_Sketch;
 
@@ -112,6 +113,10 @@ void convertRefAttrToPointOrTangentCurve(const AttributeRefAttrPtr&      theRefA
                                          const AttributePtr&             theDefaultAttr,
                                          std::shared_ptr<GeomAPI_Shape>& theTangentCurve,
                                          std::shared_ptr<GeomAPI_Pnt2d>& thePassingPoint);
+
+
+/// Calculate global coordinates for flyout point of Length constraint
+GeomPnt2dPtr flyoutPointCoordinates(const std::shared_ptr<SketchPlugin_Constraint>& theConstraint);
 }; // namespace SketchPlugin_Tools
 
 #endif // SKETCHPLUGIN_TOOLS_H_
\ No newline at end of file