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