+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSphere(
+ std::shared_ptr<GeomAPI_Pnt> theCenterPoint, double theRadius) throw (GeomAlgoAPI_Exception)
+ {
+ GeomAlgoAPI_Sphere aSphereAlgo(theCenterPoint, theRadius);
+
+ if (!aSphereAlgo.check()) {
+ throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
+ }
+
+ aSphereAlgo.build();
+
+ if(!aSphereAlgo.isDone()) {
+ throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
+ }
+
+ if (!aSphereAlgo.checkValid("Sphere builder")) {
+ throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
+ }
+ return aSphereAlgo.shape();
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSphere(double theRadius)
+ throw (GeomAlgoAPI_Exception)
+ {
+ std::shared_ptr<GeomAPI_Pnt> aCenterPoint =
+ std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
+
+ GeomAlgoAPI_Sphere aSphereAlgo(aCenterPoint, theRadius);
+
+ if (!aSphereAlgo.check()) {
+ throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
+ }
+
+ aSphereAlgo.build();
+
+ if(!aSphereAlgo.isDone()) {
+ throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
+ }
+
+ if (!aSphereAlgo.checkValid("Sphere builder")) {
+ throw GeomAlgoAPI_Exception(aSphereAlgo.getError());
+ }
+ return aSphereAlgo.shape();
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTorus(
+ std::shared_ptr<GeomAPI_Pnt> theBasePoint,
+ std::shared_ptr<GeomAPI_Edge> theEdge,double theRadius, double theRingRadius)
+ throw (GeomAlgoAPI_Exception)
+ {
+ // Check if the base point is OK
+ if (!theBasePoint) {
+ throw GeomAlgoAPI_Exception("Torus builder :: the base point is not valid.");
+ }
+ // Check if the edge is OK
+ if (!theEdge) {
+ throw GeomAlgoAPI_Exception("Torus builder :: the axis is not valid.");
+ }
+
+ std::shared_ptr<GeomAPI_Ax2> anAxis;
+ anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
+ theEdge->line()->direction()));
+
+ GeomAlgoAPI_Torus aTorusAlgo(anAxis, theRadius, theRingRadius);
+
+ if (!aTorusAlgo.check()) {
+ throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
+ }
+
+ aTorusAlgo.build();
+
+ if(!aTorusAlgo.isDone()) {
+ throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
+ }
+
+ if (!aTorusAlgo.checkValid("Torus builder")) {
+ throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
+ }
+ return aTorusAlgo.shape();
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTorus(double theRadius,
+ double theRingRadius) throw (GeomAlgoAPI_Exception)
+ {
+ 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_Torus aTorusAlgo(anAxis, theRadius, theRingRadius);
+
+ if (!aTorusAlgo.check()) {
+ throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
+ }
+
+ aTorusAlgo.build();
+
+ if(!aTorusAlgo.isDone()) {
+ throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
+ }
+
+ if (!aTorusAlgo.checkValid("Torus builder")) {
+ throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
+ }
+ return aTorusAlgo.shape();
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCone(
+ std::shared_ptr<GeomAPI_Pnt> theBasePoint,
+ std::shared_ptr<GeomAPI_Edge> theEdge,
+ double theBaseRadius, double theTopRadius,
+ double theHeight) throw (GeomAlgoAPI_Exception)
+ {
+ // Check if the base point is OK
+ if (!theBasePoint) {
+ throw GeomAlgoAPI_Exception("Cone builder :: the base point is not valid.");
+ }
+ // Check if the edge is OK
+ if (!theEdge) {
+ throw GeomAlgoAPI_Exception("Cone builder :: the axis is not valid.");
+ }
+
+ 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);
+
+ if (!aConeAlgo.check()) {
+ throw GeomAlgoAPI_Exception(aConeAlgo.getError());
+ }
+
+ aConeAlgo.build();
+
+ if(!aConeAlgo.isDone()) {
+ throw GeomAlgoAPI_Exception(aConeAlgo.getError());
+ }
+
+ if (!aConeAlgo.checkValid("Cone builder")) {
+ throw GeomAlgoAPI_Exception(aConeAlgo.getError());
+ }
+ return aConeAlgo.shape();
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCone(
+ double theBaseRadius, double theTopRadius,
+ double theHeight) throw (GeomAlgoAPI_Exception)
+ {
+ 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);
+
+ if (!aConeAlgo.check()) {
+ throw GeomAlgoAPI_Exception(aConeAlgo.getError());
+ }
+
+ aConeAlgo.build();
+
+ if(!aConeAlgo.isDone()) {
+ throw GeomAlgoAPI_Exception(aConeAlgo.getError());
+ }
+
+ if (!aConeAlgo.checkValid("Cone builder")) {
+ throw GeomAlgoAPI_Exception(aConeAlgo.getError());
+ }
+ return aConeAlgo.shape();
+ }
+