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