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