1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef BuildPlugin_Filling_H_
22 #define BuildPlugin_Filling_H_
24 #include "BuildPlugin.h"
26 #include <ModelAPI_Feature.h>
31 class GeomAlgoAPI_MakeShape;
36 /// \class BuildPlugin_Filling
38 /// \brief Feature for creation of face from list of edges (1D objects).
39 class BuildPlugin_Filling: public ModelAPI_Feature
42 /// Use plugin manager for features creation
43 BuildPlugin_Filling();
46 inline static const std::string& ID()
48 static const std::string MY_ID("Filling");
52 /// \return the kind of a feature.
53 BUILDPLUGIN_EXPORT virtual const std::string& getKind()
55 static std::string MY_KIND = BuildPlugin_Filling::ID();
59 /// Attribute name of base objects.
60 inline static const std::string& BASE_OBJECTS_ID()
62 static const std::string MY_BASE_OBJECTS_ID("base_objects");
63 return MY_BASE_OBJECTS_ID;
66 /// Attribute name of advanced options.
67 inline static const std::string& ADVANCED_OPTIONS_ID()
69 static const std::string MY_ADVANCED_OPTIONS_ID("advanced_options");
70 return MY_ADVANCED_OPTIONS_ID;
73 /// Attribute name of method of edge orientation.
74 inline static const std::string& METHOD_ID()
76 static const std::string MY_METHOD_ID("orientation");
80 /// Supported methods for edge orientation correction
82 inline static const std::string& AUTO_CORRECT_ORIENTATION()
84 static const std::string MY_AUTO_CORRECT_ORIENTATION("auto_correct");
85 return MY_AUTO_CORRECT_ORIENTATION;
87 inline static const std::string& USE_CURVE_INFORMATION()
89 static const std::string MY_USE_CURVE_INFORMATION("curve_info");
90 return MY_USE_CURVE_INFORMATION;
92 inline static const std::string& USE_EDGES_ORIENTATION()
94 static const std::string MY_USE_EDGES_ORIENTATION("edge_orient");
95 return MY_USE_EDGES_ORIENTATION;
99 /// Attribute name of minimal degree.
100 inline static const std::string& MINIMAL_DEGREE_ID()
102 static const std::string MY_MINIMAL_DEGREE_ID("min_degree");
103 return MY_MINIMAL_DEGREE_ID;
106 /// Attribute name of maximal degree.
107 inline static const std::string& MAXIMAL_DEGREE_ID()
109 static const std::string MY_MAXIMAL_DEGREE_ID("max_degree");
110 return MY_MAXIMAL_DEGREE_ID;
113 /// Attribute name of number of iterations.
114 inline static const std::string& NUMBER_OF_ITERATIONS_ID()
116 static const std::string MY_NUMBER_OF_ITERATIONS_ID("nb_iter");
117 return MY_NUMBER_OF_ITERATIONS_ID;
120 /// Attribute name of 2D tolerance.
121 inline static const std::string& TOLERANCE_2D_ID()
123 static const std::string MY_TOLERANCE_2D_ID("tol_2d");
124 return MY_TOLERANCE_2D_ID;
127 /// Attribute name of 3D tolerance.
128 inline static const std::string& TOLERANCE_3D_ID()
130 static const std::string MY_TOLERANCE_3D_ID("tol_3d");
131 return MY_TOLERANCE_3D_ID;
134 /// Attribute name of approximation.
135 inline static const std::string& APPROXIMATION_ID()
137 static const std::string MY_APPROXIMATION_ID("approximation");
138 return MY_APPROXIMATION_ID;
141 /// Default value of the orientation
142 inline static const std::string& METHOD_DEFAULT() { return Method::AUTO_CORRECT_ORIENTATION(); }
143 /// Default value of minimal degree
144 inline static int MINIMAL_DEGREE_DEFAULT() { return 2; }
145 /// Default value of maximal degree
146 inline static int MAXIMAL_DEGREE_DEFAULT() { return 5; }
147 /// Default value of number of iterations
148 inline static int NUMBER_OF_ITERATIONS_DEFAULT() { return 0; }
149 /// Default value of 2D tolerance
150 inline static double TOLERANCE_2D_DEFAULT() { return 1.e-4; }
151 /// Default value of 3D tolerance
152 inline static double TOLERANCE_3D_DEFAULT() { return 1.e-4; }
153 /// Default value of the approximation attribute
154 inline static bool APPROXIMATION_DEFAULT() { return false; }
156 /// Request for initialization of data model of the feature: adding all attributes.
157 BUILDPLUGIN_EXPORT virtual void initAttributes();
159 /// Creates a new part document if needed.
160 BUILDPLUGIN_EXPORT virtual void execute();
162 /// Called on change of any argument-attribute of this object.
163 /// \param[in] theID identifier of changed attribute.
164 BUILDPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
167 /// Check the filling algorithm is failed
168 bool isAlgorithmFailed(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm);
170 /// Convert shape to edge according to construction method
171 std::shared_ptr<GeomAPI_Edge> toEdge(const std::shared_ptr<GeomAPI_Shape>& theShape,
172 const std::string& theMethod);
174 /// Update values of attributes by their default values
175 void restoreDefaultParameters();
178 std::shared_ptr<GeomAPI_Pnt> myLastEdgeStartPoint;
179 std::shared_ptr<GeomAPI_Pnt> myLastEdgeEndPoint;