Salome HOME
Merge commit 'f709219506b7cd587e94abc5ebed18d629df92d8'
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_MacroBSpline.h
index 0137962ed1993585ccfd8bec721cf34cb55c3152..106a3450c349dd309f459530a815a3bde662ee4b 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2020  CEA/DEN, EDF R&D
+// Copyright (C) 2019-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 class GeomAPI_Circ2d;
 class GeomAPI_Pnt2d;
 
+class GeomDataAPI_Point2DArray;
+
 /**\class SketchPlugin_MacroBSpline
  * \ingroup Plugins
  * \brief Feature for creation of the new B-spline in Sketch.
  */
 class SketchPlugin_MacroBSpline : public SketchPlugin_SketchEntity,
-                                  public GeomAPI_IPresentable,
-                                  public ModelAPI_IReentrant
+                                  public GeomAPI_IPresentable
 {
 public:
   /// B-spline macro feature kind
@@ -69,6 +70,13 @@ public:
     return ID;
   }
 
+  /// flag attribute whether control polygon is need to be created
+  inline static const std::string& CONTROL_POLYGON_ID()
+  {
+    static const std::string ID("need_control_poly");
+    return ID;
+  }
+
   /// Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
   {
@@ -91,21 +99,68 @@ public:
 
   SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
 
-  /// Apply information of the message to current object. It fills reference object,
-  /// tangent type and tangent point refence in case of tangent arc
-  virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
-
   /// Use plugin manager for features creation
   SketchPlugin_MacroBSpline();
 
+protected:
+  SketchPlugin_MacroBSpline(bool isPeriodic);
+
 private:
   FeaturePtr createBSplineFeature();
 
-  void createControlPolygon(FeaturePtr theBSpline, std::list<FeaturePtr>& thePoles);
+  /// Create control polygon for the B-spline and returns the list of its poles
+  static void createControlPolygon(FeaturePtr theBSpline,
+                                   bool thePeriodic,
+                                   std::list<FeaturePtr>& thePoles);
+
+  /// Create additional coincidences if other features were selected while creating the B-spline
   void constraintsForPoles(const std::list<FeaturePtr>& thePoles);
 
+  /// Create Point feature coincident with the B-spline pole
+  static FeaturePtr createAuxiliaryPole(std::shared_ptr<GeomDataAPI_Point2DArray> theBSplinePoles,
+                                        const int thePoleIndex);
+  /// Create segment between consequtive B-spline poles
+  static void createAuxiliarySegment(std::shared_ptr<GeomDataAPI_Point2DArray> theBSplinePoles,
+                                     const int thePoleIndex1,
+                                     const int thePoleIndex2);
+  /// Set name of auxiliary feature representing the control polygon
+  static void assignDefaultNameForAux(FeaturePtr theAuxFeature,
+                                      std::shared_ptr<GeomDataAPI_Point2DArray> theBSplinePoles,
+                                      const int thePoleIndex1,
+                                      const int thePoleIndex2 = -1);
+  friend class SketchPlugin_BSplineBase;
+  friend class SketchPlugin_CurveFitting;
+
+private:
+  std::list<double> myKnots;
+  std::list<int> myMultiplicities;
   int myDegree;
   bool myIsPeriodic;
 };
 
+
+/**\class SketchPlugin_MacroBSplinePeriodic
+* \ingroup Plugins
+* \brief Feature for creation of the new periodic B-spline in Sketch.
+*/
+class SketchPlugin_MacroBSplinePeriodic : public SketchPlugin_MacroBSpline
+{
+public:
+  /// B-spline macro feature kind
+  inline static const std::string& ID()
+  {
+    static const std::string ID("SketchMacroBSplinePeriodic");
+    return ID;
+  }
+
+  /// Returns the kind of a feature
+  SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
+  {
+    return SketchPlugin_MacroBSplinePeriodic::ID();
+  }
+
+  /// Use plugin manager for features creation
+  SketchPlugin_MacroBSplinePeriodic() : SketchPlugin_MacroBSpline(true) {}
+};
+
 #endif