]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchPlugin/SketchPlugin_MacroBSpline.h
Salome HOME
78ef86823877ee1ded1e063035f92f05f35ca459
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_MacroBSpline.h
1 // Copyright (C) 2019-2020  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef SketchPlugin_MacroBSpline_H_
21 #define SketchPlugin_MacroBSpline_H_
22
23 #include <ModelAPI_IReentrant.h>
24
25 #include "SketchPlugin.h"
26
27 #include "SketchPlugin_SketchEntity.h"
28
29 #include <GeomAPI_IPresentable.h>
30
31 class GeomAPI_Circ2d;
32 class GeomAPI_Pnt2d;
33
34 /**\class SketchPlugin_MacroBSpline
35  * \ingroup Plugins
36  * \brief Feature for creation of the new B-spline in Sketch.
37  */
38 class SketchPlugin_MacroBSpline : public SketchPlugin_SketchEntity,
39                                   public GeomAPI_IPresentable,
40                                   public ModelAPI_IReentrant
41 {
42 public:
43   /// B-spline macro feature kind
44   inline static const std::string& ID()
45   {
46     static const std::string ID("SketchMacroBSpline");
47     return ID;
48   }
49
50
51   /// list of B-spline poles
52   inline static const std::string& POLES_ID()
53   {
54     static const std::string ID("poles");
55     return ID;
56   }
57
58   /// list of references of B-spline poles
59   inline static const std::string& REF_POLES_ID()
60   {
61     static const std::string ID("poles_ref");
62     return ID;
63   }
64
65   /// list of B-spline weights
66   inline static const std::string& WEIGHTS_ID()
67   {
68     static const std::string ID("weights");
69     return ID;
70   }
71
72   /// flag attribute whether control polygon is need to be created
73   inline static const std::string& CONTROL_POLYGON_ID()
74   {
75     static const std::string ID("need_control_poly");
76     return ID;
77   }
78
79   /// Returns the kind of a feature
80   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
81   {
82     static std::string MY_KIND = SketchPlugin_MacroBSpline::ID();
83     return MY_KIND;
84   }
85
86   /// \brief Request for initialization of data model of the feature: adding all attributes.
87   SKETCHPLUGIN_EXPORT virtual void initAttributes();
88
89   /// Returns the AIS preview
90   virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
91
92   /// Creates a new part document if needed
93   SKETCHPLUGIN_EXPORT virtual void execute();
94
95   /// Reimplemented from ModelAPI_Feature::isMacro().
96   /// \returns true
97   SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;};
98
99   SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
100
101   /// Apply information of the message to current object. It fills reference object,
102   /// tangent type and tangent point refence in case of tangent arc
103   virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
104
105   /// Use plugin manager for features creation
106   SketchPlugin_MacroBSpline();
107
108 protected:
109   SketchPlugin_MacroBSpline(bool isPeriodic);
110
111 private:
112   FeaturePtr createBSplineFeature();
113
114   void createControlPolygon(FeaturePtr theBSpline, std::list<FeaturePtr>& thePoles);
115   void constraintsForPoles(const std::list<FeaturePtr>& thePoles);
116
117   std::list<double> myKnots;
118   std::list<int> myMultiplicities;
119   int myDegree;
120   bool myIsPeriodic;
121 };
122
123
124 /**\class SketchPlugin_MacroBSpline
125 * \ingroup Plugins
126 * \brief Feature for creation of the new B-spline in Sketch.
127 */
128 class SketchPlugin_MacroBSplinePeriodic : public SketchPlugin_MacroBSpline
129 {
130 public:
131   /// B-spline macro feature kind
132   inline static const std::string& ID()
133   {
134     static const std::string ID("SketchMacroBSplinePeriodic");
135     return ID;
136   }
137
138   /// Returns the kind of a feature
139   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
140   {
141     return SketchPlugin_MacroBSpline::ID();
142   }
143
144   /// Use plugin manager for features creation
145   SketchPlugin_MacroBSplinePeriodic() : SketchPlugin_MacroBSpline(true) {}
146 };
147
148 #endif