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