Salome HOME
Copyright update 2022
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Fillet1D.h
1 // Copyright (C) 2020-2022  CEA/DEN, EDF R&D
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 FeaturesPlugin_Fillet1D_H_
21 #define FeaturesPlugin_Fillet1D_H_
22
23 #include <FeaturesPlugin.h>
24
25 #include <GeomAPI_Shape.h>
26 #include <ModelAPI_Feature.h>
27
28 #include <map>
29
30 /// \class FeaturesPlugin_Fillet1D
31 /// \ingroup Plugins
32 /// \brief Feature for appling fillet on vertices of 3D wire.
33 class FeaturesPlugin_Fillet1D : public ModelAPI_Feature
34 {
35   typedef std::map<GeomShapePtr, ListOfShape, GeomAPI_Shape::Comparator> MapShapeSubs;
36
37 public:
38   /// Feature kind.
39   inline static const std::string& ID()
40   {
41     static const std::string MY_ID("Fillet1D");
42     return MY_ID;
43   }
44
45   /// \return the kind of a feature.
46   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
47   {
48     static std::string MY_KIND = FeaturesPlugin_Fillet1D::ID();
49     return MY_KIND;
50   }
51
52   inline static const std::string& CREATION_METHOD()
53   {
54     static std::string MY_CREATION_METHOD("creation_method");
55     return MY_CREATION_METHOD;
56   }
57
58   inline static const std::string CREATION_BY_WIRES()
59   {
60     static std::string MY_SINGLE_RADIUS("by_wires");
61     return MY_SINGLE_RADIUS;
62   }
63
64   inline static const std::string CREATION_BY_VERTICES()
65   {
66     static std::string MY_VARYING_RADIUS("by_vertices");
67     return MY_VARYING_RADIUS;
68   }
69
70   /// Attribute name of selected wires.
71   inline static const std::string& WIRE_LIST_ID()
72   {
73     static const std::string MY_OBJECT_LIST_ID("main_wires");
74     return MY_OBJECT_LIST_ID;
75   }
76
77   /// Attribute name of selected vertices.
78   inline static const std::string& VERTEX_LIST_ID()
79   {
80     static const std::string MY_OBJECT_LIST_ID("main_vertices");
81     return MY_OBJECT_LIST_ID;
82   }
83
84   /// Attribute name of radius.
85   inline static const std::string& RADIUS_ID()
86   {
87     static const std::string MY_RADIUS_ID("radius");
88     return MY_RADIUS_ID;
89   }
90
91   /// Request for initialization of data model of the feature: adding all attributes.
92   FEATURESPLUGIN_EXPORT virtual void initAttributes();
93
94   /// Called on change of any argument-attribute of this object
95   /// \param theID identifier of changed attribute
96   FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
97
98   /// Performs the fillet algorithm and stores it in the data structure.
99   FEATURESPLUGIN_EXPORT virtual void execute();
100
101   /// Use plugin manager for features creation.
102   FeaturesPlugin_Fillet1D();
103
104 private:
105   /// Get the list of wires and fillet vertices
106   /// \retun \c false if errors occured
107   bool baseShapes(ListOfShape& theWires, MapShapeSubs& theWireVertices);
108
109   /// Run fillet operation and store result.
110   /// \return \c false if fillet failed.
111   bool performFillet(const GeomShapePtr& theWire,
112                      const ListOfShape& theVertices,
113                      const int theResultIndex);
114
115 private:
116   ListOfShape myFailedVertices;
117 };
118
119 #endif