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