Salome HOME
Copyright update 2020
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_ShapeAPI.cpp
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 #include "GeomAlgoAPI_ShapeAPI.h"
21
22 #include <GeomAlgoAPI_Box.h>
23 #include <GeomAlgoAPI_CompoundBuilder.h>
24 #include <GeomAlgoAPI_Cone.h>
25 #include <GeomAlgoAPI_ConeSegment.h>
26 #include <GeomAlgoAPI_Cylinder.h>
27 #include <GeomAlgoAPI_EdgeBuilder.h>
28 #include <GeomAlgoAPI_Rotation.h>
29 #include <GeomAlgoAPI_Scale.h>
30 #include <GeomAlgoAPI_Sphere.h>
31 #include <GeomAlgoAPI_Symmetry.h>
32 #include <GeomAlgoAPI_Torus.h>
33 #include <GeomAlgoAPI_Translation.h>
34
35 #include <GeomAPI_Lin.h>
36
37 #include <math.h>
38
39 static GeomShapePtr runAlgo(GeomAlgoAPI_MakeShape& theAlgo)  throw (GeomAlgoAPI_Exception)
40 {
41   if (!theAlgo.check())
42     throw GeomAlgoAPI_Exception(theAlgo.getError());
43
44   theAlgo.build();
45
46   if (!theAlgo.isDone())
47     throw GeomAlgoAPI_Exception(theAlgo.getError());
48
49   return theAlgo.shape();
50 }
51
52 static GeomShapePtr runAlgoAndCheckShape(GeomAlgoAPI_MakeShape& theAlgo, const std::string& theMsg)
53 throw (GeomAlgoAPI_Exception)
54 {
55   if (!theAlgo.check())
56     throw GeomAlgoAPI_Exception(theAlgo.getError());
57
58   theAlgo.build();
59
60   if (!theAlgo.isDone() || !theAlgo.checkValid(theMsg))
61     throw GeomAlgoAPI_Exception(theAlgo.getError());
62
63   return theAlgo.shape();
64 }
65
66 namespace GeomAlgoAPI_ShapeAPI
67 {
68   //===============================================================================================
69   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(
70     const double theDx, const double theDy,
71     const double theDz) throw (GeomAlgoAPI_Exception)
72   {
73     static const std::string aMsg("Box builder with dimensions");
74     GeomAlgoAPI_Box aBoxAlgo(theDx,theDy,theDz);
75     return runAlgoAndCheckShape(aBoxAlgo, aMsg);
76   }
77
78   //===============================================================================================
79   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(
80     std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
81     std::shared_ptr<GeomAPI_Pnt> theSecondPoint) throw (GeomAlgoAPI_Exception)
82   {
83     static const std::string aMsg("Box builder with two points");
84     GeomAlgoAPI_Box aBoxAlgo(theFirstPoint, theSecondPoint);
85     return runAlgoAndCheckShape(aBoxAlgo, aMsg);
86   }
87
88   //===============================================================================================
89   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
90     std::shared_ptr<GeomAPI_Pnt> theBasePoint, std::shared_ptr<GeomAPI_Edge> theEdge,
91     double theRadius, double theHeight) throw (GeomAlgoAPI_Exception)
92   {
93     // Check if the base point is OK
94     if (!theBasePoint) {
95       throw GeomAlgoAPI_Exception("Cylinder builder :: the base point is not valid.");
96     }
97     // Check if the edge is OK
98     if (!theEdge) {
99       throw GeomAlgoAPI_Exception("Cylinder builder :: the axis is not valid.");
100     }
101
102     std::shared_ptr<GeomAPI_Ax2> anAxis;
103     anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
104                                                           theEdge->line()->direction()));
105
106     GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight);
107
108     static const std::string aMsg("Cylinder builder");
109     return runAlgoAndCheckShape(aCylinderAlgo, aMsg);
110   }
111
112   //===============================================================================================
113   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
114     std::shared_ptr<GeomAPI_Pnt> theBasePoint, std::shared_ptr<GeomAPI_Edge> theEdge,
115     double theRadius, double theHeight, double theAngle) throw (GeomAlgoAPI_Exception)
116   {
117     // Check if the base point is OK
118     if (!theBasePoint) {
119       throw GeomAlgoAPI_Exception("Cylinder builder :: the base point is not valid.");
120     }
121     // Check if the edge is OK
122     if (!theEdge) {
123       throw GeomAlgoAPI_Exception("Cylinder builder :: the axis is not valid.");
124     }
125
126     std::shared_ptr<GeomAPI_Ax2> anAxis;
127     anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
128                                                           theEdge->line()->direction()));
129
130     GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight, theAngle);
131
132     static const std::string aMsg("Cylinder portion builder");
133     return runAlgoAndCheckShape(aCylinderAlgo, aMsg);
134   }
135
136   //===============================================================================================
137   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
138     double theRadius, double theHeight) throw (GeomAlgoAPI_Exception)
139   {
140     std::shared_ptr<GeomAPI_Pnt> aBasePoint =
141       std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
142     std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
143     std::shared_ptr<GeomAPI_Ax2> anAxis;
144     anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
145                                                           aEdge->line()->direction()));
146
147     GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight);
148
149     static const std::string aMsg("Cylinder builder");
150     return runAlgoAndCheckShape(aCylinderAlgo, aMsg);
151   }
152
153   //===============================================================================================
154   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
155     double theRadius, double theHeight, double theAngle) throw (GeomAlgoAPI_Exception)
156   {
157     std::shared_ptr<GeomAPI_Pnt> aBasePoint =
158       std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
159     std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
160     std::shared_ptr<GeomAPI_Ax2> anAxis;
161     anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
162                                                           aEdge->line()->direction()));
163
164     GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight, theAngle);
165
166     static const std::string aMsg("Cylinder portion builder");
167     return runAlgoAndCheckShape(aCylinderAlgo, aMsg);
168   }
169
170   //===============================================================================================
171   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSphere(
172       std::shared_ptr<GeomAPI_Pnt> theCenterPoint, double theRadius) throw (GeomAlgoAPI_Exception)
173   {
174     static const std::string aMsg("Sphere builder");
175     GeomAlgoAPI_Sphere aSphereAlgo(theCenterPoint, theRadius);
176     return runAlgoAndCheckShape(aSphereAlgo, aMsg);
177   }
178
179   //===============================================================================================
180   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSphere(double theRadius)
181       throw (GeomAlgoAPI_Exception)
182   {
183     std::shared_ptr<GeomAPI_Pnt> aCenterPoint =
184       std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
185
186     GeomAlgoAPI_Sphere aSphereAlgo(aCenterPoint, theRadius);
187
188     static const std::string aMsg("Sphere builder");
189     return runAlgoAndCheckShape(aSphereAlgo, aMsg);
190   }
191
192   //===============================================================================================
193   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTorus(
194       std::shared_ptr<GeomAPI_Pnt> theBasePoint,
195       std::shared_ptr<GeomAPI_Edge> theEdge,double theRadius, double theRingRadius)
196       throw (GeomAlgoAPI_Exception)
197   {
198     // Check if the base point is OK
199     if (!theBasePoint) {
200       throw GeomAlgoAPI_Exception("Torus builder :: the base point is not valid.");
201     }
202     // Check if the edge is OK
203     if (!theEdge) {
204       throw GeomAlgoAPI_Exception("Torus builder :: the axis is not valid.");
205     }
206
207     std::shared_ptr<GeomAPI_Ax2> anAxis;
208     anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
209                                                           theEdge->line()->direction()));
210
211     GeomAlgoAPI_Torus aTorusAlgo(anAxis, theRadius, theRingRadius);
212
213     static const std::string aMsg("Torus builder");
214     return runAlgoAndCheckShape(aTorusAlgo, aMsg);
215   }
216
217   //===============================================================================================
218   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTorus(double theRadius,
219       double theRingRadius) throw (GeomAlgoAPI_Exception)
220   {
221     std::shared_ptr<GeomAPI_Pnt> aBasePoint =
222       std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
223     std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
224     std::shared_ptr<GeomAPI_Ax2> anAxis;
225     anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
226                                                           aEdge->line()->direction()));
227
228     GeomAlgoAPI_Torus aTorusAlgo(anAxis, theRadius, theRingRadius);
229
230     static const std::string aMsg("Torus builder");
231     return runAlgoAndCheckShape(aTorusAlgo, aMsg);
232   }
233
234   //===============================================================================================
235   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCone(
236       std::shared_ptr<GeomAPI_Pnt> theBasePoint,
237       std::shared_ptr<GeomAPI_Edge> theEdge,
238       double theBaseRadius, double theTopRadius,
239       double theHeight) throw (GeomAlgoAPI_Exception)
240   {
241     // Check if the base point is OK
242     if (!theBasePoint) {
243       throw GeomAlgoAPI_Exception("Cone builder :: the base point is not valid.");
244     }
245     // Check if the edge is OK
246     if (!theEdge) {
247       throw GeomAlgoAPI_Exception("Cone builder :: the axis is not valid.");
248     }
249
250     std::shared_ptr<GeomAPI_Ax2> anAxis;
251     anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
252                                                           theEdge->line()->direction()));
253
254     GeomAlgoAPI_Cone aConeAlgo(anAxis, theBaseRadius, theTopRadius, theHeight);
255
256     static const std::string aMsg("Cone builder");
257     return runAlgoAndCheckShape(aConeAlgo, aMsg);
258   }
259
260   //===============================================================================================
261   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCone(
262       double theBaseRadius, double theTopRadius,
263       double theHeight) throw (GeomAlgoAPI_Exception)
264   {
265     std::shared_ptr<GeomAPI_Pnt> aBasePoint =
266       std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
267     std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
268     std::shared_ptr<GeomAPI_Ax2> anAxis;
269     anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
270                                                           aEdge->line()->direction()));
271
272     GeomAlgoAPI_Cone aConeAlgo(anAxis, theBaseRadius, theTopRadius, theHeight);
273
274     static const std::string aMsg("Cone builder");
275     return runAlgoAndCheckShape(aConeAlgo, aMsg);
276   }
277
278   //===============================================================================================
279   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
280     std::shared_ptr<GeomAPI_Shape> theSourceShape,
281     std::shared_ptr<GeomAPI_Ax1>   theAxis,
282     const double theDistance) throw (GeomAlgoAPI_Exception)
283   {
284     GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theAxis, theDistance);
285     return runAlgo(aTranslationAlgo);
286   }
287
288   //===============================================================================================
289   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
290     std::shared_ptr<GeomAPI_Shape> theSourceShape,
291     const double theDx,
292     const double theDy,
293     const double theDz) throw (GeomAlgoAPI_Exception)
294   {
295     GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theDx, theDy, theDz);
296     return runAlgo(aTranslationAlgo);
297   }
298
299   //===============================================================================================
300   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
301     std::shared_ptr<GeomAPI_Shape> theSourceShape,
302     std::shared_ptr<GeomAPI_Pnt>   theStartPoint,
303     std::shared_ptr<GeomAPI_Pnt>   theEndPoint) throw (GeomAlgoAPI_Exception)
304   {
305     GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theStartPoint, theEndPoint);
306     return runAlgo(aTranslationAlgo);
307   }
308
309   //===============================================================================================
310   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeRotation(
311     std::shared_ptr<GeomAPI_Shape> theSourceShape,
312     std::shared_ptr<GeomAPI_Ax1> theAxis,
313     const double theAngle) throw (GeomAlgoAPI_Exception)
314   {
315     GeomAlgoAPI_Rotation aRotationAlgo(theSourceShape, theAxis, theAngle);
316     return runAlgo(aRotationAlgo);
317   }
318
319   //===============================================================================================
320   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeRotation(
321     std::shared_ptr<GeomAPI_Shape> theSourceShape,
322     std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
323     std::shared_ptr<GeomAPI_Pnt> theStartPoint,
324     std::shared_ptr<GeomAPI_Pnt> theEndPoint) throw (GeomAlgoAPI_Exception)
325   {
326     GeomAlgoAPI_Rotation aRotationAlgo(theSourceShape, theCenterPoint, theStartPoint, theEndPoint);
327     return runAlgo(aRotationAlgo);
328   }
329
330   //===============================================================================================
331   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
332     std::shared_ptr<GeomAPI_Shape> theSourceShape,
333     std::shared_ptr<GeomAPI_Pnt>   thePoint) throw (GeomAlgoAPI_Exception)
334   {
335     GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, thePoint);
336     return runAlgo(aSymmetryAlgo);
337   }
338
339   //===============================================================================================
340   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
341     std::shared_ptr<GeomAPI_Shape> theSourceShape,
342     std::shared_ptr<GeomAPI_Ax1>   theAxis) throw (GeomAlgoAPI_Exception)
343   {
344     GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, theAxis);
345     return runAlgo(aSymmetryAlgo);
346   }
347
348   //===============================================================================================
349   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
350     std::shared_ptr<GeomAPI_Shape> theSourceShape,
351     std::shared_ptr<GeomAPI_Ax2>   thePlane) throw (GeomAlgoAPI_Exception)
352   {
353     GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, thePlane);
354     return runAlgo(aSymmetryAlgo);
355   }
356
357   //===============================================================================================
358   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeScale(
359     std::shared_ptr<GeomAPI_Shape> theSourceShape,
360     std::shared_ptr<GeomAPI_Pnt>   theCenterPoint,
361     const double                   theScaleFactor) throw (GeomAlgoAPI_Exception)
362   {
363     GeomAlgoAPI_Scale aScaleAlgo(theSourceShape, theCenterPoint, theScaleFactor);
364     return runAlgo(aScaleAlgo);
365   }
366
367   //===============================================================================================
368   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeScale(
369     std::shared_ptr<GeomAPI_Shape> theSourceShape,
370     std::shared_ptr<GeomAPI_Pnt>   theCenterPoint,
371     const double                   theScaleFactorX,
372     const double                   theScaleFactorY,
373     const double                   theScaleFactorZ) throw (GeomAlgoAPI_Exception)
374   {
375     GeomAlgoAPI_Scale aScaleAlgo(theSourceShape, theCenterPoint,
376                                  theScaleFactorX, theScaleFactorY, theScaleFactorZ);
377     return runAlgo(aScaleAlgo);
378   }
379
380   //===============================================================================================
381   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeMultiTranslation(
382     std::shared_ptr<GeomAPI_Shape> theSourceShape,
383     std::shared_ptr<GeomAPI_Ax1> theAxis,
384     const double theStep,
385     const int theNumber) throw (GeomAlgoAPI_Exception)
386   {
387     if (!theAxis) {
388       std::string aError = "Multitranslation builder ";
389       aError+=":: the first axis is not valid";
390       throw GeomAlgoAPI_Exception(aError);
391     }
392
393     if (theNumber <=0) {
394       std::string aError = "Multitranslation builder ";
395       aError+=":: the number of copies for the first direction is null or negative.";
396       throw GeomAlgoAPI_Exception(aError);
397     }
398
399     ListOfShape aListOfShape;
400     for (int i=0; i<theNumber; i++) {
401       aListOfShape.
402         push_back(GeomAlgoAPI_ShapeAPI::makeTranslation(theSourceShape, theAxis, i*theStep));
403     }
404     return GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
405   }
406
407   //===============================================================================================
408   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeMultiTranslation(
409     std::shared_ptr<GeomAPI_Shape> theSourceShape,
410     std::shared_ptr<GeomAPI_Ax1> theFirstAxis,
411     const double theFirstStep,
412     const int theFirstNumber,
413     std::shared_ptr<GeomAPI_Ax1> theSecondAxis,
414     const double theSecondStep,
415     const int theSecondNumber) throw (GeomAlgoAPI_Exception)
416   {
417     if (!theFirstAxis) {
418       std::string aError = "Multitranslation builder ";
419       aError+=":: the first axis is not valid";
420       throw GeomAlgoAPI_Exception(aError);
421     }
422
423     if (!theSecondAxis) {
424       std::string aError = "Multitranslation builder ";
425       aError+=":: the second axis is not valid";
426       throw GeomAlgoAPI_Exception(aError);
427     }
428
429     if (theFirstNumber <=0) {
430       std::string aError = "Multitranslation builder ";
431       aError+=":: the number of copies for the first direction is null or negative.";
432       throw GeomAlgoAPI_Exception(aError);
433     }
434
435     if (theSecondNumber <=0) {
436       std::string aError = "Multitranslation builder ";
437       aError+=":: the number of copies for the second direction is null or negative.";
438       throw GeomAlgoAPI_Exception(aError);
439     }
440
441     // Coord theFirstAxis
442     double x1 = theFirstAxis->dir()->x();
443     double y1 = theFirstAxis->dir()->y();
444     double z1 = theFirstAxis->dir()->z();
445     double norm1 = sqrt(x1*x1 + y1*y1 + z1*z1);
446
447     // Coord theSecondAxis
448     double x2 = theSecondAxis->dir()->x();
449     double y2 = theSecondAxis->dir()->y();
450     double z2 = theSecondAxis->dir()->z();
451     double norm2 = sqrt(x2*x2 + y2*y2 + z2*z2);
452
453     ListOfShape aListOfShape;
454     for (int j=0; j<theSecondStep; j++) {
455       for (int i=0; i<theFirstNumber; i++) {
456         double dx = i*theFirstStep*x1/norm1+j*theSecondStep*x2/norm2;
457         double dy = i*theFirstStep*y1/norm1+j*theSecondStep*y2/norm2;
458         double dz = i*theFirstStep*z1/norm1+j*theSecondStep*z2/norm2;
459         aListOfShape.push_back(GeomAlgoAPI_ShapeAPI::makeTranslation(theSourceShape, dx, dy, dz));
460       }
461     }
462     return GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
463   }
464
465   //===============================================================================================
466   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeMultiRotation(
467     std::shared_ptr<GeomAPI_Shape> theSourceShape,
468     std::shared_ptr<GeomAPI_Ax1> theAxis,
469     const int theNumber) throw (GeomAlgoAPI_Exception)
470   {
471     if (!theAxis) {
472       std::string aError = "Multirotation builder ";
473       aError+=":: the axis is not valid";
474       throw GeomAlgoAPI_Exception(aError);
475     }
476
477     if (theNumber <=0) {
478       std::string aError = "Multirotation builder ";
479       aError+=":: the number of copies is null or negative.";
480       throw GeomAlgoAPI_Exception(aError);
481     }
482
483     double anAngle = 360./theNumber;
484
485     ListOfShape aListOfShape;
486     for (int i=0; i<theNumber; i++) {
487       aListOfShape.
488         push_back(GeomAlgoAPI_ShapeAPI::makeRotation(theSourceShape, theAxis, i*anAngle));
489     }
490     return GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
491   }
492
493   //===============================================================================================
494   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeMultiRotation(
495     std::shared_ptr<GeomAPI_Shape> theSourceShape,
496     std::shared_ptr<GeomAPI_Ax1> theAxis,
497     const double theStep,
498     const int theNumber) throw (GeomAlgoAPI_Exception)
499   {
500     if (!theAxis) {
501       std::string aError = "Multirotation builder ";
502       aError+=":: the axis is not valid";
503       throw GeomAlgoAPI_Exception(aError);
504     }
505
506     if (theNumber <=0) {
507       std::string aError = "Multirotation builder ";
508       aError+=":: the number of copies is null or negative.";
509       throw GeomAlgoAPI_Exception(aError);
510     }
511
512     ListOfShape aListOfShape;
513     for (int i=0; i<theNumber; i++) {
514       aListOfShape.
515         push_back(GeomAlgoAPI_ShapeAPI::makeRotation(theSourceShape, theAxis, i*theStep));
516     }
517     return GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
518   }
519
520   //===============================================================================================
521   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeConeSegment(
522     const double theRMin1, const double theRMax1,
523     const double theRMin2, const double theRMax2,
524     const double theZ,
525     const double theStartPhi, const double theDeltaPhi) throw (GeomAlgoAPI_Exception)
526   {
527     GeomAlgoAPI_ConeSegment aConeSegmentAlgo(theRMin1, theRMax1, theRMin2, theRMax2,
528                                              theZ, theStartPhi, theDeltaPhi);
529
530     static const std::string aMsg("Cone Segment builder");
531     return runAlgoAndCheckShape(aConeSegmentAlgo, aMsg);
532   }
533 }