]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Task 2.12. New entities: ellipses and arcs of ellipses (issue #3003)
authorazv <azv@opencascade.com>
Tue, 1 Oct 2019 09:32:48 +0000 (12:32 +0300)
committerazv <azv@opencascade.com>
Tue, 1 Oct 2019 09:53:08 +0000 (12:53 +0300)
Constraints on-the-fly for elliptic arcs.

src/SketchPlugin/SketchPlugin_MacroEllipticArc.cpp
src/SketchPlugin/SketchPlugin_MacroEllipticArc.h

index ab87ca57f7bb40ba1ecb49961d470f8e388824fa..984a759261cd1ace2416455d69f18a2531452b50 100644 (file)
@@ -83,6 +83,7 @@ void SketchPlugin_MacroEllipticArc::initAttributes()
 void SketchPlugin_MacroEllipticArc::execute()
 {
   FeaturePtr anEllipse = createEllipticArcFeature();
+  constraintsForEllipticArc(anEllipse);
 
   // message to init reentrant operation
   static Events_ID anId = SketchPlugin_MacroArcReentrantMessage::eventId();
@@ -301,6 +302,32 @@ FeaturePtr SketchPlugin_MacroEllipticArc::createEllipticArcFeature()
   return aEllipseFeature;
 }
 
+void SketchPlugin_MacroEllipticArc::constraintsForEllipticArc(FeaturePtr theEllipticArc)
+{
+  // tangency on-the-fly is not applicable for elliptic arcs
+  static const bool isTangencyApplicable = false;
+  // Create constraints.
+  SketchPlugin_Tools::createCoincidenceOrTangency(
+      this, CENTER_REF_ID(),
+      theEllipticArc->attribute(SketchPlugin_EllipticArc::CENTER_ID()),
+      ObjectPtr(), isTangencyApplicable);
+  // make coincidence only if PASSED_POINT_REF_ID() refers a point but not an object
+  if (!refattr(MAJOR_AXIS_POINT_REF_ID())->isObject()) {
+    SketchPlugin_Tools::createCoincidenceOrTangency(
+        this, MAJOR_AXIS_POINT_REF_ID(),
+        AttributePtr(),
+        theEllipticArc->lastResult(), isTangencyApplicable);
+  }
+  SketchPlugin_Tools::createCoincidenceOrTangency(
+      this, START_POINT_REF_ID(),
+      theEllipticArc->attribute(SketchPlugin_EllipticArc::START_POINT_ID()),
+      ObjectPtr(), isTangencyApplicable);
+  SketchPlugin_Tools::createCoincidenceOrTangency(
+      this, END_POINT_REF_ID(),
+      theEllipticArc->attribute(SketchPlugin_EllipticArc::END_POINT_ID()),
+      ObjectPtr(), isTangencyApplicable);
+}
+
 AISObjectPtr SketchPlugin_MacroEllipticArc::getAISObject(AISObjectPtr thePrevious)
 {
   SketchPlugin_Sketch* aSketch = sketch();
index 5c43f6784733660df8feb06c729484c61e116025..296d431739588acf88a32d282658b6431287fa88 100644 (file)
@@ -36,7 +36,7 @@ class SketchPlugin_MacroEllipticArc: public SketchPlugin_SketchEntity,
                                      public GeomAPI_IPresentable,
                                      public ModelAPI_IReentrant
 {
- public:
+public:
   /// Elliptic arc feature kind
   inline static const std::string& ID()
   {
@@ -159,6 +159,7 @@ private:
   std::shared_ptr<GeomAPI_Shape> getArcShape();
 
   FeaturePtr createEllipticArcFeature();
+  void constraintsForEllipticArc(FeaturePtr theEllipticArc);
 
 private:
   std::shared_ptr<GeomAPI_Pnt2d> myCenter;