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