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