SHAPER  9.12.0
SketchAPI_BSpline.h
1 // Copyright (C) 2019-2023 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 SketchAPI_BSpline_H_
21 #define SketchAPI_BSpline_H_
22 
23 #include "SketchAPI.h"
24 #include "SketchAPI_SketchEntity.h"
25 
26 #include <GeomDataAPI_Point2DArray.h>
27 
28 #include <ModelAPI_AttributeDoubleArray.h>
29 
30 #include <SketchPlugin_BSpline.h>
31 #include <SketchPlugin_BSplinePeriodic.h>
32 
33 #include <ModelHighAPI_Double.h>
34 #include <ModelHighAPI_Integer.h>
35 
37 
42 {
43 public:
45  SKETCHAPI_EXPORT
46  explicit SketchAPI_BSpline(const std::shared_ptr<ModelAPI_Feature>& theFeature);
47 
49  SKETCHAPI_EXPORT
50  virtual ~SketchAPI_BSpline();
51 
52  INTERFACE_8(SketchPlugin_BSpline::ID(),
69 
70 
71  SKETCHAPI_EXPORT
73  const std::list<std::shared_ptr<GeomAPI_Pnt2d> >& thePoles,
74  const std::list<ModelHighAPI_Double>& theWeights);
75 
77  SKETCHAPI_EXPORT
78  void setByParameters(const ModelHighAPI_Integer& theDegree,
79  const std::list<std::shared_ptr<GeomAPI_Pnt2d> >& thePoles,
80  const std::list<ModelHighAPI_Double>& theWeights,
81  const std::list<ModelHighAPI_Double>& theKnots,
82  const std::list<ModelHighAPI_Integer>& theMults);
83 
85  SKETCHAPI_EXPORT
86  void setByExternal(const ModelHighAPI_Selection& theExternal);
87 
89  SKETCHAPI_EXPORT
90  std::list<std::shared_ptr<SketchAPI_SketchEntity> > controlPoles(
91  const std::list<int>& regular = std::list<int>(),
92  const std::list<int>& auxiliary = std::list<int>()) const;
93 
95  SKETCHAPI_EXPORT
96  std::list<std::shared_ptr<SketchAPI_SketchEntity> > controlPolygon(
97  const std::list<int>& regular = std::list<int>(),
98  const std::list<int>& auxiliary = std::list<int>()) const;
99 
101  SKETCHAPI_EXPORT
102  bool insertPole(const int theIndex,
103  const std::shared_ptr<GeomAPI_Pnt2d>& theCoordinates,
104  const ModelHighAPI_Double& theWeight = ModelHighAPI_Double(1.0));
105 
107  SKETCHAPI_EXPORT
108  virtual void dump(ModelHighAPI_Dumper& theDumper) const;
109 
110 protected:
111  SketchAPI_BSpline(const std::shared_ptr<ModelAPI_Feature>& theFeature, bool theInitialize);
112 
113 private:
116  void setStartAndEndPoints();
117 
120  void getDefaultParameters(const std::list<std::shared_ptr<GeomAPI_Pnt2d> >& thePoles,
121  const std::list<ModelHighAPI_Double>& theWeights,
122  ModelHighAPI_Integer& theDegree,
123  std::list<ModelHighAPI_Double>& theKnots,
124  std::list<ModelHighAPI_Integer>& theMults) const;
125 
127  void checkDefaultParameters(bool& isDefaultDegree,
128  bool& isDefaultWeights,
129  bool& isDefaultKnotsMults) const;
130 
131  void dumpControlPolygon(ModelHighAPI_Dumper& theDumper,
132  const FeaturePtr& theBSpline,
133  const std::string& theMethod,
134  const std::map<int, FeaturePtr>& theAuxFeatures) const;
135 };
136 
138 typedef std::shared_ptr<SketchAPI_BSpline> BSplinePtr;
139 
140 
141 
146 {
147 public:
149  SKETCHAPI_EXPORT
150  explicit SketchAPI_BSplinePeriodic(const std::shared_ptr<ModelAPI_Feature>& theFeature);
151 
153  SKETCHAPI_EXPORT
155 
156  static std::string ID() { return SketchPlugin_BSplinePeriodic::ID(); }
157  virtual std::string getID() { return SketchPlugin_BSplinePeriodic::ID(); }
158 };
159 
160 #endif // SketchAPI_BSpline_H_
2D point defined by two coordinates
Definition: GeomAPI_Pnt2d.h:36
Attribute that contains array of 2D point coordinates.
Definition: GeomDataAPI_Point2DArray.h:34
Attribute that contains 2D point coordinates.
Definition: GeomDataAPI_Point2D.h:37
API for the attribute that contains several double in the array inside.
Definition: ModelAPI_AttributeDoubleArray.h:32
API for the attribute that contains several integers in the array inside.
Definition: ModelAPI_AttributeIntArray.h:36
API for the attribute that contains integer (int).
Definition: ModelAPI_AttributeInteger.h:34
Attribute that contains reference to the sub-shape of some result, the selected shape.
Definition: ModelAPI_AttributeSelection.h:35
Feature function that represents the particular functionality of this operation.
Definition: ModelAPI_Feature.h:39
Class for filling ModelAPI_AttributeDouble.
Definition: ModelHighAPI_Double.h:37
Dump engine for the model.
Definition: ModelHighAPI_Dumper.h:81
Class for filling ModelAPI_AttributeInteger.
Definition: ModelHighAPI_Integer.h:36
Class for filling ModelAPI_AttributeSelection.
Definition: ModelHighAPI_Selection.h:49
Interface for BSplinePeriodic feature.
Definition: SketchAPI_BSpline.h:146
virtual ~SketchAPI_BSplinePeriodic()
Destructor.
Definition: SketchAPI_BSpline.h:154
Interface for BSpline feature.
Definition: SketchAPI_BSpline.h:42
virtual std::shared_ptr< ModelAPI_AttributeSelection > external() const
External.
Definition: SketchAPI_BSpline.h:68
virtual ~SketchAPI_BSpline()
Destructor.
Definition: SketchAPI_BSpline.cpp:58
void setByExternal(const ModelHighAPI_Selection &theExternal)
Set by external.
Definition: SketchAPI_BSpline.cpp:115
void setByParameters(const ModelHighAPI_Integer &theDegree, const std::list< std::shared_ptr< GeomAPI_Pnt2d > > &thePoles, const std::list< ModelHighAPI_Double > &theWeights, const std::list< ModelHighAPI_Double > &theKnots, const std::list< ModelHighAPI_Integer > &theMults)
Initialize by full set of B-spline parameters.
Definition: SketchAPI_BSpline.cpp:83
void setByDegreePolesAndWeights(const ModelHighAPI_Integer &theDegree, const std::list< std::shared_ptr< GeomAPI_Pnt2d > > &thePoles, const std::list< ModelHighAPI_Double > &theWeights)
Set by poles and weights.
Definition: SketchAPI_BSpline.cpp:62
bool insertPole(const int theIndex, const std::shared_ptr< GeomAPI_Pnt2d > &theCoordinates, const ModelHighAPI_Double &theWeight=ModelHighAPI_Double(1.0))
Insert new pole after the pole with the given index.
Definition: SketchAPI_BSpline.cpp:490
virtual void dump(ModelHighAPI_Dumper &theDumper) const
Dump wrapped feature.
Definition: SketchAPI_BSpline.cpp:393
std::list< std::shared_ptr< SketchAPI_SketchEntity > > controlPolygon(const std::list< int > &regular=std::list< int >(), const std::list< int > &auxiliary=std::list< int >()) const
Generate control polygon for B-spline curve.
Definition: SketchAPI_BSpline.cpp:235
virtual std::shared_ptr< ModelAPI_AttributeDoubleArray > knots() const
B-spline knots.
Definition: SketchAPI_BSpline.h:68
virtual std::shared_ptr< ModelAPI_AttributeInteger > degree() const
B-spline degree.
Definition: SketchAPI_BSpline.h:68
virtual std::shared_ptr< GeomDataAPI_Point2D > endPoint() const
Last pole of B-spline.
Definition: SketchAPI_BSpline.h:68
virtual std::shared_ptr< ModelAPI_AttributeIntArray > multiplicities() const
Knots multiplicities.
Definition: SketchAPI_BSpline.h:68
std::list< std::shared_ptr< SketchAPI_SketchEntity > > controlPoles(const std::list< int > &regular=std::list< int >(), const std::list< int > &auxiliary=std::list< int >()) const
Generate list of construction points coincident with B-spline poles.
Definition: SketchAPI_BSpline.cpp:216
virtual std::shared_ptr< ModelAPI_AttributeDoubleArray > weights() const
B-spline weights.
Definition: SketchAPI_BSpline.h:68
virtual std::shared_ptr< GeomDataAPI_Point2D > startPoint() const
First pole of B-spline.
Definition: SketchAPI_BSpline.h:68
virtual std::shared_ptr< GeomDataAPI_Point2DArray > poles() const
B-spline poles.
Definition: SketchAPI_BSpline.h:68
SketchAPI_BSpline(const std::shared_ptr< ModelAPI_Feature > &theFeature)
Constructor without values.
Definition: SketchAPI_BSpline.cpp:44
Base class for Sketch feature interfaces.
Definition: SketchAPI_SketchEntity.h:38
std::shared_ptr< ModelAPI_AttributeBoolean > auxiliary() const
Auxiliary.
Definition: SketchAPI_SketchEntity.cpp:62
static const std::string & MULTS_ID()
list of B-spline multiplicities
Definition: SketchPlugin_BSplineBase.h:62
static const std::string & DEGREE_ID()
attribute to store the degree of B-spline
Definition: SketchPlugin_BSplineBase.h:48
static const std::string & WEIGHTS_ID()
list of B-spline weights
Definition: SketchPlugin_BSplineBase.h:41
static const std::string & POLES_ID()
list of B-spline poles
Definition: SketchPlugin_BSplineBase.h:34
static const std::string & KNOTS_ID()
list of B-spline knots
Definition: SketchPlugin_BSplineBase.h:55
static const std::string & ID()
B-spline feature kind.
Definition: SketchPlugin_BSplinePeriodic.h:33
static const std::string & END_ID()
end point of B-spline curve
Definition: SketchPlugin_BSpline.h:46
static const std::string & ID()
B-spline feature kind.
Definition: SketchPlugin_BSpline.h:33
static const std::string & START_ID()
start point of B-spline curve
Definition: SketchPlugin_BSpline.h:40
static const std::string & EXTERNAL_ID()
Reference to the external edge or vertex as a AttributeSelection.
Definition: SketchPlugin_SketchEntity.h:55