Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_ShapeAPI.cpp
1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D
2
3 // File:        GeomAlgoAPI_ShapeAPI.cpp
4 // Created:     17 Mar 2016
5 // Author:      Clarisse Genrault (CEA)
6
7 #include "GeomAlgoAPI_ShapeAPI.h"
8
9 #include <GeomAlgoAPI_Box.h>
10 #include <GeomAlgoAPI_CompoundBuilder.h>
11 #include <GeomAlgoAPI_Cone.h>
12 #include <GeomAlgoAPI_ConeSegment.h>
13 #include <GeomAlgoAPI_Cylinder.h>
14 #include <GeomAlgoAPI_EdgeBuilder.h>
15 #include <GeomAlgoAPI_Rotation.h>
16 #include <GeomAlgoAPI_Scale.h>
17 #include <GeomAlgoAPI_Sphere.h>
18 #include <GeomAlgoAPI_Symmetry.h>
19 #include <GeomAlgoAPI_Torus.h>
20 #include <GeomAlgoAPI_Translation.h>
21
22 #include <GeomAPI_Lin.h>
23
24 #include <math.h>
25
26 namespace GeomAlgoAPI_ShapeAPI
27 {
28   //===============================================================================================
29   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(
30     const double theDx, const double theDy,
31     const double theDz) throw (GeomAlgoAPI_Exception)
32   {
33     GeomAlgoAPI_Box aBoxAlgo(theDx,theDy,theDz);
34
35     if (!aBoxAlgo.check()) {
36       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
37     }
38
39     aBoxAlgo.build();
40
41     if(!aBoxAlgo.isDone()) {
42       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
43     }
44     if (!aBoxAlgo.checkValid("Box builder with dimensions")) {
45       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
46     }
47     return aBoxAlgo.shape();
48   }
49
50   //===============================================================================================
51   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(
52     std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
53     std::shared_ptr<GeomAPI_Pnt> theSecondPoint) throw (GeomAlgoAPI_Exception)
54   {
55     GeomAlgoAPI_Box aBoxAlgo(theFirstPoint, theSecondPoint);
56
57     if (!aBoxAlgo.check()) {
58       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
59     }
60
61     aBoxAlgo.build();
62
63     if(!aBoxAlgo.isDone()) {
64       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
65     }
66     if (!aBoxAlgo.checkValid("Box builder with two points")) {
67       throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
68     }
69     return aBoxAlgo.shape();
70   }
71
72   //===============================================================================================
73   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
74     std::shared_ptr<GeomAPI_Pnt> theBasePoint, std::shared_ptr<GeomAPI_Edge> theEdge,
75     double theRadius, double theHeight) throw (GeomAlgoAPI_Exception)
76   {
77     // Check if the base point is OK
78     if (!theBasePoint) {
79       throw GeomAlgoAPI_Exception("Cylinder builder :: the base point is not valid.");
80     }
81     // Check if the edge is OK
82     if (!theEdge) {
83       throw GeomAlgoAPI_Exception("Cylinder builder :: the axis is not valid.");
84     }
85
86     std::shared_ptr<GeomAPI_Ax2> anAxis;
87     anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
88                                                           theEdge->line()->direction()));
89
90     GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight);
91
92     if (!aCylinderAlgo.check()) {
93       throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
94     }
95
96     aCylinderAlgo.build();
97
98     if(!aCylinderAlgo.isDone()) {
99       throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
100     }
101     if (!aCylinderAlgo.checkValid("Cylinder builder")) {
102       throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
103     }
104     return aCylinderAlgo.shape();
105   }
106
107   //===============================================================================================
108   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
109     std::shared_ptr<GeomAPI_Pnt> theBasePoint, std::shared_ptr<GeomAPI_Edge> theEdge,
110     double theRadius, double theHeight, double theAngle) throw (GeomAlgoAPI_Exception)
111   {
112     // Check if the base point is OK
113     if (!theBasePoint) {
114       throw GeomAlgoAPI_Exception("Cylinder builder :: the base point is not valid.");
115     }
116     // Check if the edge is OK
117     if (!theEdge) {
118       throw GeomAlgoAPI_Exception("Cylinder builder :: the axis is not valid.");
119     }
120
121     std::shared_ptr<GeomAPI_Ax2> anAxis;
122     anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
123                                                           theEdge->line()->direction()));
124
125     GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight, theAngle);
126
127     if (!aCylinderAlgo.check()) {
128       throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
129     }
130
131     aCylinderAlgo.build();
132
133     if(!aCylinderAlgo.isDone()) {
134       throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
135     }
136     if (!aCylinderAlgo.checkValid("Cylinder portion builder")) {
137       throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
138     }
139     return aCylinderAlgo.shape();
140   }
141
142   //===============================================================================================
143   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
144     double theRadius, double theHeight) throw (GeomAlgoAPI_Exception)
145   {
146     std::shared_ptr<GeomAPI_Pnt> aBasePoint =
147       std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
148     std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
149     std::shared_ptr<GeomAPI_Ax2> anAxis;
150     anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
151                                                           aEdge->line()->direction()));
152
153     GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight);
154
155     if (!aCylinderAlgo.check()) {
156       throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
157     }
158
159     aCylinderAlgo.build();
160
161     if(!aCylinderAlgo.isDone()) {
162       throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
163     }
164     if (!aCylinderAlgo.checkValid("Cylinder builder")) {
165       throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
166     }
167     return aCylinderAlgo.shape();
168   }
169
170   //===============================================================================================
171   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
172     double theRadius, double theHeight, double theAngle) throw (GeomAlgoAPI_Exception)
173   {
174     std::shared_ptr<GeomAPI_Pnt> aBasePoint =
175       std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
176     std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
177     std::shared_ptr<GeomAPI_Ax2> anAxis;
178     anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
179                                                           aEdge->line()->direction()));
180
181     GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight, theAngle);
182
183     if (!aCylinderAlgo.check()) {
184       throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
185     }
186
187     aCylinderAlgo.build();
188
189     if(!aCylinderAlgo.isDone()) {
190       throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
191     }
192     if (!aCylinderAlgo.checkValid("Cylinder portion builder")) {
193       throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
194     }
195     return aCylinderAlgo.shape();
196   }
197
198   //===============================================================================================
199   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSphere(
200       std::shared_ptr<GeomAPI_Pnt> theCenterPoint, double theRadius) throw (GeomAlgoAPI_Exception)
201   {
202     GeomAlgoAPI_Sphere aSphereAlgo(theCenterPoint, theRadius);
203
204     if (!aSphereAlgo.check()) {
205       throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
206     }
207
208     aSphereAlgo.build();
209
210     if(!aSphereAlgo.isDone()) {
211       throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
212     }
213
214     if (!aSphereAlgo.checkValid("Sphere builder")) {
215       throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
216     }
217     return aSphereAlgo.shape();
218   }
219
220   //===============================================================================================
221   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSphere(double theRadius)
222       throw (GeomAlgoAPI_Exception)
223   {
224     std::shared_ptr<GeomAPI_Pnt> aCenterPoint =
225       std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
226
227     GeomAlgoAPI_Sphere aSphereAlgo(aCenterPoint, theRadius);
228
229     if (!aSphereAlgo.check()) {
230       throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
231     }
232
233     aSphereAlgo.build();
234
235     if(!aSphereAlgo.isDone()) {
236       throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
237     }
238
239     if (!aSphereAlgo.checkValid("Sphere builder")) {
240       throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
241     }
242     return aSphereAlgo.shape();
243   }
244
245   //===============================================================================================
246   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTorus(
247       std::shared_ptr<GeomAPI_Pnt> theBasePoint,
248       std::shared_ptr<GeomAPI_Edge> theEdge,double theRadius, double theRingRadius)
249       throw (GeomAlgoAPI_Exception)
250   {
251     // Check if the base point is OK
252     if (!theBasePoint) {
253       throw GeomAlgoAPI_Exception("Torus builder :: the base point is not valid.");
254     }
255     // Check if the edge is OK
256     if (!theEdge) {
257       throw GeomAlgoAPI_Exception("Torus builder :: the axis is not valid.");
258     }
259
260     std::shared_ptr<GeomAPI_Ax2> anAxis;
261     anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
262                                                           theEdge->line()->direction()));
263
264     GeomAlgoAPI_Torus aTorusAlgo(anAxis, theRadius, theRingRadius);
265
266     if (!aTorusAlgo.check()) {
267       throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
268     }
269
270     aTorusAlgo.build();
271
272     if(!aTorusAlgo.isDone()) {
273       throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
274     }
275
276     if (!aTorusAlgo.checkValid("Torus builder")) {
277       throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
278     }
279     return aTorusAlgo.shape();
280   }
281
282   //===============================================================================================
283   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTorus(double theRadius,
284       double theRingRadius) throw (GeomAlgoAPI_Exception)
285   {
286     std::shared_ptr<GeomAPI_Pnt> aBasePoint =
287       std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
288     std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
289     std::shared_ptr<GeomAPI_Ax2> anAxis;
290     anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
291                                                           aEdge->line()->direction()));
292
293     GeomAlgoAPI_Torus aTorusAlgo(anAxis, theRadius, theRingRadius);
294
295     if (!aTorusAlgo.check()) {
296       throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
297     }
298
299     aTorusAlgo.build();
300
301     if(!aTorusAlgo.isDone()) {
302       throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
303     }
304
305     if (!aTorusAlgo.checkValid("Torus builder")) {
306       throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
307     }
308     return aTorusAlgo.shape();
309   }
310
311   //===============================================================================================
312   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCone(
313       std::shared_ptr<GeomAPI_Pnt> theBasePoint,
314       std::shared_ptr<GeomAPI_Edge> theEdge,
315       double theBaseRadius, double theTopRadius,
316       double theHeight) throw (GeomAlgoAPI_Exception)
317   {
318     // Check if the base point is OK
319     if (!theBasePoint) {
320       throw GeomAlgoAPI_Exception("Cone builder :: the base point is not valid.");
321     }
322     // Check if the edge is OK
323     if (!theEdge) {
324       throw GeomAlgoAPI_Exception("Cone builder :: the axis is not valid.");
325     }
326
327     std::shared_ptr<GeomAPI_Ax2> anAxis;
328     anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
329                                                           theEdge->line()->direction()));
330
331     GeomAlgoAPI_Cone aConeAlgo(anAxis, theBaseRadius, theTopRadius, theHeight);
332
333     if (!aConeAlgo.check()) {
334       throw GeomAlgoAPI_Exception(aConeAlgo.getError());
335     }
336
337     aConeAlgo.build();
338
339     if(!aConeAlgo.isDone()) {
340       throw GeomAlgoAPI_Exception(aConeAlgo.getError());
341     }
342
343     if (!aConeAlgo.checkValid("Cone builder")) {
344       throw GeomAlgoAPI_Exception(aConeAlgo.getError());
345     }
346     return aConeAlgo.shape();
347   }
348
349   //===============================================================================================
350   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCone(
351       double theBaseRadius, double theTopRadius,
352       double theHeight) throw (GeomAlgoAPI_Exception)
353   {
354     std::shared_ptr<GeomAPI_Pnt> aBasePoint =
355       std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
356     std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
357     std::shared_ptr<GeomAPI_Ax2> anAxis;
358     anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
359                                                           aEdge->line()->direction()));
360
361     GeomAlgoAPI_Cone aConeAlgo(anAxis, theBaseRadius, theTopRadius, theHeight);
362
363     if (!aConeAlgo.check()) {
364       throw GeomAlgoAPI_Exception(aConeAlgo.getError());
365     }
366
367     aConeAlgo.build();
368
369     if(!aConeAlgo.isDone()) {
370       throw GeomAlgoAPI_Exception(aConeAlgo.getError());
371     }
372
373     if (!aConeAlgo.checkValid("Cone builder")) {
374       throw GeomAlgoAPI_Exception(aConeAlgo.getError());
375     }
376     return aConeAlgo.shape();
377   }
378
379   //===============================================================================================
380   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
381     std::shared_ptr<GeomAPI_Shape> theSourceShape,
382     std::shared_ptr<GeomAPI_Ax1>   theAxis,
383     const double theDistance) throw (GeomAlgoAPI_Exception)
384   {
385     GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theAxis, theDistance);
386
387     if (!aTranslationAlgo.check()) {
388       throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
389     }
390
391     aTranslationAlgo.build();
392
393     if(!aTranslationAlgo.isDone()) {
394       throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
395     }
396
397     return aTranslationAlgo.shape();
398   }
399
400   //===============================================================================================
401   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
402     std::shared_ptr<GeomAPI_Shape> theSourceShape,
403     const double theDx,
404     const double theDy,
405     const double theDz) throw (GeomAlgoAPI_Exception)
406   {
407     GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theDx, theDy, theDz);
408
409     if (!aTranslationAlgo.check()) {
410       throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
411     }
412
413     aTranslationAlgo.build();
414
415     if(!aTranslationAlgo.isDone()) {
416       throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
417     }
418
419     return aTranslationAlgo.shape();
420   }
421
422   //===============================================================================================
423   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
424     std::shared_ptr<GeomAPI_Shape> theSourceShape,
425     std::shared_ptr<GeomAPI_Pnt>   theStartPoint,
426     std::shared_ptr<GeomAPI_Pnt>   theEndPoint) throw (GeomAlgoAPI_Exception)
427   {
428     GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theStartPoint, theEndPoint);
429
430     if (!aTranslationAlgo.check()) {
431       throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
432     }
433
434     aTranslationAlgo.build();
435
436     if(!aTranslationAlgo.isDone()) {
437       throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
438     }
439
440     return aTranslationAlgo.shape();
441   }
442
443   //===============================================================================================
444   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeRotation(
445     std::shared_ptr<GeomAPI_Shape> theSourceShape,
446     std::shared_ptr<GeomAPI_Ax1> theAxis,
447     const double theAngle) throw (GeomAlgoAPI_Exception)
448   {
449     GeomAlgoAPI_Rotation aRotationAlgo(theSourceShape, theAxis, theAngle);
450
451     if (!aRotationAlgo.check()) {
452       throw GeomAlgoAPI_Exception(aRotationAlgo.getError());
453     }
454
455     aRotationAlgo.build();
456
457     if(!aRotationAlgo.isDone()) {
458       throw GeomAlgoAPI_Exception(aRotationAlgo.getError());
459     }
460
461     return aRotationAlgo.shape();
462   }
463
464   //===============================================================================================
465   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeRotation(
466     std::shared_ptr<GeomAPI_Shape> theSourceShape,
467     std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
468     std::shared_ptr<GeomAPI_Pnt> theStartPoint,
469     std::shared_ptr<GeomAPI_Pnt> theEndPoint) throw (GeomAlgoAPI_Exception)
470   {
471     GeomAlgoAPI_Rotation aRotationAlgo(theSourceShape, theCenterPoint, theStartPoint, theEndPoint);
472
473     if (!aRotationAlgo.check()) {
474       throw GeomAlgoAPI_Exception(aRotationAlgo.getError());
475     }
476
477     aRotationAlgo.build();
478
479     if(!aRotationAlgo.isDone()) {
480       throw GeomAlgoAPI_Exception(aRotationAlgo.getError());
481     }
482
483     return aRotationAlgo.shape();
484   }
485
486   //===============================================================================================
487   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
488     std::shared_ptr<GeomAPI_Shape> theSourceShape,
489     std::shared_ptr<GeomAPI_Pnt>   thePoint) throw (GeomAlgoAPI_Exception)
490   {
491     GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, thePoint);
492
493     if (!aSymmetryAlgo.check()) {
494       throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
495     }
496
497     aSymmetryAlgo.build();
498
499     if(!aSymmetryAlgo.isDone()) {
500       throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
501     }
502
503     return aSymmetryAlgo.shape();
504   }
505
506   //===============================================================================================
507   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
508     std::shared_ptr<GeomAPI_Shape> theSourceShape,
509     std::shared_ptr<GeomAPI_Ax1>   theAxis) throw (GeomAlgoAPI_Exception)
510   {
511     GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, theAxis);
512
513     if (!aSymmetryAlgo.check()) {
514       throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
515     }
516
517     aSymmetryAlgo.build();
518
519     if(!aSymmetryAlgo.isDone()) {
520       throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
521     }
522
523     return aSymmetryAlgo.shape();
524   }
525
526   //===============================================================================================
527   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
528     std::shared_ptr<GeomAPI_Shape> theSourceShape,
529     std::shared_ptr<GeomAPI_Ax2>   thePlane) throw (GeomAlgoAPI_Exception)
530   {
531     GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, thePlane);
532
533     if (!aSymmetryAlgo.check()) {
534       throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
535     }
536
537     aSymmetryAlgo.build();
538
539     if(!aSymmetryAlgo.isDone()) {
540       throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
541     }
542
543     return aSymmetryAlgo.shape();
544   }
545
546   //===============================================================================================
547   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeScale(
548     std::shared_ptr<GeomAPI_Shape> theSourceShape,
549     std::shared_ptr<GeomAPI_Pnt>   theCenterPoint,
550     const double                   theScaleFactor) throw (GeomAlgoAPI_Exception)
551   {
552     GeomAlgoAPI_Scale aScaleAlgo(theSourceShape, theCenterPoint, theScaleFactor);
553
554     if (!aScaleAlgo.check()) {
555       throw GeomAlgoAPI_Exception(aScaleAlgo.getError());
556     }
557
558     aScaleAlgo.build();
559
560     if(!aScaleAlgo.isDone()) {
561       throw GeomAlgoAPI_Exception(aScaleAlgo.getError());
562     }
563
564     return aScaleAlgo.shape();
565   }
566
567   //===============================================================================================
568   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeScale(
569     std::shared_ptr<GeomAPI_Shape> theSourceShape,
570     std::shared_ptr<GeomAPI_Pnt>   theCenterPoint,
571     const double                   theScaleFactorX,
572     const double                   theScaleFactorY,
573     const double                   theScaleFactorZ) throw (GeomAlgoAPI_Exception)
574   {
575     GeomAlgoAPI_Scale aScaleAlgo(theSourceShape, theCenterPoint,
576                                  theScaleFactorX, theScaleFactorY, theScaleFactorZ);
577
578     if (!aScaleAlgo.check()) {
579       throw GeomAlgoAPI_Exception(aScaleAlgo.getError());
580     }
581
582     aScaleAlgo.build();
583
584     if(!aScaleAlgo.isDone()) {
585       throw GeomAlgoAPI_Exception(aScaleAlgo.getError());
586     }
587
588     return aScaleAlgo.shape();
589   }
590
591   //===============================================================================================
592   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeMultiTranslation(
593     std::shared_ptr<GeomAPI_Shape> theSourceShape,
594     std::shared_ptr<GeomAPI_Ax1> theAxis,
595     const double theStep,
596     const int theNumber) throw (GeomAlgoAPI_Exception)
597   {
598     if (!theAxis) {
599       std::string aError = "Multitranslation builder ";
600       aError+=":: the first axis is not valid";
601       throw GeomAlgoAPI_Exception(aError);
602     }
603
604     if (theNumber <=0) {
605       std::string aError = "Multitranslation builder ";
606       aError+=":: the number of copies for the first direction is null or negative.";
607       throw GeomAlgoAPI_Exception(aError);
608     }
609
610     ListOfShape aListOfShape;
611     for (int i=0; i<theNumber; i++) {
612       aListOfShape.
613         push_back(GeomAlgoAPI_ShapeAPI::makeTranslation(theSourceShape, theAxis, i*theStep));
614     }
615     return GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
616   }
617
618   //===============================================================================================
619   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeMultiTranslation(
620     std::shared_ptr<GeomAPI_Shape> theSourceShape,
621     std::shared_ptr<GeomAPI_Ax1> theFirstAxis,
622     const double theFirstStep,
623     const int theFirstNumber,
624     std::shared_ptr<GeomAPI_Ax1> theSecondAxis,
625     const double theSecondStep,
626     const int theSecondNumber) throw (GeomAlgoAPI_Exception)
627   {
628     if (!theFirstAxis) {
629       std::string aError = "Multitranslation builder ";
630       aError+=":: the first axis is not valid";
631       throw GeomAlgoAPI_Exception(aError);
632     }
633
634     if (!theSecondAxis) {
635       std::string aError = "Multitranslation builder ";
636       aError+=":: the second axis is not valid";
637       throw GeomAlgoAPI_Exception(aError);
638     }
639
640     if (theFirstNumber <=0) {
641       std::string aError = "Multitranslation builder ";
642       aError+=":: the number of copies for the first direction is null or negative.";
643       throw GeomAlgoAPI_Exception(aError);
644     }
645
646     if (theSecondNumber <=0) {
647       std::string aError = "Multitranslation builder ";
648       aError+=":: the number of copies for the second direction is null or negative.";
649       throw GeomAlgoAPI_Exception(aError);
650     }
651
652     // Coord theFirstAxis
653     double x1 = theFirstAxis->dir()->x();
654     double y1 = theFirstAxis->dir()->y();
655     double z1 = theFirstAxis->dir()->z();
656     double norm1 = sqrt(x1*x1 + y1*y1 + z1*z1);
657
658     // Coord theSecondAxis
659     double x2 = theSecondAxis->dir()->x();
660     double y2 = theSecondAxis->dir()->y();
661     double z2 = theSecondAxis->dir()->z();
662     double norm2 = sqrt(x2*x2 + y2*y2 + z2*z2);
663
664     ListOfShape aListOfShape;
665     for (int j=0; j<theSecondStep; j++) {
666       for (int i=0; i<theFirstNumber; i++) {
667         double dx = i*theFirstStep*x1/norm1+j*theSecondStep*x2/norm2;
668         double dy = i*theFirstStep*y1/norm1+j*theSecondStep*y2/norm2;
669         double dz = i*theFirstStep*z1/norm1+j*theSecondStep*z2/norm2;
670         aListOfShape.push_back(GeomAlgoAPI_ShapeAPI::makeTranslation(theSourceShape, dx, dy, dz));
671       }
672     }
673     return GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
674   }
675
676   //===============================================================================================
677   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeConeSegment(
678     const double theRMin1, const double theRMax1,
679     const double theRMin2, const double theRMax2,
680     const double theZ,
681     const double theStartPhi, const double theDeltaPhi) throw (GeomAlgoAPI_Exception)
682   {
683     GeomAlgoAPI_ConeSegment aConeSegmentAlgo(theRMin1, theRMax1, theRMin2, theRMax2,
684                                              theZ, theStartPhi, theDeltaPhi);
685
686     if (!aConeSegmentAlgo.check()) {
687       throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError());
688     }
689
690     aConeSegmentAlgo.build();
691
692     if(!aConeSegmentAlgo.isDone()) {
693       throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError());
694     }
695     if (!aConeSegmentAlgo.checkValid("Cone Segment builder")) {
696       throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError());
697     }
698     return aConeSegmentAlgo.shape();
699   }
700 }