+
+ std::shared_ptr<GeomAPI_Ax2> anAxis;
+ anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
+ theEdge->line()->direction()));
+
+ GeomAlgoAPI_Cone aConeAlgo(anAxis, theBaseRadius, theTopRadius, theHeight);
+
+ static const std::string aMsg("Cone builder");
+ return runAlgoAndCheckShape(aConeAlgo, aMsg);
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCone(
+ double theBaseRadius, double theTopRadius,
+ double theHeight)
+ {
+ std::shared_ptr<GeomAPI_Pnt> aBasePoint =
+ std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
+ std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
+ std::shared_ptr<GeomAPI_Ax2> anAxis;
+ anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
+ aEdge->line()->direction()));
+
+ GeomAlgoAPI_Cone aConeAlgo(anAxis, theBaseRadius, theTopRadius, theHeight);
+
+ static const std::string aMsg("Cone builder");
+ return runAlgoAndCheckShape(aConeAlgo, aMsg);
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Ax1> theAxis,
+ const double theDistance)
+ {
+ GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theAxis, theDistance);
+ return runAlgo(aTranslationAlgo);
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ const double theDx,
+ const double theDy,
+ const double theDz)
+ {
+ GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theDx, theDy, theDz);
+ return runAlgo(aTranslationAlgo);
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Pnt> theStartPoint,
+ std::shared_ptr<GeomAPI_Pnt> theEndPoint)
+ {
+ GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theStartPoint, theEndPoint);
+ return runAlgo(aTranslationAlgo);
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeRotation(
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Ax1> theAxis,
+ const double theAngle)
+ {
+ GeomAlgoAPI_Rotation aRotationAlgo(theSourceShape, theAxis, theAngle);
+ return runAlgo(aRotationAlgo);
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeRotation(
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
+ std::shared_ptr<GeomAPI_Pnt> theStartPoint,
+ std::shared_ptr<GeomAPI_Pnt> theEndPoint)
+ {
+ GeomAlgoAPI_Rotation aRotationAlgo(theSourceShape, theCenterPoint, theStartPoint, theEndPoint);
+ return runAlgo(aRotationAlgo);
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Pnt> thePoint)
+ {
+ GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, thePoint);
+ return runAlgo(aSymmetryAlgo);
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Ax1> theAxis)
+ {
+ GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, theAxis);
+ return runAlgo(aSymmetryAlgo);
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Ax2> thePlane)
+ {
+ GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, thePlane);
+ return runAlgo(aSymmetryAlgo);
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeScale(
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
+ const double theScaleFactor)
+ {
+ GeomAlgoAPI_Scale aScaleAlgo(theSourceShape, theCenterPoint, theScaleFactor);
+ return runAlgo(aScaleAlgo);
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeScale(
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
+ const double theScaleFactorX,
+ const double theScaleFactorY,
+ const double theScaleFactorZ)
+ {
+ GeomAlgoAPI_Scale aScaleAlgo(theSourceShape, theCenterPoint,
+ theScaleFactorX, theScaleFactorY, theScaleFactorZ);
+ return runAlgo(aScaleAlgo);
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeMultiTranslation(
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Ax1> theAxis,
+ const double theStep,
+ const int theNumber)
+ {
+ if (!theAxis) {
+ std::string aError = "Multitranslation builder ";
+ aError+=":: the first axis is not valid";
+ throw GeomAlgoAPI_Exception(aError);
+ }
+
+ if (theNumber <=0) {
+ std::string aError = "Multitranslation builder ";
+ aError+=":: the number of copies for the first direction is null or negative.";
+ throw GeomAlgoAPI_Exception(aError);
+ }
+
+ ListOfShape aListOfShape;
+ for (int i=0; i<theNumber; i++) {
+ aListOfShape.
+ push_back(GeomAlgoAPI_ShapeAPI::makeTranslation(theSourceShape, theAxis, i*theStep));
+ }
+ return GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeMultiTranslation(
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Ax1> theFirstAxis,
+ const double theFirstStep,
+ const int theFirstNumber,
+ std::shared_ptr<GeomAPI_Ax1> theSecondAxis,
+ const double theSecondStep,
+ const int theSecondNumber)
+ {
+ if (!theFirstAxis) {
+ std::string aError = "Multitranslation builder ";
+ aError+=":: the first axis is not valid";
+ throw GeomAlgoAPI_Exception(aError);
+ }
+
+ if (!theSecondAxis) {
+ std::string aError = "Multitranslation builder ";
+ aError+=":: the second axis is not valid";
+ throw GeomAlgoAPI_Exception(aError);
+ }
+
+ if (theFirstNumber <=0) {
+ std::string aError = "Multitranslation builder ";
+ aError+=":: the number of copies for the first direction is null or negative.";
+ throw GeomAlgoAPI_Exception(aError);
+ }
+
+ if (theSecondNumber <=0) {
+ std::string aError = "Multitranslation builder ";
+ aError+=":: the number of copies for the second direction is null or negative.";
+ throw GeomAlgoAPI_Exception(aError);
+ }
+
+ // Coord theFirstAxis
+ double x1 = theFirstAxis->dir()->x();
+ double y1 = theFirstAxis->dir()->y();
+ double z1 = theFirstAxis->dir()->z();
+ double norm1 = sqrt(x1*x1 + y1*y1 + z1*z1);
+
+ // Coord theSecondAxis
+ double x2 = theSecondAxis->dir()->x();
+ double y2 = theSecondAxis->dir()->y();
+ double z2 = theSecondAxis->dir()->z();
+ double norm2 = sqrt(x2*x2 + y2*y2 + z2*z2);
+
+ ListOfShape aListOfShape;
+ for (int j=0; j<theSecondStep; j++) {
+ for (int i=0; i<theFirstNumber; i++) {
+ double dx = i*theFirstStep*x1/norm1+j*theSecondStep*x2/norm2;
+ double dy = i*theFirstStep*y1/norm1+j*theSecondStep*y2/norm2;
+ double dz = i*theFirstStep*z1/norm1+j*theSecondStep*z2/norm2;
+ aListOfShape.push_back(GeomAlgoAPI_ShapeAPI::makeTranslation(theSourceShape, dx, dy, dz));
+ }
+ }
+ return GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeMultiRotation(
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Ax1> theAxis,
+ const int theNumber)
+ {
+ if (!theAxis) {
+ std::string aError = "Multirotation builder ";
+ aError+=":: the axis is not valid";
+ throw GeomAlgoAPI_Exception(aError);
+ }
+
+ if (theNumber <=0) {
+ std::string aError = "Multirotation builder ";
+ aError+=":: the number of copies is null or negative.";
+ throw GeomAlgoAPI_Exception(aError);
+ }
+
+ double anAngle = 360./theNumber;
+
+ ListOfShape aListOfShape;
+ for (int i=0; i<theNumber; i++) {
+ aListOfShape.
+ push_back(GeomAlgoAPI_ShapeAPI::makeRotation(theSourceShape, theAxis, i*anAngle));
+ }
+ return GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeMultiRotation(
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Ax1> theAxis,
+ const double theStep,
+ const int theNumber)
+ {
+ if (!theAxis) {
+ std::string aError = "Multirotation builder ";
+ aError+=":: the axis is not valid";
+ throw GeomAlgoAPI_Exception(aError);
+ }
+
+ if (theNumber <=0) {
+ std::string aError = "Multirotation builder ";
+ aError+=":: the number of copies is null or negative.";
+ throw GeomAlgoAPI_Exception(aError);
+ }
+
+ ListOfShape aListOfShape;
+ for (int i=0; i<theNumber; i++) {
+ aListOfShape.
+ push_back(GeomAlgoAPI_ShapeAPI::makeRotation(theSourceShape, theAxis, i*theStep));
+ }
+ return GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeConeSegment(
+ const double theRMin1, const double theRMax1,
+ const double theRMin2, const double theRMax2,
+ const double theZ,
+ const double theStartPhi, const double theDeltaPhi)
+ {
+ GeomAlgoAPI_ConeSegment aConeSegmentAlgo(theRMin1, theRMax1, theRMin2, theRMax2,
+ theZ, theStartPhi, theDeltaPhi);
+
+ static const std::string aMsg("Cone Segment builder");
+ return runAlgoAndCheckShape(aConeSegmentAlgo, aMsg);