X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_ShapeAPI.cpp;h=b10e028abeeb62761ca4490884a41c578298b5a5;hb=87f348fe7ec3805441bd5524536736eeb2e87501;hp=6945ee370c073e720a019e14d159c34add3fca61;hpb=7311abb70485616ce87c3589f0d1b5e8f20e728a;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp index 6945ee370..b10e028ab 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp @@ -5,29 +5,32 @@ // Author: Clarisse Genrault (CEA) #include "GeomAlgoAPI_ShapeAPI.h" -#include -#include -#include -#include +#include +#include +#include #include +#include +#include +#include -#include +#include namespace GeomAlgoAPI_ShapeAPI { - //========================================================================================================= - std::shared_ptr GeomAlgoAPI_ShapeAPI::makeBox(const double theDx, const double theDy, - const double theDz) throw (GeomAlgoAPI_Exception) + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeBox( + const double theDx, const double theDy, + const double theDz) throw (GeomAlgoAPI_Exception) { GeomAlgoAPI_Box aBoxAlgo(theDx,theDy,theDz); - + if (!aBoxAlgo.check()) { throw GeomAlgoAPI_Exception(aBoxAlgo.getError()); } - + aBoxAlgo.build(); - + if(!aBoxAlgo.isDone()) { throw GeomAlgoAPI_Exception(aBoxAlgo.getError()); } @@ -36,19 +39,20 @@ namespace GeomAlgoAPI_ShapeAPI } return aBoxAlgo.shape(); } - - //========================================================================================================= - std::shared_ptr GeomAlgoAPI_ShapeAPI::makeBox(std::shared_ptr theFirstPoint, - std::shared_ptr theSecondPoint) throw (GeomAlgoAPI_Exception) + + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeBox( + std::shared_ptr theFirstPoint, + std::shared_ptr theSecondPoint) throw (GeomAlgoAPI_Exception) { - GeomAlgoAPI_BoxPoints aBoxAlgo(theFirstPoint, theSecondPoint); - + GeomAlgoAPI_Box aBoxAlgo(theFirstPoint, theSecondPoint); + if (!aBoxAlgo.check()) { throw GeomAlgoAPI_Exception(aBoxAlgo.getError()); } - + aBoxAlgo.build(); - + if(!aBoxAlgo.isDone()) { throw GeomAlgoAPI_Exception(aBoxAlgo.getError()); } @@ -57,4 +61,296 @@ namespace GeomAlgoAPI_ShapeAPI } return aBoxAlgo.shape(); } + + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeCylinder( + std::shared_ptr theBasePoint, std::shared_ptr theEdge, + double theRadius, double theHeight) throw (GeomAlgoAPI_Exception) + { + std::shared_ptr anAxis; + anAxis = std::shared_ptr(new GeomAPI_Ax2(theBasePoint, + theEdge->line()->direction())); + + GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight); + + if (!aCylinderAlgo.check()) { + throw GeomAlgoAPI_Exception(aCylinderAlgo.getError()); + } + + aCylinderAlgo.build(); + + if(!aCylinderAlgo.isDone()) { + throw GeomAlgoAPI_Exception(aCylinderAlgo.getError()); + } + if (!aCylinderAlgo.checkValid("Cylinder builder")) { + throw GeomAlgoAPI_Exception(aCylinderAlgo.getError()); + } + return aCylinderAlgo.shape(); + } + + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeCylinder( + std::shared_ptr theBasePoint, std::shared_ptr theEdge, + double theRadius, double theHeight, double theAngle) throw (GeomAlgoAPI_Exception) + { + std::shared_ptr anAxis; + anAxis = std::shared_ptr(new GeomAPI_Ax2(theBasePoint, + theEdge->line()->direction())); + + GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight, theAngle); + + if (!aCylinderAlgo.check()) { + throw GeomAlgoAPI_Exception(aCylinderAlgo.getError()); + } + + aCylinderAlgo.build(); + + if(!aCylinderAlgo.isDone()) { + throw GeomAlgoAPI_Exception(aCylinderAlgo.getError()); + } + if (!aCylinderAlgo.checkValid("Cylinder portion builder")) { + throw GeomAlgoAPI_Exception(aCylinderAlgo.getError()); + } + return aCylinderAlgo.shape(); + } + + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeCylinder( + double theRadius, double theHeight) throw (GeomAlgoAPI_Exception) + { + std::shared_ptr aBasePoint = + std::shared_ptr(new GeomAPI_Pnt(0.,0.,0.)); + std::shared_ptr aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.); + std::shared_ptr anAxis; + anAxis = std::shared_ptr(new GeomAPI_Ax2(aBasePoint, + aEdge->line()->direction())); + + GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight); + + if (!aCylinderAlgo.check()) { + throw GeomAlgoAPI_Exception(aCylinderAlgo.getError()); + } + + aCylinderAlgo.build(); + + if(!aCylinderAlgo.isDone()) { + throw GeomAlgoAPI_Exception(aCylinderAlgo.getError()); + } + if (!aCylinderAlgo.checkValid("Cylinder builder")) { + throw GeomAlgoAPI_Exception(aCylinderAlgo.getError()); + } + return aCylinderAlgo.shape(); + } + + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeCylinder( + double theRadius, double theHeight, double theAngle) throw (GeomAlgoAPI_Exception) + { + std::shared_ptr aBasePoint = + std::shared_ptr(new GeomAPI_Pnt(0.,0.,0.)); + std::shared_ptr aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.); + std::shared_ptr anAxis; + anAxis = std::shared_ptr(new GeomAPI_Ax2(aBasePoint, + aEdge->line()->direction())); + + GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight, theAngle); + + if (!aCylinderAlgo.check()) { + throw GeomAlgoAPI_Exception(aCylinderAlgo.getError()); + } + + aCylinderAlgo.build(); + + if(!aCylinderAlgo.isDone()) { + throw GeomAlgoAPI_Exception(aCylinderAlgo.getError()); + } + if (!aCylinderAlgo.checkValid("Cylinder portion builder")) { + throw GeomAlgoAPI_Exception(aCylinderAlgo.getError()); + } + return aCylinderAlgo.shape(); + } + + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeTranslation( + std::shared_ptr theSourceShape, + std::shared_ptr theAxis, + const double theDistance) throw (GeomAlgoAPI_Exception) + { + GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theAxis, theDistance); + + if (!aTranslationAlgo.check()) { + throw GeomAlgoAPI_Exception(aTranslationAlgo.getError()); + } + + aTranslationAlgo.build(); + + if(!aTranslationAlgo.isDone()) { + throw GeomAlgoAPI_Exception(aTranslationAlgo.getError()); + } + if (!aTranslationAlgo.checkValid("Translation builder with axis and distance")) { + throw GeomAlgoAPI_Exception(aTranslationAlgo.getError()); + } + return aTranslationAlgo.shape(); + } + + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeTranslation( + std::shared_ptr theSourceShape, + const double theDx, + const double theDy, + const double theDz) throw (GeomAlgoAPI_Exception) + { + GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theDx, theDy, theDz); + + if (!aTranslationAlgo.check()) { + throw GeomAlgoAPI_Exception(aTranslationAlgo.getError()); + } + + aTranslationAlgo.build(); + + if(!aTranslationAlgo.isDone()) { + throw GeomAlgoAPI_Exception(aTranslationAlgo.getError()); + } + if (!aTranslationAlgo.checkValid("Translation builder with dimensions")) { + throw GeomAlgoAPI_Exception(aTranslationAlgo.getError()); + } + return aTranslationAlgo.shape(); + } + + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeTranslation( + std::shared_ptr theSourceShape, + std::shared_ptr theStartPoint, + std::shared_ptr theEndPoint) throw (GeomAlgoAPI_Exception) + { + GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theStartPoint, theEndPoint); + + if (!aTranslationAlgo.check()) { + throw GeomAlgoAPI_Exception(aTranslationAlgo.getError()); + } + + aTranslationAlgo.build(); + + if(!aTranslationAlgo.isDone()) { + throw GeomAlgoAPI_Exception(aTranslationAlgo.getError()); + } + if (!aTranslationAlgo.checkValid("Translation builder with two points")) { + throw GeomAlgoAPI_Exception(aTranslationAlgo.getError()); + } + return aTranslationAlgo.shape(); + } + + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeSymmetry( + std::shared_ptr theSourceShape, + std::shared_ptr thePoint) throw (GeomAlgoAPI_Exception) + { + GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, thePoint); + + if (!aSymmetryAlgo.check()) { + throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError()); + } + + aSymmetryAlgo.build(); + + if(!aSymmetryAlgo.isDone()) { + throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError()); + } + if (!aSymmetryAlgo.checkValid("Symmetry builder by a point")) { + throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError()); + } + return aSymmetryAlgo.shape(); + } + + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeSymmetry( + std::shared_ptr theSourceShape, + std::shared_ptr theAxis) throw (GeomAlgoAPI_Exception) + { + GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, theAxis); + + if (!aSymmetryAlgo.check()) { + throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError()); + } + + aSymmetryAlgo.build(); + + if(!aSymmetryAlgo.isDone()) { + throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError()); + } + if (!aSymmetryAlgo.checkValid("Symmetry builder by an axis")) { + throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError()); + } + return aSymmetryAlgo.shape(); + } + + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeSymmetry( + std::shared_ptr theSourceShape, + std::shared_ptr thePlane) throw (GeomAlgoAPI_Exception) + { + GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, thePlane); + + if (!aSymmetryAlgo.check()) { + throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError()); + } + + aSymmetryAlgo.build(); + + if(!aSymmetryAlgo.isDone()) { + throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError()); + } + if (!aSymmetryAlgo.checkValid("Symmetry builder by a plane")) { + throw GeomAlgoAPI_Exception(aSymmetryAlgo.getError()); + } + return aSymmetryAlgo.shape(); + } + + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeScale( + std::shared_ptr theSourceShape, + std::shared_ptr theCenterPoint, + const double theScaleFactor) throw (GeomAlgoAPI_Exception) + { + GeomAlgoAPI_Scale aScaleAlgo(theSourceShape, theCenterPoint, theScaleFactor); + + if (!aScaleAlgo.check()) { + throw GeomAlgoAPI_Exception(aScaleAlgo.getError()); + } + + aScaleAlgo.build(); + + if(!aScaleAlgo.isDone()) { + throw GeomAlgoAPI_Exception(aScaleAlgo.getError()); + } + if (!aScaleAlgo.checkValid("Scale builder by a scale factor")) { + throw GeomAlgoAPI_Exception(aScaleAlgo.getError()); + } + return aScaleAlgo.shape(); + } + + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeConeSegment( + const double theRMin1, const double theRMax1, + const double theRMin2, const double theRMax2, + const double theZ, + const double theStartPhi, const double theDeltaPhi) throw (GeomAlgoAPI_Exception) + { + GeomAlgoAPI_ConeSegment aConeSegmentAlgo(theRMin1, theRMax1, theRMin2, theRMax2, + theZ, theStartPhi, theDeltaPhi); + + if (!aConeSegmentAlgo.check()) { + throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError()); + } + + aConeSegmentAlgo.build(); + + if(!aConeSegmentAlgo.isDone()) { + throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError()); + } + if (!aConeSegmentAlgo.checkValid("Cone Segment builder")) { + throw GeomAlgoAPI_Exception(aConeSegmentAlgo.getError()); + } + return aConeSegmentAlgo.shape(); + } }