1 // Copyright (C) 2014-2022 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef PrimitivesPlugin_Box_H_
21 #define PrimitivesPlugin_Box_H_
23 #include <PrimitivesPlugin.h>
24 #include <ModelAPI_Feature.h>
25 #include <GeomAlgoAPI_Box.h>
28 class ModelAPI_ResultBody;
30 /**\class PrimitivesPlugin_Box
32 * \brief Feature for creation of a box primitive using various methods.
34 * Box creates a cuboid - Parallelepiped with 6 rectangular faces. It can be built via three
35 * methods : using two points that define a diagonal, a point that define a center and 3 lengths
36 * that define the half-lengths on X, Y and Z-axes, or using 3 lengths that define the
37 * rectangular dimensions.
39 class PrimitivesPlugin_Box : public ModelAPI_Feature
43 inline static const std::string& ID()
45 static const std::string MY_BOX_ID("Box");
49 /// Attribute name for creation method
50 inline static const std::string& CREATION_METHOD()
52 static const std::string MY_CREATION_METHOD_ID("CreationMethod");
53 return MY_CREATION_METHOD_ID;
56 /// Attribute name for creation method
57 inline static const std::string& CREATION_METHOD_BY_DIMENSIONS()
59 static const std::string MY_CREATION_METHOD_ID("BoxByDimensions");
60 return MY_CREATION_METHOD_ID;
63 /// Attribute name for creation method
64 inline static const std::string& CREATION_METHOD_BY_TWO_POINTS()
66 static const std::string MY_CREATION_METHOD_ID("BoxByTwoPoints");
67 return MY_CREATION_METHOD_ID;
70 /// Attribute name for creation method
71 inline static const std::string& CREATION_METHOD_BY_ONE_POINT_AND_DIMS()
73 static const std::string MY_CREATION_METHOD_ID("BoxByOnePointAndDims");
74 return MY_CREATION_METHOD_ID;
77 /// Attribute name of first point
78 inline static const std::string& POINT_FIRST_ID()
80 static const std::string MY_POINT_FIRST_ID("FirstPoint");
81 return MY_POINT_FIRST_ID;
84 /// Attribute name of second point
85 inline static const std::string& POINT_SECOND_ID()
87 static const std::string MY_POINT_SECOND_ID("SecondPoint");
88 return MY_POINT_SECOND_ID;
91 /// Attribute first coordinate
92 inline static const std::string& DX_ID()
94 static const std::string MY_DX_ID("dx");
98 /// Attribute second coordinate
99 inline static const std::string& DY_ID()
101 static const std::string MY_DY_ID("dy");
105 /// Attribute third coordinate
106 inline static const std::string& DZ_ID()
108 static const std::string MY_DZ_ID("dz");
112 /// Attribute name of the first coordinate of the center
113 inline static const std::string& OX_ID()
115 static const std::string MY_OX_ID("ox");
119 /// Attribute name of the second coordinate of the center
120 inline static const std::string& OY_ID()
122 static const std::string MY_OY_ID("oy");
126 /// Attribute name of the third coordinate of the center
127 inline static const std::string& OZ_ID()
129 static const std::string MY_OZ_ID("oz");
133 /// Attribute name of the half-length on X axis
134 inline static const std::string& HALF_DX_ID()
136 static const std::string MY_HALF_DX_ID("half_dx");
137 return MY_HALF_DX_ID;
140 /// Attribute name of the half-length on Y axis
141 inline static const std::string& HALF_DY_ID()
143 static const std::string MY_HALF_DY_ID("half_dy");
144 return MY_HALF_DY_ID;
147 /// Attribute name of the half-length on Z axis
148 inline static const std::string& HALF_DZ_ID()
150 static const std::string MY_HALF_DZ_ID("half_dz");
151 return MY_HALF_DZ_ID;
154 /// Returns the kind of a feature
155 PRIMITIVESPLUGIN_EXPORT virtual const std::string& getKind()
157 static std::string MY_KIND = PrimitivesPlugin_Box::ID();
161 /// Creates a new part document if needed
162 PRIMITIVESPLUGIN_EXPORT virtual void execute();
164 /// Request for initialization of data model of the feature: adding all attributes
165 PRIMITIVESPLUGIN_EXPORT virtual void initAttributes();
167 /// Use plugin manager for features creation
168 PrimitivesPlugin_Box();
171 /// Load Naming data structure of the feature to the document
172 void loadNamingDS(std::shared_ptr<GeomAlgoAPI_Box> theBoxAlgo,
173 std::shared_ptr<ModelAPI_ResultBody> theResultBox);
175 ///Perform the creation of the box using two points defining a diagonal
176 void createBoxByTwoPoints();
178 ///Perform the creation of the box using three cordinates
179 void createBoxByDimensions();
181 ///Perform the creation of the box using a center and three half-lenths
182 void createBoxByOnePointAndDims();