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 SketchAPI_BSpline_H_
21 #define SketchAPI_BSpline_H_
23 #include "SketchAPI.h"
24 #include "SketchAPI_SketchEntity.h"
26 #include <GeomDataAPI_Point2DArray.h>
28 #include <ModelAPI_AttributeDoubleArray.h>
30 #include <SketchPlugin_BSpline.h>
32 class ModelHighAPI_Double;
33 class ModelHighAPI_Integer;
34 class ModelHighAPI_Selection;
36 /// \class SketchAPI_BSpline
37 /// \ingroup CPPHighAPI
38 /// \brief Interface for BSpline feature.
39 class SketchAPI_BSpline : public SketchAPI_SketchEntity
42 /// Constructor without values.
44 explicit SketchAPI_BSpline(const std::shared_ptr<ModelAPI_Feature>& theFeature);
46 /// Constructor with values.
47 SKETCHAPI_EXPORT SketchAPI_BSpline(
48 const std::shared_ptr<ModelAPI_Feature>& theFeature,
49 const std::list<std::shared_ptr<GeomAPI_Pnt2d> >& thePoles,
50 const std::list<ModelHighAPI_Double>& theWeights = std::list<ModelHighAPI_Double>());
52 /// Constructor with values.
53 SKETCHAPI_EXPORT SketchAPI_BSpline(
54 const std::shared_ptr<ModelAPI_Feature>& theFeature,
56 const std::list<std::shared_ptr<GeomAPI_Pnt2d> >& thePoles,
57 const std::list<ModelHighAPI_Double>& theWeights = std::list<ModelHighAPI_Double>(),
58 const std::list<ModelHighAPI_Double>& theKnots = std::list<ModelHighAPI_Double>(),
59 const std::list<ModelHighAPI_Integer>& theMults = std::list<ModelHighAPI_Integer>());
61 /// Constructor with external.
63 SketchAPI_BSpline(const std::shared_ptr<ModelAPI_Feature>& theFeature,
64 const ModelHighAPI_Selection& theExternal);
66 /// Constructor with external.
68 SketchAPI_BSpline(const std::shared_ptr<ModelAPI_Feature>& theFeature,
69 const std::string& theExternalName);
73 virtual ~SketchAPI_BSpline();
75 INTERFACE_8(SketchPlugin_BSpline::ID(),
76 poles, SketchPlugin_BSpline::POLES_ID(),
77 GeomDataAPI_Point2DArray, /** B-spline poles */,
78 weights, SketchPlugin_BSpline::WEIGHTS_ID(),
79 ModelAPI_AttributeDoubleArray, /** B-spline weights */,
80 knots, SketchPlugin_BSpline::KNOTS_ID(),
81 ModelAPI_AttributeDoubleArray, /** B-spline knots */,
82 multiplicities, SketchPlugin_BSpline::MULTS_ID(),
83 ModelAPI_AttributeIntArray, /** Knots multiplicities */,
84 degree, SketchPlugin_BSpline::DEGREE_ID(),
85 ModelAPI_AttributeInteger, /** B-spline degree */,
86 startPoint, SketchPlugin_BSpline::START_ID(),
87 GeomDataAPI_Point2D, /** First pole of B-spline */,
88 endPoint, SketchPlugin_BSpline::END_ID(),
89 GeomDataAPI_Point2D, /** Last pole of B-spline */,
90 external, SketchPlugin_BSpline::EXTERNAL_ID(),
91 ModelAPI_AttributeSelection, /** External */)
93 /// Set by poles and weights.
95 void setByDegreePolesAndWeights(const ModelHighAPI_Integer& theDegree,
96 const std::list<std::shared_ptr<GeomAPI_Pnt2d> >& thePoles,
97 const std::list<ModelHighAPI_Double>& theWeights);
99 /// Initialize by full set of B-spline parameters.
101 void setByParameters(const ModelHighAPI_Integer& theDegree,
102 const std::list<std::shared_ptr<GeomAPI_Pnt2d> >& thePoles,
103 const std::list<ModelHighAPI_Double>& theWeights,
104 const std::list<ModelHighAPI_Double>& theKnots,
105 const std::list<ModelHighAPI_Integer>& theMults);
109 void setByExternal(const ModelHighAPI_Selection& theExternal);
111 /// Set by external name.
113 void setByExternalName(const std::string& theExternalName);
115 /// Generate list of construction points coincident with B-spline poles
117 std::list<std::shared_ptr<SketchAPI_SketchEntity> > controlPoles(
118 const std::list<int>& regular = std::list<int>(),
119 const std::list<int>& auxiliary = std::list<int>()) const;
121 /// Generate control polygon for B-spline curve
123 std::list<std::shared_ptr<SketchAPI_SketchEntity> > controlPolygon(
124 const std::list<int>& regular = std::list<int>(),
125 const std::list<int>& auxiliary = std::list<int>()) const;
127 /// Dump wrapped feature
129 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
132 /// Initialize start and end points of B-spline and apply internal coincidence
133 /// constraint to keep them on the corresponding pole.
134 void setStartAndEndPoints();
136 /// Compute default B-spline parameters (degree, knots and multiplicities)
137 /// basing on hte given poles and weights
138 void getDefaultParameters(const std::list<std::shared_ptr<GeomAPI_Pnt2d> >& thePoles,
139 const std::list<ModelHighAPI_Double>& theWeights,
140 ModelHighAPI_Integer& theDegree,
141 std::list<ModelHighAPI_Double>& theKnots,
142 std::list<ModelHighAPI_Integer>& theMults) const;
144 /// Check what parameters of B-spline are default
145 void checkDefaultParameters(bool& isDefaultDegree,
146 bool& isDefaultWeights,
147 bool& isDefaultKnotsMults) const;
149 void dumpControlPolygon(ModelHighAPI_Dumper& theDumper,
150 const FeaturePtr& theBSpline,
151 const std::string& theMethod,
152 const std::map<int, FeaturePtr>& theAuxFeatures) const;
155 /// Pointer on B-spline object.
156 typedef std::shared_ptr<SketchAPI_BSpline> BSplinePtr;
158 #endif // SketchAPI_BSpline_H_