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>
18 //=================================================================================================
19 GeomAlgoAPI_Cylinder::GeomAlgoAPI_Cylinder()
23 //=================================================================================================
24 GeomAlgoAPI_Cylinder::GeomAlgoAPI_Cylinder(std::shared_ptr<GeomAPI_Ax2> theAxis,
25 const double theRadius,
26 const double theHeight)
34 //=================================================================================================
35 GeomAlgoAPI_Cylinder::GeomAlgoAPI_Cylinder(std::shared_ptr<GeomAPI_Ax2> theAxis,
36 const double theRadius,
37 const double theHeight,
38 const double theAngle)
47 //=================================================================================================
48 bool GeomAlgoAPI_Cylinder::check()
51 myError = "Cylinder builder :: axis is not valid.";
54 if (myRadius < Precision::Confusion()) {
55 myError = "Cylinder builder :: radius is negative or null.";
58 if (myHeight < Precision::Confusion()) {
59 myError = "Cylinder builder :: height is negative or null.";
63 if (myAngle < Precision::Angular() * 180./M_PI) {
64 myError = "Cylinder builder :: angle is negative or null.";
68 myError = "Cylinder builder :: angle greater than 360 degrees.";
75 //=================================================================================================
76 void GeomAlgoAPI_Cylinder::build()
78 myCreatedFaces.clear();
80 const gp_Ax2& anAxis = myAxis->impl<gp_Ax2>();
82 // Construct the cylinder
83 BRepPrimAPI_MakeCylinder *aCylinderMaker;
87 new BRepPrimAPI_MakeCylinder(anAxis, myRadius, myHeight, myAngle * M_PI / 180.);
89 aCylinderMaker = new BRepPrimAPI_MakeCylinder(anAxis, myRadius, myHeight);
92 aCylinderMaker->Build();
94 if (!aCylinderMaker->IsDone()) {
98 TopoDS_Shape aResult = aCylinderMaker->Shape();
99 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
100 aShape->setImpl(new TopoDS_Shape(aResult));
103 // Test on the shapes
104 if (!aShape.get() || aShape->isNull()) {
105 myError = "Cylinder builder :: resulting shape is null.";
109 setImpl(aCylinderMaker);