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)
29 //myBasePoint = theBasePoint;
35 //=================================================================================================
36 GeomAlgoAPI_Cylinder::GeomAlgoAPI_Cylinder(std::shared_ptr<GeomAPI_Ax2> theAxis,
37 const double theRadius,
38 const double theHeight,
39 const double theAngle)
48 //=================================================================================================
49 bool GeomAlgoAPI_Cylinder::check()
52 myError = "Cylinder builder :: axis is invalid.";
55 if (myRadius < Precision::Confusion()) {
56 myError = "Cylinder builder :: radius is negative or null.";
59 if (myHeight < Precision::Confusion()) {
60 myError = "Cylinder builder :: height is negative or null.";
64 if (myAngle < Precision::Angular() * 180./M_PI) {
65 myError = "Cylinder builder :: angle is negative or null.";
69 myError = "Cylinder builder :: angle greater than 360 degrees.";
76 //=================================================================================================
77 void GeomAlgoAPI_Cylinder::build()
79 myCreatedFaces.clear();
81 const gp_Ax2& anAxis = myAxis->impl<gp_Ax2>();
83 // Construct the cylinder
84 BRepPrimAPI_MakeCylinder *aCylinderMaker;
88 new BRepPrimAPI_MakeCylinder(anAxis, myRadius, myHeight, myAngle * M_PI / 180.);
90 aCylinderMaker = new BRepPrimAPI_MakeCylinder(anAxis, myRadius, myHeight);
93 aCylinderMaker->Build();
95 if (!aCylinderMaker->IsDone()) {
99 TopoDS_Shape aResult = aCylinderMaker->Shape();
100 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
101 aShape->setImpl(new TopoDS_Shape(aResult));
104 // Test on the shapes
105 if (!aShape.get() || aShape->isNull()) {
106 myError = "Cylinder builder :: resulting shape is null.";
110 setImpl(aCylinderMaker);