1 // Copyright (C) 2020-2023 CEA, EDF
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_CurveFitting_H_
21 #define SketchPlugin_CurveFitting_H_
23 #include <SketchPlugin.h>
24 #include <SketchPlugin_SketchEntity.h>
26 #include <GeomAPI_IPresentable.h>
30 /**\class SketchPlugin_CurveFitting
32 * \brief Feature for creation of the new B-spline curve in sketch
33 * as an interpolation or an approximation of a list of points.
35 class SketchPlugin_CurveFitting : public SketchPlugin_SketchEntity,
36 public GeomAPI_IPresentable
39 /// Interpolation macro feature kind
40 inline static const std::string& ID()
42 static const std::string ID("SketchCurveFitting");
46 /// list of selected points
47 inline static const std::string& POINTS_ID()
49 static const std::string ID("points");
53 /// attribute for the periodic flag
54 inline static const std::string& PERIODIC_ID()
56 static const std::string ID("periodic");
60 /// attribute for the closed flag
61 inline static const std::string& CLOSED_ID()
63 static const std::string ID("closed");
67 /// attribute for the flag of creation a control polygon
68 inline static const std::string& NEED_CONTROL_POLYGON_ID()
70 static const std::string ID("need_control_poly");
74 /// attribute for the type of the operation
75 inline static const std::string& TYPE_ID()
77 static const std::string ID("type");
81 /// value for the type of operation
82 inline static const std::string& TYPE_INTERPOLATION_ID()
84 static const std::string ID("interpolation_type");
88 /// value for the type of operation
89 inline static const std::string& TYPE_APPROXIMATION_ID()
91 static const std::string ID("approximation_type");
95 /// attribute for the precision of the approximation
96 inline static const std::string& PRECISION_ID()
98 static const std::string ID("precision");
102 /// attribute for the closed flag
103 inline static const std::string& REORDER_POINTS_ACTION_ID()
105 static const std::string ID("reorder_points");
109 /// Returns the kind of a feature
110 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
112 static std::string MY_KIND = SketchPlugin_CurveFitting::ID();
116 /// Returns the AIS preview
117 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
119 /// Creates a new part document if needed
120 SKETCHPLUGIN_EXPORT virtual void execute();
122 /// Reimplemented from ModelAPI_Feature::isMacro().
124 SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;};
126 SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
128 /// Performs some functionality by action id.
129 /// \param[in] theAttributeId action key id.
130 /// \return false in case if action not performed.
131 SKETCHPLUGIN_EXPORT virtual bool customAction(const std::string& theActionId);
133 /// Use plugin manager for features creation
134 SketchPlugin_CurveFitting();
137 /// \brief Initializes attributes of derived class.
138 virtual void initDerivedClassAttributes();
141 /// \brief Create a feature, which passes through the selected points
142 FeaturePtr createBSplineFeature();
144 /// \brief Create coincidence constraints between selected points and the produced curve.
145 void createConstraints(FeaturePtr theProducedFeature);
147 /// \brief Reorder point to compose the polyline of the minimal length
148 void reorderPoints();
151 std::shared_ptr<GeomAPI_Edge> myTransientResult; ///< Interpolation curve