+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
+ std::shared_ptr<GeomAPI_Pnt> theBasePoint, std::shared_ptr<GeomAPI_Edge> theEdge,
+ double theRadius, double theHeight) throw (GeomAlgoAPI_Exception)
+ {
+ // Check if the base point is OK
+ if (!theBasePoint) {
+ throw GeomAlgoAPI_Exception("Cylinder builder :: the base point is not valid.");
+ }
+ // Check if the edge is OK
+ if (!theEdge) {
+ throw GeomAlgoAPI_Exception("Cylinder 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_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<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
+ std::shared_ptr<GeomAPI_Pnt> theBasePoint, std::shared_ptr<GeomAPI_Edge> theEdge,
+ double theRadius, double theHeight, double theAngle) throw (GeomAlgoAPI_Exception)
+ {
+ std::shared_ptr<GeomAPI_Ax2> anAxis;
+ anAxis = std::shared_ptr<GeomAPI_Ax2>(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<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
+ double theRadius, 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_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<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
+ double theRadius, double theHeight, double theAngle) 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_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();
+ }
+
+ //===============================================================================================