1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "GeomAlgoAPI_ShapeAPI.h"
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>
36 #include <GeomAPI_Lin.h>
40 namespace GeomAlgoAPI_ShapeAPI
42 //===============================================================================================
43 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(
44 const double theDx, const double theDy,
45 const double theDz) throw (GeomAlgoAPI_Exception)
47 GeomAlgoAPI_Box aBoxAlgo(theDx,theDy,theDz);
49 if (!aBoxAlgo.check()) {
50 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
55 if(!aBoxAlgo.isDone()) {
56 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
58 if (!aBoxAlgo.checkValid("Box builder with dimensions")) {
59 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
61 return aBoxAlgo.shape();
64 //===============================================================================================
65 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(
66 std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
67 std::shared_ptr<GeomAPI_Pnt> theSecondPoint) throw (GeomAlgoAPI_Exception)
69 GeomAlgoAPI_Box aBoxAlgo(theFirstPoint, theSecondPoint);
71 if (!aBoxAlgo.check()) {
72 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
77 if(!aBoxAlgo.isDone()) {
78 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
80 if (!aBoxAlgo.checkValid("Box builder with two points")) {
81 throw GeomAlgoAPI_Exception(aBoxAlgo.getError());
83 return aBoxAlgo.shape();
86 //===============================================================================================
87 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
88 std::shared_ptr<GeomAPI_Pnt> theBasePoint, std::shared_ptr<GeomAPI_Edge> theEdge,
89 double theRadius, double theHeight) throw (GeomAlgoAPI_Exception)
91 // Check if the base point is OK
93 throw GeomAlgoAPI_Exception("Cylinder builder :: the base point is not valid.");
95 // Check if the edge is OK
97 throw GeomAlgoAPI_Exception("Cylinder builder :: the axis is not valid.");
100 std::shared_ptr<GeomAPI_Ax2> anAxis;
101 anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
102 theEdge->line()->direction()));
104 GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight);
106 if (!aCylinderAlgo.check()) {
107 throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
110 aCylinderAlgo.build();
112 if(!aCylinderAlgo.isDone()) {
113 throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
115 if (!aCylinderAlgo.checkValid("Cylinder builder")) {
116 throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
118 return aCylinderAlgo.shape();
121 //===============================================================================================
122 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
123 std::shared_ptr<GeomAPI_Pnt> theBasePoint, std::shared_ptr<GeomAPI_Edge> theEdge,
124 double theRadius, double theHeight, double theAngle) throw (GeomAlgoAPI_Exception)
126 // Check if the base point is OK
128 throw GeomAlgoAPI_Exception("Cylinder builder :: the base point is not valid.");
130 // Check if the edge is OK
132 throw GeomAlgoAPI_Exception("Cylinder builder :: the axis is not valid.");
135 std::shared_ptr<GeomAPI_Ax2> anAxis;
136 anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
137 theEdge->line()->direction()));
139 GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight, theAngle);
141 if (!aCylinderAlgo.check()) {
142 throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
145 aCylinderAlgo.build();
147 if(!aCylinderAlgo.isDone()) {
148 throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
150 if (!aCylinderAlgo.checkValid("Cylinder portion builder")) {
151 throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
153 return aCylinderAlgo.shape();
156 //===============================================================================================
157 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
158 double theRadius, double theHeight) throw (GeomAlgoAPI_Exception)
160 std::shared_ptr<GeomAPI_Pnt> aBasePoint =
161 std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
162 std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
163 std::shared_ptr<GeomAPI_Ax2> anAxis;
164 anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
165 aEdge->line()->direction()));
167 GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight);
169 if (!aCylinderAlgo.check()) {
170 throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
173 aCylinderAlgo.build();
175 if(!aCylinderAlgo.isDone()) {
176 throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
178 if (!aCylinderAlgo.checkValid("Cylinder builder")) {
179 throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
181 return aCylinderAlgo.shape();
184 //===============================================================================================
185 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
186 double theRadius, double theHeight, double theAngle) throw (GeomAlgoAPI_Exception)
188 std::shared_ptr<GeomAPI_Pnt> aBasePoint =
189 std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
190 std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
191 std::shared_ptr<GeomAPI_Ax2> anAxis;
192 anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
193 aEdge->line()->direction()));
195 GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight, theAngle);
197 if (!aCylinderAlgo.check()) {
198 throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
201 aCylinderAlgo.build();
203 if(!aCylinderAlgo.isDone()) {
204 throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
206 if (!aCylinderAlgo.checkValid("Cylinder portion builder")) {
207 throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
209 return aCylinderAlgo.shape();
212 //===============================================================================================
213 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSphere(
214 std::shared_ptr<GeomAPI_Pnt> theCenterPoint, double theRadius) throw (GeomAlgoAPI_Exception)
216 GeomAlgoAPI_Sphere aSphereAlgo(theCenterPoint, theRadius);
218 if (!aSphereAlgo.check()) {
219 throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
224 if(!aSphereAlgo.isDone()) {
225 throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
228 if (!aSphereAlgo.checkValid("Sphere builder")) {
229 throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
231 return aSphereAlgo.shape();
234 //===============================================================================================
235 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSphere(double theRadius)
236 throw (GeomAlgoAPI_Exception)
238 std::shared_ptr<GeomAPI_Pnt> aCenterPoint =
239 std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
241 GeomAlgoAPI_Sphere aSphereAlgo(aCenterPoint, theRadius);
243 if (!aSphereAlgo.check()) {
244 throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
249 if(!aSphereAlgo.isDone()) {
250 throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
253 if (!aSphereAlgo.checkValid("Sphere builder")) {
254 throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
256 return aSphereAlgo.shape();
259 //===============================================================================================
260 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTorus(
261 std::shared_ptr<GeomAPI_Pnt> theBasePoint,
262 std::shared_ptr<GeomAPI_Edge> theEdge,double theRadius, double theRingRadius)
263 throw (GeomAlgoAPI_Exception)
265 // Check if the base point is OK
267 throw GeomAlgoAPI_Exception("Torus builder :: the base point is not valid.");
269 // Check if the edge is OK
271 throw GeomAlgoAPI_Exception("Torus builder :: the axis is not valid.");
274 std::shared_ptr<GeomAPI_Ax2> anAxis;
275 anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
276 theEdge->line()->direction()));
278 GeomAlgoAPI_Torus aTorusAlgo(anAxis, theRadius, theRingRadius);
280 if (!aTorusAlgo.check()) {
281 throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
286 if(!aTorusAlgo.isDone()) {
287 throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
290 if (!aTorusAlgo.checkValid("Torus builder")) {
291 throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
293 return aTorusAlgo.shape();
296 //===============================================================================================
297 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTorus(double theRadius,
298 double theRingRadius) throw (GeomAlgoAPI_Exception)
300 std::shared_ptr<GeomAPI_Pnt> aBasePoint =
301 std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
302 std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
303 std::shared_ptr<GeomAPI_Ax2> anAxis;
304 anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
305 aEdge->line()->direction()));
307 GeomAlgoAPI_Torus aTorusAlgo(anAxis, theRadius, theRingRadius);
309 if (!aTorusAlgo.check()) {
310 throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
315 if(!aTorusAlgo.isDone()) {
316 throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
319 if (!aTorusAlgo.checkValid("Torus builder")) {
320 throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
322 return aTorusAlgo.shape();
325 //===============================================================================================
326 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCone(
327 std::shared_ptr<GeomAPI_Pnt> theBasePoint,
328 std::shared_ptr<GeomAPI_Edge> theEdge,
329 double theBaseRadius, double theTopRadius,
330 double theHeight) throw (GeomAlgoAPI_Exception)
332 // Check if the base point is OK
334 throw GeomAlgoAPI_Exception("Cone builder :: the base point is not valid.");
336 // Check if the edge is OK
338 throw GeomAlgoAPI_Exception("Cone builder :: the axis is not valid.");
341 std::shared_ptr<GeomAPI_Ax2> anAxis;
342 anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
343 theEdge->line()->direction()));
345 GeomAlgoAPI_Cone aConeAlgo(anAxis, theBaseRadius, theTopRadius, theHeight);
347 if (!aConeAlgo.check()) {
348 throw GeomAlgoAPI_Exception(aConeAlgo.getError());
353 if(!aConeAlgo.isDone()) {
354 throw GeomAlgoAPI_Exception(aConeAlgo.getError());
357 if (!aConeAlgo.checkValid("Cone builder")) {
358 throw GeomAlgoAPI_Exception(aConeAlgo.getError());
360 return aConeAlgo.shape();
363 //===============================================================================================
364 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCone(
365 double theBaseRadius, double theTopRadius,
366 double theHeight) throw (GeomAlgoAPI_Exception)
368 std::shared_ptr<GeomAPI_Pnt> aBasePoint =
369 std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
370 std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
371 std::shared_ptr<GeomAPI_Ax2> anAxis;
372 anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
373 aEdge->line()->direction()));
375 GeomAlgoAPI_Cone aConeAlgo(anAxis, theBaseRadius, theTopRadius, theHeight);
377 if (!aConeAlgo.check()) {
378 throw GeomAlgoAPI_Exception(aConeAlgo.getError());
383 if(!aConeAlgo.isDone()) {
384 throw GeomAlgoAPI_Exception(aConeAlgo.getError());
387 if (!aConeAlgo.checkValid("Cone builder")) {
388 throw GeomAlgoAPI_Exception(aConeAlgo.getError());
390 return aConeAlgo.shape();
393 //===============================================================================================
394 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
395 std::shared_ptr<GeomAPI_Shape> theSourceShape,
396 std::shared_ptr<GeomAPI_Ax1> theAxis,
397 const double theDistance) throw (GeomAlgoAPI_Exception)
399 GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theAxis, theDistance);
401 if (!aTranslationAlgo.check()) {
402 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
405 aTranslationAlgo.build();
407 if(!aTranslationAlgo.isDone()) {
408 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
411 return aTranslationAlgo.shape();
414 //===============================================================================================
415 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
416 std::shared_ptr<GeomAPI_Shape> theSourceShape,
419 const double theDz) throw (GeomAlgoAPI_Exception)
421 GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theDx, theDy, theDz);
423 if (!aTranslationAlgo.check()) {
424 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
427 aTranslationAlgo.build();
429 if(!aTranslationAlgo.isDone()) {
430 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
433 return aTranslationAlgo.shape();
436 //===============================================================================================
437 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
438 std::shared_ptr<GeomAPI_Shape> theSourceShape,
439 std::shared_ptr<GeomAPI_Pnt> theStartPoint,
440 std::shared_ptr<GeomAPI_Pnt> theEndPoint) throw (GeomAlgoAPI_Exception)
442 GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theStartPoint, theEndPoint);
444 if (!aTranslationAlgo.check()) {
445 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
448 aTranslationAlgo.build();
450 if(!aTranslationAlgo.isDone()) {
451 throw GeomAlgoAPI_Exception(aTranslationAlgo.getError());
454 return aTranslationAlgo.shape();
457 //===============================================================================================
458 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeRotation(
459 std::shared_ptr<GeomAPI_Shape> theSourceShape,
460 std::shared_ptr<GeomAPI_Ax1> theAxis,
461 const double theAngle) throw (GeomAlgoAPI_Exception)
463 GeomAlgoAPI_Rotation aRotationAlgo(theSourceShape, theAxis, theAngle);
465 if (!aRotationAlgo.check()) {
466 throw GeomAlgoAPI_Exception(aRotationAlgo.getError());
469 aRotationAlgo.build();
471 if(!aRotationAlgo.isDone()) {
472 throw GeomAlgoAPI_Exception(aRotationAlgo.getError());
475 return aRotationAlgo.shape();
478 //===============================================================================================
479 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeRotation(
480 std::shared_ptr<GeomAPI_Shape> theSourceShape,
481 std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
482 std::shared_ptr<GeomAPI_Pnt> theStartPoint,
483 std::shared_ptr<GeomAPI_Pnt> theEndPoint) throw (GeomAlgoAPI_Exception)
485 GeomAlgoAPI_Rotation aRotationAlgo(theSourceShape, theCenterPoint, theStartPoint, theEndPoint);
487 if (!aRotationAlgo.check()) {
488 throw GeomAlgoAPI_Exception(aRotationAlgo.getError());
491 aRotationAlgo.build();
493 if(!aRotationAlgo.isDone()) {
494 throw GeomAlgoAPI_Exception(aRotationAlgo.getError());
497 return aRotationAlgo.shape();
500 //===============================================================================================
501 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
502 std::shared_ptr<GeomAPI_Shape> theSourceShape,
503 std::shared_ptr<GeomAPI_Pnt> thePoint) throw (GeomAlgoAPI_Exception)
505 GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, thePoint);
507 if (!aSymmetryAlgo.check()) {
508 throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
511 aSymmetryAlgo.build();
513 if(!aSymmetryAlgo.isDone()) {
514 throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
517 return aSymmetryAlgo.shape();
520 //===============================================================================================
521 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
522 std::shared_ptr<GeomAPI_Shape> theSourceShape,
523 std::shared_ptr<GeomAPI_Ax1> theAxis) throw (GeomAlgoAPI_Exception)
525 GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, theAxis);
527 if (!aSymmetryAlgo.check()) {
528 throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
531 aSymmetryAlgo.build();
533 if(!aSymmetryAlgo.isDone()) {
534 throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
537 return aSymmetryAlgo.shape();
540 //===============================================================================================
541 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
542 std::shared_ptr<GeomAPI_Shape> theSourceShape,
543 std::shared_ptr<GeomAPI_Ax2> thePlane) throw (GeomAlgoAPI_Exception)
545 GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, thePlane);
547 if (!aSymmetryAlgo.check()) {
548 throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
551 aSymmetryAlgo.build();
553 if(!aSymmetryAlgo.isDone()) {
554 throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError());
557 return aSymmetryAlgo.shape();
560 //===============================================================================================
561 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeScale(
562 std::shared_ptr<GeomAPI_Shape> theSourceShape,
563 std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
564 const double theScaleFactor) throw (GeomAlgoAPI_Exception)
566 GeomAlgoAPI_Scale aScaleAlgo(theSourceShape, theCenterPoint, theScaleFactor);
568 if (!aScaleAlgo.check()) {
569 throw GeomAlgoAPI_Exception(aScaleAlgo.getError());
574 if(!aScaleAlgo.isDone()) {
575 throw GeomAlgoAPI_Exception(aScaleAlgo.getError());
578 return aScaleAlgo.shape();
581 //===============================================================================================
582 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeScale(
583 std::shared_ptr<GeomAPI_Shape> theSourceShape,
584 std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
585 const double theScaleFactorX,
586 const double theScaleFactorY,
587 const double theScaleFactorZ) throw (GeomAlgoAPI_Exception)
589 GeomAlgoAPI_Scale aScaleAlgo(theSourceShape, theCenterPoint,
590 theScaleFactorX, theScaleFactorY, theScaleFactorZ);
592 if (!aScaleAlgo.check()) {
593 throw GeomAlgoAPI_Exception(aScaleAlgo.getError());
598 if(!aScaleAlgo.isDone()) {
599 throw GeomAlgoAPI_Exception(aScaleAlgo.getError());
602 return aScaleAlgo.shape();
605 //===============================================================================================
606 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeMultiTranslation(
607 std::shared_ptr<GeomAPI_Shape> theSourceShape,
608 std::shared_ptr<GeomAPI_Ax1> theAxis,
609 const double theStep,
610 const int theNumber) throw (GeomAlgoAPI_Exception)
613 std::string aError = "Multitranslation builder ";
614 aError+=":: the first axis is not valid";
615 throw GeomAlgoAPI_Exception(aError);
619 std::string aError = "Multitranslation builder ";
620 aError+=":: the number of copies for the first direction is null or negative.";
621 throw GeomAlgoAPI_Exception(aError);
624 ListOfShape aListOfShape;
625 for (int i=0; i<theNumber; i++) {
627 push_back(GeomAlgoAPI_ShapeAPI::makeTranslation(theSourceShape, theAxis, i*theStep));
629 return GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
632 //===============================================================================================
633 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeMultiTranslation(
634 std::shared_ptr<GeomAPI_Shape> theSourceShape,
635 std::shared_ptr<GeomAPI_Ax1> theFirstAxis,
636 const double theFirstStep,
637 const int theFirstNumber,
638 std::shared_ptr<GeomAPI_Ax1> theSecondAxis,
639 const double theSecondStep,
640 const int theSecondNumber) throw (GeomAlgoAPI_Exception)
643 std::string aError = "Multitranslation builder ";
644 aError+=":: the first axis is not valid";
645 throw GeomAlgoAPI_Exception(aError);
648 if (!theSecondAxis) {
649 std::string aError = "Multitranslation builder ";
650 aError+=":: the second axis is not valid";
651 throw GeomAlgoAPI_Exception(aError);
654 if (theFirstNumber <=0) {
655 std::string aError = "Multitranslation builder ";
656 aError+=":: the number of copies for the first direction is null or negative.";
657 throw GeomAlgoAPI_Exception(aError);
660 if (theSecondNumber <=0) {
661 std::string aError = "Multitranslation builder ";
662 aError+=":: the number of copies for the second direction is null or negative.";
663 throw GeomAlgoAPI_Exception(aError);
666 // Coord theFirstAxis
667 double x1 = theFirstAxis->dir()->x();
668 double y1 = theFirstAxis->dir()->y();
669 double z1 = theFirstAxis->dir()->z();
670 double norm1 = sqrt(x1*x1 + y1*y1 + z1*z1);
672 // Coord theSecondAxis
673 double x2 = theSecondAxis->dir()->x();
674 double y2 = theSecondAxis->dir()->y();
675 double z2 = theSecondAxis->dir()->z();
676 double norm2 = sqrt(x2*x2 + y2*y2 + z2*z2);
678 ListOfShape aListOfShape;
679 for (int j=0; j<theSecondStep; j++) {
680 for (int i=0; i<theFirstNumber; i++) {
681 double dx = i*theFirstStep*x1/norm1+j*theSecondStep*x2/norm2;
682 double dy = i*theFirstStep*y1/norm1+j*theSecondStep*y2/norm2;
683 double dz = i*theFirstStep*z1/norm1+j*theSecondStep*z2/norm2;
684 aListOfShape.push_back(GeomAlgoAPI_ShapeAPI::makeTranslation(theSourceShape, dx, dy, dz));
687 return GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
690 //===============================================================================================
691 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeMultiRotation(
692 std::shared_ptr<GeomAPI_Shape> theSourceShape,
693 std::shared_ptr<GeomAPI_Ax1> theAxis,
697 std::string aError = "Multirotation builder ";
698 aError+=":: the axis is not valid";
699 throw GeomAlgoAPI_Exception(aError);
703 std::string aError = "Multirotation builder ";
704 aError+=":: the number of copies is null or negative.";
705 throw GeomAlgoAPI_Exception(aError);
708 double anAngle = 360./theNumber;
710 ListOfShape aListOfShape;
711 for (int i=0; i<theNumber; i++) {
713 push_back(GeomAlgoAPI_ShapeAPI::makeRotation(theSourceShape, theAxis, i*anAngle));
715 return GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
718 //===============================================================================================
719 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeMultiRotation(
720 std::shared_ptr<GeomAPI_Shape> theSourceShape,
721 std::shared_ptr<GeomAPI_Ax1> theAxis,
722 const double theStep,
726 std::string aError = "Multirotation builder ";
727 aError+=":: the axis is not valid";
728 throw GeomAlgoAPI_Exception(aError);
732 std::string aError = "Multirotation builder ";
733 aError+=":: the number of copies is null or negative.";
734 throw GeomAlgoAPI_Exception(aError);
737 ListOfShape aListOfShape;
738 for (int i=0; i<theNumber; i++) {
740 push_back(GeomAlgoAPI_ShapeAPI::makeRotation(theSourceShape, theAxis, i*theStep));
742 return GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
745 //===============================================================================================
746 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeConeSegment(
747 const double theRMin1, const double theRMax1,
748 const double theRMin2, const double theRMax2,
750 const double theStartPhi, const double theDeltaPhi) throw (GeomAlgoAPI_Exception)
752 GeomAlgoAPI_ConeSegment aConeSegmentAlgo(theRMin1, theRMax1, theRMin2, theRMax2,
753 theZ, theStartPhi, theDeltaPhi);
755 if (!aConeSegmentAlgo.check()) {
756 throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError());
759 aConeSegmentAlgo.build();
761 if(!aConeSegmentAlgo.isDone()) {
762 throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError());
764 if (!aConeSegmentAlgo.checkValid("Cone Segment builder")) {
765 throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError());
767 return aConeSegmentAlgo.shape();