SHAPER 9.16.0
SketchPlugin_MacroBSpline.h
1// Copyright (C) 2019-2026 CEA, EDF
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
31class GeomAPI_Circ2d;
32class GeomAPI_Pnt2d;
33
35
42{
43public:
45 inline static const std::string& ID()
46 {
47 static const std::string ID("SketchMacroBSpline");
48 return ID;
49 }
50
51
53 inline static const std::string& POLES_ID()
54 {
55 static const std::string ID("poles");
56 return ID;
57 }
58
60 inline static const std::string& REF_POLES_ID()
61 {
62 static const std::string ID("poles_ref");
63 return ID;
64 }
65
67 inline static const std::string& WEIGHTS_ID()
68 {
69 static const std::string ID("weights");
70 return ID;
71 }
72
74 inline static const std::string& CONTROL_POLYGON_ID()
75 {
76 static const std::string ID("need_control_poly");
77 return ID;
78 }
79
81 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
82 {
83 static std::string MY_KIND = SketchPlugin_MacroBSpline::ID();
84 return MY_KIND;
85 }
86
88 SKETCHPLUGIN_EXPORT virtual void initAttributes();
89
91 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
92
94 SKETCHPLUGIN_EXPORT virtual void execute();
95
98 SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;};
99
100 SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
101
104
105protected:
106 SketchPlugin_MacroBSpline(bool isPeriodic);
107
108private:
109 FeaturePtr createBSplineFeature();
110
112 static void createControlPolygon(FeaturePtr theBSpline,
113 bool thePeriodic,
114 std::list<FeaturePtr>& thePoles);
115
117 void constraintsForPoles(const std::list<FeaturePtr>& thePoles);
118
120 static FeaturePtr createAuxiliaryPole(std::shared_ptr<GeomDataAPI_Point2DArray> theBSplinePoles,
121 const int thePoleIndex);
123 static void createAuxiliarySegment(std::shared_ptr<GeomDataAPI_Point2DArray> theBSplinePoles,
124 const int thePoleIndex1,
125 const int thePoleIndex2);
127 static void assignDefaultNameForAux(FeaturePtr theAuxFeature,
128 std::shared_ptr<GeomDataAPI_Point2DArray> theBSplinePoles,
129 const int thePoleIndex1,
130 const int thePoleIndex2 = -1);
131 friend class SketchPlugin_BSplineBase;
132 friend class SketchPlugin_CurveFitting;
133
134private:
135 std::list<double> myKnots;
136 std::list<int> myMultiplicities;
137 int myDegree;
138 bool myIsPeriodic;
139};
140
141
147{
148public:
150 inline static const std::string& ID()
151 {
152 static const std::string ID("SketchMacroBSplinePeriodic");
153 return ID;
154 }
155
157 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
158 {
160 }
161
164};
165
166#endif
Circle in 2D.
Definition: GeomAPI_Circ2d.h:37
A class which defines an interface of object which is able to create its own presentation.
Definition: GeomAPI_IPresentable.h:29
2D point defined by two coordinates
Definition: GeomAPI_Pnt2d.h:36
Attribute that contains array of 2D point coordinates.
Definition: GeomDataAPI_Point2DArray.h:34
Base class for B-spline curves in the sketch.
Definition: SketchPlugin_BSplineBase.h:31
Feature for creation of the new B-spline curve in sketch as an interpolation or an approximation of a...
Definition: SketchPlugin_CurveFitting.h:37
Feature for creation of the new periodic B-spline in Sketch.
Definition: SketchPlugin_MacroBSpline.h:147
SketchPlugin_MacroBSplinePeriodic()
Use plugin manager for features creation.
Definition: SketchPlugin_MacroBSpline.h:163
virtual const std::string & getKind()
Returns the kind of a feature.
Definition: SketchPlugin_MacroBSpline.h:157
static const std::string & ID()
B-spline macro feature kind.
Definition: SketchPlugin_MacroBSpline.h:150
Feature for creation of the new B-spline in Sketch.
Definition: SketchPlugin_MacroBSpline.h:42
static const std::string & POLES_ID()
list of B-spline poles
Definition: SketchPlugin_MacroBSpline.h:53
SketchPlugin_MacroBSpline()
Use plugin manager for features creation.
Definition: SketchPlugin_MacroBSpline.cpp:57
virtual void execute()
Creates a new part document if needed.
Definition: SketchPlugin_MacroBSpline.cpp:84
static const std::string & ID()
B-spline macro feature kind.
Definition: SketchPlugin_MacroBSpline.h:45
static const std::string & CONTROL_POLYGON_ID()
flag attribute whether control polygon is need to be created
Definition: SketchPlugin_MacroBSpline.h:74
static const std::string & WEIGHTS_ID()
list of B-spline weights
Definition: SketchPlugin_MacroBSpline.h:67
virtual bool isPreviewNeeded() const
Returns true if preview update during the edition needed.
Definition: SketchPlugin_MacroBSpline.h:100
static const std::string & REF_POLES_ID()
list of references of B-spline poles
Definition: SketchPlugin_MacroBSpline.h:60
virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious)
Returns the AIS preview.
Definition: SketchPlugin_MacroBSpline.cpp:198
virtual bool isMacro() const
Reimplemented from ModelAPI_Feature::isMacro().
Definition: SketchPlugin_MacroBSpline.h:98
virtual void initAttributes()
Request for initialization of data model of the feature: adding all attributes.
Definition: SketchPlugin_MacroBSpline.cpp:71
virtual const std::string & getKind()
Returns the kind of a feature.
Definition: SketchPlugin_MacroBSpline.h:81
Sketch Entity for creation of the new feature in PartSet.
Definition: SketchPlugin_SketchEntity.h:45