1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAlgoAPI_Cone.cpp
4 // Created: 20 Mar 2017
5 // Author: Clarisse Genrault (CEA)
7 #include <GeomAlgoAPI_Cone.h>
11 #include <BRepPrimAPI_MakeCone.hxx>
13 //=================================================================================================
14 GeomAlgoAPI_Cone::GeomAlgoAPI_Cone()
18 //=================================================================================================
19 GeomAlgoAPI_Cone::GeomAlgoAPI_Cone(std::shared_ptr<GeomAPI_Ax2> theAxis,
20 const double theBaseRadius,
21 const double theTopRadius,
22 const double theHeight)
25 myBaseRadius = theBaseRadius;
26 myTopRadius = theTopRadius;
30 //=================================================================================================
31 bool GeomAlgoAPI_Cone::check()
34 myError = "Cone builder :: axis is not valid.";
36 } else if (myBaseRadius < Precision::Confusion() && myTopRadius < Precision::Confusion()) {
37 myError = "Cone builder :: base radius and top radius are negative or null.";
39 } else if (myBaseRadius < 0.) {
40 myError = "Cone builder :: base radius is negative.";
42 } else if (myTopRadius < 0.) {
43 myError = "Cone builder :: top radius is negative.";
45 } else if (fabs(myBaseRadius-myTopRadius) < Precision::Confusion()) {
46 myError = "Cone builder :: base radius and top radius are too close.";
48 } else if (myHeight < Precision::Confusion()) {
49 myError = "Cone builder :: height is negative or null.";
55 //=================================================================================================
56 void GeomAlgoAPI_Cone::build()
58 myCreatedFaces.clear();
60 const gp_Ax2& anAxis = myAxis->impl<gp_Ax2>();
62 // Construct the torus
63 BRepPrimAPI_MakeCone *aConeMaker =
64 new BRepPrimAPI_MakeCone(anAxis, myBaseRadius, myTopRadius, myHeight);
68 if (!aConeMaker->IsDone()) {
72 TopoDS_Shape aResult = aConeMaker->Shape();
73 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
74 aShape->setImpl(new TopoDS_Shape(aResult));
78 if (!aShape.get() || aShape->isNull()) {
79 myError = "Torus builder :: resulting shape is null.";