1 // Copyright (C) 2019-2020 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef SketchPlugin_MacroBSpline_H_
21 #define SketchPlugin_MacroBSpline_H_
23 #include <ModelAPI_IReentrant.h>
25 #include "SketchPlugin.h"
27 #include "SketchPlugin_SketchEntity.h"
29 #include <GeomAPI_IPresentable.h>
34 class GeomDataAPI_Point2DArray;
36 /**\class SketchPlugin_MacroBSpline
38 * \brief Feature for creation of the new B-spline in Sketch.
40 class SketchPlugin_MacroBSpline : public SketchPlugin_SketchEntity,
41 public GeomAPI_IPresentable,
42 public ModelAPI_IReentrant
45 /// B-spline macro feature kind
46 inline static const std::string& ID()
48 static const std::string ID("SketchMacroBSpline");
53 /// list of B-spline poles
54 inline static const std::string& POLES_ID()
56 static const std::string ID("poles");
60 /// list of references of B-spline poles
61 inline static const std::string& REF_POLES_ID()
63 static const std::string ID("poles_ref");
67 /// list of B-spline weights
68 inline static const std::string& WEIGHTS_ID()
70 static const std::string ID("weights");
74 /// flag attribute whether control polygon is need to be created
75 inline static const std::string& CONTROL_POLYGON_ID()
77 static const std::string ID("need_control_poly");
81 /// Returns the kind of a feature
82 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
84 static std::string MY_KIND = SketchPlugin_MacroBSpline::ID();
88 /// \brief Request for initialization of data model of the feature: adding all attributes.
89 SKETCHPLUGIN_EXPORT virtual void initAttributes();
91 /// Returns the AIS preview
92 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
94 /// Creates a new part document if needed
95 SKETCHPLUGIN_EXPORT virtual void execute();
97 /// Reimplemented from ModelAPI_Feature::isMacro().
99 SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;};
101 SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
103 /// Apply information of the message to current object. It fills reference object,
104 /// tangent type and tangent point refence in case of tangent arc
105 virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
107 /// Use plugin manager for features creation
108 SketchPlugin_MacroBSpline();
111 SketchPlugin_MacroBSpline(bool isPeriodic);
114 FeaturePtr createBSplineFeature();
116 void createControlPolygon(FeaturePtr theBSpline, std::list<FeaturePtr>& thePoles);
117 void constraintsForPoles(const std::list<FeaturePtr>& thePoles);
119 /// Create Point feature coincident with the B-spline pole
120 static FeaturePtr createAuxiliaryPole(std::shared_ptr<GeomDataAPI_Point2DArray> theBSplinePoles,
121 const int thePoleIndex);
122 /// Create segment between consequtive B-spline poles
123 static void createAuxiliarySegment(std::shared_ptr<GeomDataAPI_Point2DArray> theBSplinePoles,
124 const int thePoleIndex1,
125 const int thePoleIndex2);
126 friend class SketchPlugin_BSplineBase;
129 std::list<double> myKnots;
130 std::list<int> myMultiplicities;
136 /**\class SketchPlugin_MacroBSpline
138 * \brief Feature for creation of the new B-spline in Sketch.
140 class SketchPlugin_MacroBSplinePeriodic : public SketchPlugin_MacroBSpline
143 /// B-spline macro feature kind
144 inline static const std::string& ID()
146 static const std::string ID("SketchMacroBSplinePeriodic");
150 /// Returns the kind of a feature
151 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
153 return SketchPlugin_MacroBSpline::ID();
156 /// Use plugin manager for features creation
157 SketchPlugin_MacroBSplinePeriodic() : SketchPlugin_MacroBSpline(true) {}