SHAPER  9.12.0
SketchPlugin_CurveFitting.h
1 // Copyright (C) 2020-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 SketchPlugin_CurveFitting_H_
21 #define SketchPlugin_CurveFitting_H_
22 
23 #include <SketchPlugin.h>
24 #include <SketchPlugin_SketchEntity.h>
25 
26 #include <GeomAPI_IPresentable.h>
27 
28 class GeomAPI_Edge;
29 
37 {
38 public:
40  inline static const std::string& ID()
41  {
42  static const std::string ID("SketchCurveFitting");
43  return ID;
44  }
45 
47  inline static const std::string& POINTS_ID()
48  {
49  static const std::string ID("points");
50  return ID;
51  }
52 
54  inline static const std::string& PERIODIC_ID()
55  {
56  static const std::string ID("periodic");
57  return ID;
58  }
59 
61  inline static const std::string& CLOSED_ID()
62  {
63  static const std::string ID("closed");
64  return ID;
65  }
66 
68  inline static const std::string& NEED_CONTROL_POLYGON_ID()
69  {
70  static const std::string ID("need_control_poly");
71  return ID;
72  }
73 
75  inline static const std::string& TYPE_ID()
76  {
77  static const std::string ID("type");
78  return ID;
79  }
80 
82  inline static const std::string& TYPE_INTERPOLATION_ID()
83  {
84  static const std::string ID("interpolation_type");
85  return ID;
86  }
87 
89  inline static const std::string& TYPE_APPROXIMATION_ID()
90  {
91  static const std::string ID("approximation_type");
92  return ID;
93  }
94 
96  inline static const std::string& PRECISION_ID()
97  {
98  static const std::string ID("precision");
99  return ID;
100  }
101 
103  inline static const std::string& REORDER_POINTS_ACTION_ID()
104  {
105  static const std::string ID("reorder_points");
106  return ID;
107  }
108 
110  SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
111  {
112  static std::string MY_KIND = SketchPlugin_CurveFitting::ID();
113  return MY_KIND;
114  }
115 
117  virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
118 
120  SKETCHPLUGIN_EXPORT virtual void execute();
121 
124  SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;};
125 
126  SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
127 
131  SKETCHPLUGIN_EXPORT virtual bool customAction(const std::string& theActionId);
132 
135 
136 protected:
138  virtual void initDerivedClassAttributes();
139 
140 private:
142  FeaturePtr createBSplineFeature();
143 
145  void createConstraints(FeaturePtr theProducedFeature);
146 
148  void reorderPoints();
149 
150 private:
151  std::shared_ptr<GeomAPI_Edge> myTransientResult;
152 };
153 
154 #endif
Interface to the edge object.
Definition: GeomAPI_Edge.h:38
A class which defines an interface of object which is able to create its own presentation.
Definition: GeomAPI_IPresentable.h:29
Feature for creation of the new B-spline curve in sketch as an interpolation or an approximation of a...
Definition: SketchPlugin_CurveFitting.h:37
static const std::string & PRECISION_ID()
attribute for the precision of the approximation
Definition: SketchPlugin_CurveFitting.h:96
virtual SKETCHPLUGIN_EXPORT const std::string & getKind()
Returns the kind of a feature.
Definition: SketchPlugin_CurveFitting.h:110
static const std::string & NEED_CONTROL_POLYGON_ID()
attribute for the flag of creation a control polygon
Definition: SketchPlugin_CurveFitting.h:68
static const std::string & CLOSED_ID()
attribute for the closed flag
Definition: SketchPlugin_CurveFitting.h:61
virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious)
Returns the AIS preview.
Definition: SketchPlugin_CurveFitting.cpp:287
static const std::string & POINTS_ID()
list of selected points
Definition: SketchPlugin_CurveFitting.h:47
virtual void initDerivedClassAttributes()
Initializes attributes of derived class.
Definition: SketchPlugin_CurveFitting.cpp:70
static const std::string & PERIODIC_ID()
attribute for the periodic flag
Definition: SketchPlugin_CurveFitting.h:54
static const std::string & TYPE_APPROXIMATION_ID()
value for the type of operation
Definition: SketchPlugin_CurveFitting.h:89
static const std::string & ID()
Interpolation macro feature kind.
Definition: SketchPlugin_CurveFitting.h:40
static const std::string & TYPE_INTERPOLATION_ID()
value for the type of operation
Definition: SketchPlugin_CurveFitting.h:82
static const std::string & TYPE_ID()
attribute for the type of the operation
Definition: SketchPlugin_CurveFitting.h:75
virtual SKETCHPLUGIN_EXPORT bool isMacro() const
Reimplemented from ModelAPI_Feature::isMacro().
Definition: SketchPlugin_CurveFitting.h:124
virtual SKETCHPLUGIN_EXPORT bool isPreviewNeeded() const
Returns true if preview update during the edition needed.
Definition: SketchPlugin_CurveFitting.h:126
virtual SKETCHPLUGIN_EXPORT void execute()
Creates a new part document if needed.
Definition: SketchPlugin_CurveFitting.cpp:87
virtual SKETCHPLUGIN_EXPORT bool customAction(const std::string &theActionId)
Performs some functionality by action id.
Definition: SketchPlugin_CurveFitting.cpp:238
static const std::string & REORDER_POINTS_ACTION_ID()
attribute for the closed flag
Definition: SketchPlugin_CurveFitting.h:103
SketchPlugin_CurveFitting()
Use plugin manager for features creation.
Definition: SketchPlugin_CurveFitting.cpp:65
Sketch Entity for creation of the new feature in PartSet.
Definition: SketchPlugin_SketchEntity.h:45