Salome HOME
[Code coverage GeomAlgoAPI]: Refactoring of ShapeAPI and additional unit tests
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_ShapeAPI.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 GEOMALGOAPI_SHAPEAPI_H
22 #define GEOMALGOAPI_SHAPEAPI_H
23
24 #include <GeomAPI_Ax1.h>
25 #include <GeomAPI_Ax2.h>
26 #include <GeomAPI_Edge.h>
27 #include <GeomAPI_Pnt.h>
28 #include <GeomAPI_Shape.h>
29
30 #include <GeomAlgoAPI_Exception.h>
31
32 namespace GeomAlgoAPI_ShapeAPI
33 {
34 /**\class GeomAlgoAPI_ShapeAPI
35  * \ingroup DataAlgo
36  * \brief Allows to access the direct API
37  */
38 class GEOMALGOAPI_EXPORT GeomAlgoAPI_ShapeAPI
39 {
40 public:
41   /// Creates a box using the dimensions.
42   /// \param theDx The dimension on X
43   /// \param theDy The dimension on Y
44   /// \param theDz The dimension on Z
45   /// \return a shape
46   static std::shared_ptr<GeomAPI_Shape> makeBox(const double theDx, const double theDy,
47                                                 const double theDz) throw (GeomAlgoAPI_Exception);
48
49   /// Creates a box using the two points that defined a diagonal.
50   /// \param theFirstPoint One extermity of the diagonal
51   /// \param theSecondPoint The other extremity of the diagonal
52   /// \return a shape
53   static std::shared_ptr<GeomAPI_Shape> makeBox(std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
54                      std::shared_ptr<GeomAPI_Pnt> theSecondPoint) throw (GeomAlgoAPI_Exception);
55
56   /// Creates a cylinder using a center, an axis, a radius and a height.
57   /// \param theBasePoint The center of the lower base of the cylinder
58   /// \param theEdge The axis of the cylinder
59   /// \param theRadius The radius of the cylinder
60   /// \param theHeight The heigth of the cylinder
61   static std::shared_ptr<GeomAPI_Shape> makeCylinder(std::shared_ptr<GeomAPI_Pnt> theBasePoint,
62                      std::shared_ptr<GeomAPI_Edge> theEdge, double theRadius, double theHeight)
63                      throw (GeomAlgoAPI_Exception);
64
65   /// Creates a portion of cylinder using a center, an axis, a radius, a height and an angle.
66   /// \param theBasePoint The center of the lower base of the cylinder
67   /// \param theEdge The axis of the cylinder
68   /// \param theRadius The radius of the cylinder
69   /// \param theHeight The heigth of the cylinder
70   /// \param theAngle The angle defining the portion
71   static std::shared_ptr<GeomAPI_Shape> makeCylinder(std::shared_ptr<GeomAPI_Pnt> theBasePoint,
72                      std::shared_ptr<GeomAPI_Edge> theEdge, double theRadius, double theHeight,
73                      double theAngle) throw (GeomAlgoAPI_Exception);
74
75   /// Creates a cylinder using the origin, the OZ axis, a radius and a height.
76   /// \param theRadius The radius of the cylinder
77   /// \param theHeight The heigth of the cylinder
78   static std::shared_ptr<GeomAPI_Shape> makeCylinder(double theRadius, double theHeight)
79                      throw (GeomAlgoAPI_Exception);
80
81   /// Creates a portion of cylinder using the origin, the OZ axis, a radius, a height and an angle.
82   /// \param theRadius The radius of the cylinder
83   /// \param theHeight The heigth of the cylinder
84   /// \param theAngle The angle defining the portion
85   static std::shared_ptr<GeomAPI_Shape> makeCylinder(double theRadius, double theHeight,
86                      double theAngle) throw (GeomAlgoAPI_Exception);
87
88   /// Creates a sphere using a center and a radius.
89   /// \param theCenterPoint The center of the sphere
90   /// \param theRadius The radius of the sphere
91   static std::shared_ptr<GeomAPI_Shape> makeSphere(std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
92                      double theRadius) throw (GeomAlgoAPI_Exception);
93
94   /// Creates a sphere using the origin and a radius.
95   /// \param theRadius The radius of the sphere
96   static std::shared_ptr<GeomAPI_Shape> makeSphere(double theRadius)
97                      throw (GeomAlgoAPI_Exception);
98
99   /// Creates a torus using a base point, an axis, a radius and a ring radius.
100   /// \param theBasePoint The center of the torus
101   /// \param theEdge The axis of the torus
102   /// \param theRadius The radius of the torus
103   /// \param theRingRadius The ring radius of the torus
104   static std::shared_ptr<GeomAPI_Shape> makeTorus(std::shared_ptr<GeomAPI_Pnt> theBasePoint,
105                      std::shared_ptr<GeomAPI_Edge> theEdge, double theRadius, double theRingRadius)
106                      throw (GeomAlgoAPI_Exception);
107
108   /// Creates a torus using a radius and a ring radius.
109   /// \param theRadius The radius of the torus
110   /// \param theRingRadius The ring radius of the torus
111   static std::shared_ptr<GeomAPI_Shape> makeTorus(double theRadius, double theRingRadius)
112                      throw (GeomAlgoAPI_Exception);
113
114   /// Creates a cone using a base point, an axis, a base radius, a top radius and a height.
115   /// \param theBasePoint The center of the lower base of the cone
116   /// \param theEdge The axis of the cone
117   /// \param theBaseRadius The base radius of the cone
118   /// \param theTopRadius The top radius of the cone
119   /// \param theHeight The height of the cone
120   static std::shared_ptr<GeomAPI_Shape> makeCone(std::shared_ptr<GeomAPI_Pnt> theBasePoint,
121                      std::shared_ptr<GeomAPI_Edge> theEdge, double theBaseRadius,
122                      double theTopRadius, double theHeight) throw (GeomAlgoAPI_Exception);
123
124   /// Creates a cone using a base radius, a top radius and a height.
125   /// \param theBaseRadius The base radius of the cone
126   /// \param theTopRadius The top radius of the cone
127   /// \param theHeight The height of the cone
128   static std::shared_ptr<GeomAPI_Shape> makeCone(double theBaseRadius, double theTopRadius,
129                      double theHeight) throw (GeomAlgoAPI_Exception);
130
131   /// Performs a translation from an axis and a distance.
132   /// \param theSourceShape Shape to be moved
133   /// \param theAxis Movement axis
134   /// \param theDistance Movement distance
135   /// \return a shape
136   static std::shared_ptr<GeomAPI_Shape> makeTranslation(
137                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
138                      std::shared_ptr<GeomAPI_Ax1> theAxis,
139                      const double theDistance) throw (GeomAlgoAPI_Exception);
140
141   /// Performs a translation from dimensions.
142   /// \param theSourceShape Shape to be moved
143   /// \param theDx Movement dimension on X
144   /// \param theDy Movement dimension on Y
145   /// \param theDz Movement dimension on Z
146   /// \return a shape
147   static std::shared_ptr<GeomAPI_Shape> makeTranslation(
148                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
149                      const double theDx,
150                      const double theDy,
151                      const double theDz) throw (GeomAlgoAPI_Exception);
152
153   /// Performs a translation from two points.
154   /// \param theSourceShape Shape to be moved
155   /// \param theStartPoint Movement start point
156   /// \param theEndPoint Movement end point
157   /// \return a shape
158   static std::shared_ptr<GeomAPI_Shape> makeTranslation(
159                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
160                      std::shared_ptr<GeomAPI_Pnt> theStartPoint,
161                      std::shared_ptr<GeomAPI_Pnt> theEndPoint) throw (GeomAlgoAPI_Exception);
162
163   /// Performs a rotation from an axis and an angle.
164   /// \param theSourceShape Shape to be rotated
165   /// \param theAxis Movement axis
166   /// \param theAngle Movement angle
167   /// \return a shape
168   static std::shared_ptr<GeomAPI_Shape> makeRotation(
169                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
170                      std::shared_ptr<GeomAPI_Ax1> theAxis,
171                      const double theAngle) throw (GeomAlgoAPI_Exception);
172
173   /// Performs a rotation from three points.
174   /// \param theSourceShape Shape to be rotated
175   /// \param theCenterPoint Movement center point
176   /// \param theStartPoint Movement start point
177   /// \param theEndPoint Movement end point
178   /// \return a shape
179   static std::shared_ptr<GeomAPI_Shape> makeRotation(
180                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
181                      std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
182                      std::shared_ptr<GeomAPI_Pnt> theStartPoint,
183                      std::shared_ptr<GeomAPI_Pnt> theEndPoint) throw (GeomAlgoAPI_Exception);
184
185   /// Performs a symmetry by a point.
186   /// \param theSourceShape Shape be symmetrized
187   /// \param thePoint Point of symmetry
188   static std::shared_ptr<GeomAPI_Shape> makeSymmetry(
189                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
190                      std::shared_ptr<GeomAPI_Pnt> thePoint) throw (GeomAlgoAPI_Exception);
191
192   /// Performs a symmetry by an axis.
193   /// \param theSourceShape Shape be symmetrized
194   /// \param theAxis Axis of symmetry
195   static std::shared_ptr<GeomAPI_Shape> makeSymmetry(
196                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
197                      std::shared_ptr<GeomAPI_Ax1> theAxis) throw (GeomAlgoAPI_Exception);
198
199   /// Performs a symmetry by a plane.
200   /// \param theSourceShape Shape be symmetrized
201   /// \param thePlane Plane of symmetry
202   static std::shared_ptr<GeomAPI_Shape> makeSymmetry(
203                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
204                      std::shared_ptr<GeomAPI_Ax2> thePlane) throw (GeomAlgoAPI_Exception);
205
206   /// Performs a scale by a scale factor.
207   /// \param theSourceShape Shape be scaled
208   /// \param theCenterPoint Point of scale
209   /// \param theScaleFactor Factor of scale
210   static std::shared_ptr<GeomAPI_Shape> makeScale(
211                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
212                      std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
213                      const double theScaleFactor) throw (GeomAlgoAPI_Exception);
214
215   /// Performs a scale by dimensions.
216   /// \param theSourceShape Shape be scaled
217   /// \param theCenterPoint Point of scale
218   /// \param theScaleFactorX Factor of scale in X
219   /// \param theScaleFactorY Factor of scale in Y
220   /// \param theScaleFactorZ Factor of scale in Z
221   static std::shared_ptr<GeomAPI_Shape> makeScale(
222                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
223                      std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
224                      const double theScaleFactorX,
225                      const double theScaleFactorY,
226                      const double theScaleFactorZ) throw (GeomAlgoAPI_Exception);
227
228   /// Performs a multi translation along one axis, at a distance and a number of times
229   /// \param theSourceShape Shape to be moved
230   /// \param theAxis Movement axis
231   /// \param theStep Movement step
232   /// \param theNumber Movement number
233   /// \return a shape
234   static std::shared_ptr<GeomAPI_Shape> makeMultiTranslation(
235                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
236                      std::shared_ptr<GeomAPI_Ax1> theAxis,
237                      const double theStep,
238                      const int theNumber) throw (GeomAlgoAPI_Exception);
239
240   /// Performs a multi translation along two axis : a different distance on each axis
241   /// and a different number of times for each axis
242   /// \param theSourceShape Shape to be moved
243   /// \param theFirstAxis First movement axis
244   /// \param theFirstStep First movement step
245   /// \param theFirstNumber First movement number
246   /// \param theSecondAxis First movement axis
247   /// \param theSecondStep First movement step
248   /// \param theSecondNumber First movement number
249   /// \return a shape
250   static std::shared_ptr<GeomAPI_Shape> makeMultiTranslation(
251                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
252                      std::shared_ptr<GeomAPI_Ax1> theFirstAxis,
253                      const double theFirstStep,
254                      const int theFirstNumber,
255                      std::shared_ptr<GeomAPI_Ax1> theSecondAxis,
256                      const double theSecondStep,
257                      const int theSecondNumber) throw (GeomAlgoAPI_Exception);
258
259   /// Performs a multi rotation along one axis and a number of times
260   /// \param[in] theSourceShape Shape to be rotated
261   /// \param[in] theAxis Axis for the rotation
262   /// \param[in] theNumber Number of copies
263   static std::shared_ptr<GeomAPI_Shape> makeMultiRotation(
264                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
265                      std::shared_ptr<GeomAPI_Ax1> theAxis,
266                      const int theNumber) throw (GeomAlgoAPI_Exception);
267
268   /// Performs a multi rotation along one axis, at a step and a number of times
269   /// \param theSourceShape Shape to be moved
270   /// \param[in] theAxis Axis for the rotation
271   /// \param[in] theStep Angle for each rotation
272   /// \param[in] theNumber Number of copies
273   static std::shared_ptr<GeomAPI_Shape> makeMultiRotation(
274                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
275                      std::shared_ptr<GeomAPI_Ax1> theAxis,
276                      const double theStep,
277                      const int theNumber) throw (GeomAlgoAPI_Exception);
278
279   /// Creates a cone segment using standard GDML parameters.
280   /// \param theRMin1 Inner radius at base of cone
281   /// \param theRMax1 Outer radius at base of cone
282   /// \param theRMin2 Inner radius at top of cone
283   /// \param theRMax2 Outer radius at top of cone
284   /// \param theZ Height of cone segment
285   /// \param theStartPhi Start angle of the segment
286   /// \param theDeltaPhi Angle of the segment
287   static std::shared_ptr<GeomAPI_Shape> makeConeSegment(
288                      const double theRMin1,
289                      const double theRMax1,
290                      const double theRMin2,
291                      const double theRMax2,
292                      const double theZ,
293                      const double theStartPhi,
294                      const double theDeltaPhi) throw (GeomAlgoAPI_Exception);
295 };
296 }
297 #endif