Salome HOME
Merge branch 'V9_7_BR'
[modules/shaper.git] / src / PrimitivesPlugin / PrimitivesPlugin_Box.h
1 // Copyright (C) 2014-2021  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 PrimitivesPlugin_Box_H_
21 #define PrimitivesPlugin_Box_H_
22
23 #include <PrimitivesPlugin.h>
24 #include <ModelAPI_Feature.h>
25 #include <GeomAlgoAPI_Box.h>
26
27 class GeomAPI_Shape;
28 class ModelAPI_ResultBody;
29
30 /**\class PrimitivesPlugin_Box
31  * \ingroup Plugins
32  * \brief Feature for creation of a box primitive using various methods.
33  *
34  * Box creates a cuboid - Parallelepiped with 6 rectangular faces. It can be built via two
35  * methods : using two points that define a diagonal, or using 3 lengths that define the 
36  * rectangular dimensions.
37  */
38 class PrimitivesPlugin_Box : public ModelAPI_Feature
39 {
40  public:
41   /// Box kind
42   inline static const std::string& ID()
43   {
44     static const std::string MY_BOX_ID("Box");
45     return MY_BOX_ID;
46   }
47
48   /// Attribute name for creation method
49   inline static const std::string& CREATION_METHOD()
50   {
51     static const std::string MY_CREATION_METHOD_ID("CreationMethod");
52     return MY_CREATION_METHOD_ID;
53   }
54
55   /// Attribute name for creation method
56   inline static const std::string& CREATION_METHOD_BY_DIMENSIONS()
57   {
58     static const std::string MY_CREATION_METHOD_ID("BoxByDimensions");
59     return MY_CREATION_METHOD_ID;
60   }
61
62   /// Attribute name for creation method
63   inline static const std::string& CREATION_METHOD_BY_TWO_POINTS()
64   {
65     static const std::string MY_CREATION_METHOD_ID("BoxByTwoPoints");
66     return MY_CREATION_METHOD_ID;
67   }
68
69   /// Attribute name of first point
70   inline static const std::string& POINT_FIRST_ID()
71   {
72     static const std::string MY_POINT_FIRST_ID("FirstPoint");
73     return MY_POINT_FIRST_ID;
74   }
75
76   /// Attribute name of second point
77   inline static const std::string& POINT_SECOND_ID()
78   {
79     static const std::string MY_POINT_SECOND_ID("SecondPoint");
80     return MY_POINT_SECOND_ID;
81   }
82
83   /// Attribute first coordinate
84   inline static const std::string& DX_ID()
85   {
86     static const std::string MY_DX_ID("dx");
87     return MY_DX_ID;
88   }
89
90   /// Attribute second coordinate
91   inline static const std::string& DY_ID()
92   {
93     static const std::string MY_DY_ID("dy");
94     return MY_DY_ID;
95   }
96
97   /// Attribute third coordinate
98   inline static const std::string& DZ_ID()
99   {
100     static const std::string MY_DZ_ID("dz");
101     return MY_DZ_ID;
102   }
103
104   /// Returns the kind of a feature
105   PRIMITIVESPLUGIN_EXPORT virtual const std::string& getKind()
106   {
107     static std::string MY_KIND = PrimitivesPlugin_Box::ID();
108     return MY_KIND;
109   }
110
111   /// Creates a new part document if needed
112   PRIMITIVESPLUGIN_EXPORT virtual void execute();
113
114   /// Request for initialization of data model of the feature: adding all attributes
115   PRIMITIVESPLUGIN_EXPORT virtual void initAttributes();
116
117   /// Use plugin manager for features creation
118   PrimitivesPlugin_Box();
119
120  private:
121   /// Load Naming data structure of the feature to the document
122   void loadNamingDS(std::shared_ptr<GeomAlgoAPI_Box> theBoxAlgo,
123                     std::shared_ptr<ModelAPI_ResultBody> theResultBox);
124
125   ///Perform the creation of the box using two points defining a diagonal
126   void createBoxByTwoPoints();
127
128   ///Perform the creation of the box using three cordinates
129   void createBoxByDimensions();
130
131 };
132
133
134 #endif