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 GEOMALGOAPI_SHAPEAPI_H
21 #define GEOMALGOAPI_SHAPEAPI_H
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>
29 #include <GeomAlgoAPI_Exception.h>
32 #pragma warning(disable : 4290)
35 namespace GeomAlgoAPI_ShapeAPI
37 /**\class GeomAlgoAPI_ShapeAPI
39 * \brief Allows to access the direct API
41 class GEOMALGOAPI_EXPORT GeomAlgoAPI_ShapeAPI
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
49 static std::shared_ptr<GeomAPI_Shape> makeBox(const double theDx, const double theDy,
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
56 static std::shared_ptr<GeomAPI_Shape> makeBox(std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
57 std::shared_ptr<GeomAPI_Pnt> theSecondPoint);
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);
67 /// Creates a portion of cylinder using a center, an axis, a radius, a height and an angle.
68 /// \param theBasePoint The center of the lower base of the cylinder
69 /// \param theEdge The axis of the cylinder
70 /// \param theRadius The radius of the cylinder
71 /// \param theHeight The heigth of the cylinder
72 /// \param theAngle The angle defining the portion
73 static std::shared_ptr<GeomAPI_Shape> makeCylinder(std::shared_ptr<GeomAPI_Pnt> theBasePoint,
74 std::shared_ptr<GeomAPI_Edge> theEdge, double theRadius, double theHeight,
77 /// Creates a cylinder using the origin, the OZ axis, a radius and a height.
78 /// \param theRadius The radius of the cylinder
79 /// \param theHeight The heigth of the cylinder
80 static std::shared_ptr<GeomAPI_Shape> makeCylinder(double theRadius, double theHeight);
82 /// Creates a portion of cylinder using the origin, the OZ axis, a radius, a height and an angle.
83 /// \param theRadius The radius of the cylinder
84 /// \param theHeight The heigth of the cylinder
85 /// \param theAngle The angle defining the portion
86 static std::shared_ptr<GeomAPI_Shape> makeCylinder(double theRadius, double theHeight,
89 /// Creates a sphere using a center and a radius.
90 /// \param theCenterPoint The center of the sphere
91 /// \param theRadius The radius of the sphere
92 static std::shared_ptr<GeomAPI_Shape> makeSphere(std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
95 /// Creates a sphere using the origin and a radius.
96 /// \param theRadius The radius of the sphere
97 static std::shared_ptr<GeomAPI_Shape> makeSphere(double theRadius);
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);
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);
112 /// Creates a cone using a base point, an axis, a base radius, a top radius and a height.
113 /// \param theBasePoint The center of the lower base of the cone
114 /// \param theEdge The axis of the cone
115 /// \param theBaseRadius The base radius of the cone
116 /// \param theTopRadius The top radius of the cone
117 /// \param theHeight The height of the cone
118 static std::shared_ptr<GeomAPI_Shape> makeCone(std::shared_ptr<GeomAPI_Pnt> theBasePoint,
119 std::shared_ptr<GeomAPI_Edge> theEdge, double theBaseRadius,
120 double theTopRadius, double theHeight);
122 /// Creates a cone using a base radius, a top radius and a height.
123 /// \param theBaseRadius The base radius of the cone
124 /// \param theTopRadius The top radius of the cone
125 /// \param theHeight The height of the cone
126 static std::shared_ptr<GeomAPI_Shape> makeCone(double theBaseRadius, double theTopRadius,
129 /// Performs a translation from an axis and a distance.
130 /// \param theSourceShape Shape to be moved
131 /// \param theAxis Movement axis
132 /// \param theDistance Movement distance
134 static std::shared_ptr<GeomAPI_Shape> makeTranslation(
135 std::shared_ptr<GeomAPI_Shape> theSourceShape,
136 std::shared_ptr<GeomAPI_Ax1> theAxis,
137 const double theDistance);
139 /// Performs a translation from dimensions.
140 /// \param theSourceShape Shape to be moved
141 /// \param theDx Movement dimension on X
142 /// \param theDy Movement dimension on Y
143 /// \param theDz Movement dimension on Z
145 static std::shared_ptr<GeomAPI_Shape> makeTranslation(
146 std::shared_ptr<GeomAPI_Shape> theSourceShape,
151 /// Performs a translation from two points.
152 /// \param theSourceShape Shape to be moved
153 /// \param theStartPoint Movement start point
154 /// \param theEndPoint Movement end point
156 static std::shared_ptr<GeomAPI_Shape> makeTranslation(
157 std::shared_ptr<GeomAPI_Shape> theSourceShape,
158 std::shared_ptr<GeomAPI_Pnt> theStartPoint,
159 std::shared_ptr<GeomAPI_Pnt> theEndPoint);
161 /// Performs a rotation from an axis and an angle.
162 /// \param theSourceShape Shape to be rotated
163 /// \param theAxis Movement axis
164 /// \param theAngle Movement angle
166 static std::shared_ptr<GeomAPI_Shape> makeRotation(
167 std::shared_ptr<GeomAPI_Shape> theSourceShape,
168 std::shared_ptr<GeomAPI_Ax1> theAxis,
169 const double theAngle);
171 /// Performs a rotation from three points.
172 /// \param theSourceShape Shape to be rotated
173 /// \param theCenterPoint Movement center point
174 /// \param theStartPoint Movement start point
175 /// \param theEndPoint Movement end point
177 static std::shared_ptr<GeomAPI_Shape> makeRotation(
178 std::shared_ptr<GeomAPI_Shape> theSourceShape,
179 std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
180 std::shared_ptr<GeomAPI_Pnt> theStartPoint,
181 std::shared_ptr<GeomAPI_Pnt> theEndPoint);
183 /// Performs a symmetry by a point.
184 /// \param theSourceShape Shape be symmetrized
185 /// \param thePoint Point of symmetry
186 static std::shared_ptr<GeomAPI_Shape> makeSymmetry(
187 std::shared_ptr<GeomAPI_Shape> theSourceShape,
188 std::shared_ptr<GeomAPI_Pnt> thePoint);
190 /// Performs a symmetry by an axis.
191 /// \param theSourceShape Shape be symmetrized
192 /// \param theAxis Axis of symmetry
193 static std::shared_ptr<GeomAPI_Shape> makeSymmetry(
194 std::shared_ptr<GeomAPI_Shape> theSourceShape,
195 std::shared_ptr<GeomAPI_Ax1> theAxis);
197 /// Performs a symmetry by a plane.
198 /// \param theSourceShape Shape be symmetrized
199 /// \param thePlane Plane of symmetry
200 static std::shared_ptr<GeomAPI_Shape> makeSymmetry(
201 std::shared_ptr<GeomAPI_Shape> theSourceShape,
202 std::shared_ptr<GeomAPI_Ax2> thePlane);
204 /// Performs a scale by a scale factor.
205 /// \param theSourceShape Shape be scaled
206 /// \param theCenterPoint Point of scale
207 /// \param theScaleFactor Factor of scale
208 static std::shared_ptr<GeomAPI_Shape> makeScale(
209 std::shared_ptr<GeomAPI_Shape> theSourceShape,
210 std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
211 const double theScaleFactor);
213 /// Performs a scale by dimensions.
214 /// \param theSourceShape Shape be scaled
215 /// \param theCenterPoint Point of scale
216 /// \param theScaleFactorX Factor of scale in X
217 /// \param theScaleFactorY Factor of scale in Y
218 /// \param theScaleFactorZ Factor of scale in Z
219 static std::shared_ptr<GeomAPI_Shape> makeScale(
220 std::shared_ptr<GeomAPI_Shape> theSourceShape,
221 std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
222 const double theScaleFactorX,
223 const double theScaleFactorY,
224 const double theScaleFactorZ);
226 /// Performs a multi translation along one axis, at a distance and a number of times
227 /// \param theSourceShape Shape to be moved
228 /// \param theAxis Movement axis
229 /// \param theStep Movement step
230 /// \param theNumber Movement number
232 static std::shared_ptr<GeomAPI_Shape> makeMultiTranslation(
233 std::shared_ptr<GeomAPI_Shape> theSourceShape,
234 std::shared_ptr<GeomAPI_Ax1> theAxis,
235 const double theStep,
236 const int theNumber);
238 /// Performs a multi translation along two axis : a different distance on each axis
239 /// and a different number of times for each axis
240 /// \param theSourceShape Shape to be moved
241 /// \param theFirstAxis First movement axis
242 /// \param theFirstStep First movement step
243 /// \param theFirstNumber First movement number
244 /// \param theSecondAxis First movement axis
245 /// \param theSecondStep First movement step
246 /// \param theSecondNumber First movement number
248 static std::shared_ptr<GeomAPI_Shape> makeMultiTranslation(
249 std::shared_ptr<GeomAPI_Shape> theSourceShape,
250 std::shared_ptr<GeomAPI_Ax1> theFirstAxis,
251 const double theFirstStep,
252 const int theFirstNumber,
253 std::shared_ptr<GeomAPI_Ax1> theSecondAxis,
254 const double theSecondStep,
255 const int theSecondNumber);
257 /// Performs a multi rotation along one axis and a number of times
258 /// \param[in] theSourceShape Shape to be rotated
259 /// \param[in] theAxis Axis for the rotation
260 /// \param[in] theNumber Number of copies
261 static std::shared_ptr<GeomAPI_Shape> makeMultiRotation(
262 std::shared_ptr<GeomAPI_Shape> theSourceShape,
263 std::shared_ptr<GeomAPI_Ax1> theAxis,
264 const int theNumber);
266 /// Performs a multi rotation along one axis, at a step and a number of times
267 /// \param theSourceShape Shape to be moved
268 /// \param[in] theAxis Axis for the rotation
269 /// \param[in] theStep Angle for each rotation
270 /// \param[in] theNumber Number of copies
271 static std::shared_ptr<GeomAPI_Shape> makeMultiRotation(
272 std::shared_ptr<GeomAPI_Shape> theSourceShape,
273 std::shared_ptr<GeomAPI_Ax1> theAxis,
274 const double theStep,
275 const int theNumber);
277 /// Creates a cone segment using standard GDML parameters.
278 /// \param theRMin1 Inner radius at base of cone
279 /// \param theRMax1 Outer radius at base of cone
280 /// \param theRMin2 Inner radius at top of cone
281 /// \param theRMax2 Outer radius at top of cone
282 /// \param theZ Height of cone segment
283 /// \param theStartPhi Start angle of the segment
284 /// \param theDeltaPhi Angle of the segment
285 static std::shared_ptr<GeomAPI_Shape> makeConeSegment(
286 const double theRMin1,
287 const double theRMax1,
288 const double theRMin2,
289 const double theRMax2,
291 const double theStartPhi,
292 const double theDeltaPhi);