1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAlgoAPI_Cylinder.cpp
4 // Created: 05 Jan 2016
5 // Author: Clarisse Genrault (CEA)
7 #include <GeomAlgoAPI_Cylinder.h>
11 #include <TopoDS_Edge.hxx>
12 #include <TopoDS_Shape.hxx>
14 #include <BRepPrimAPI_MakeCylinder.hxx>
16 //=================================================================================================
17 GeomAlgoAPI_Cylinder::GeomAlgoAPI_Cylinder()
21 //=================================================================================================
22 GeomAlgoAPI_Cylinder::GeomAlgoAPI_Cylinder(std::shared_ptr<GeomAPI_Ax2> theAxis,
23 const double theRadius,
24 const double theHeight)
32 //=================================================================================================
33 GeomAlgoAPI_Cylinder::GeomAlgoAPI_Cylinder(std::shared_ptr<GeomAPI_Ax2> theAxis,
34 const double theRadius,
35 const double theHeight,
36 const double theAngle)
45 //=================================================================================================
46 bool GeomAlgoAPI_Cylinder::check()
49 myError = "Cylinder builder :: axis is not valid.";
52 if (myRadius < Precision::Confusion()) {
53 myError = "Cylinder builder :: radius is negative or null.";
56 if (myHeight < Precision::Confusion()) {
57 myError = "Cylinder builder :: height is negative or null.";
61 if (myAngle < Precision::Angular() * 180./M_PI) {
62 myError = "Cylinder builder :: angle is negative or null.";
66 myError = "Cylinder builder :: angle greater than 360 degrees.";
73 //=================================================================================================
74 void GeomAlgoAPI_Cylinder::build()
76 myCreatedFaces.clear();
78 const gp_Ax2& anAxis = myAxis->impl<gp_Ax2>();
80 // Construct the cylinder
81 BRepPrimAPI_MakeCylinder *aCylinderMaker;
85 new BRepPrimAPI_MakeCylinder(anAxis, myRadius, myHeight, myAngle * M_PI / 180.);
87 aCylinderMaker = new BRepPrimAPI_MakeCylinder(anAxis, myRadius, myHeight);
90 aCylinderMaker->Build();
92 if (!aCylinderMaker->IsDone()) {
96 TopoDS_Shape aResult = aCylinderMaker->Shape();
97 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
98 aShape->setImpl(new TopoDS_Shape(aResult));
101 // Test on the shapes
102 if (!aShape.get() || aShape->isNull()) {
103 myError = "Cylinder builder :: resulting shape is null.";
107 setImpl(aCylinderMaker);