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(std::shared_ptr<GeomAPI_Ax2> theAxis,
15 const double theBaseRadius,
16 const double theTopRadius,
17 const double theHeight)
20 myBaseRadius = theBaseRadius;
21 myTopRadius = theTopRadius;
25 //=================================================================================================
26 bool GeomAlgoAPI_Cone::check()
29 myError = "Cone builder :: axis is not valid.";
31 } else if (myBaseRadius < Precision::Confusion() && myTopRadius < Precision::Confusion()) {
32 myError = "Cone builder :: base radius and top radius are negative or null.";
34 } else if (myBaseRadius < 0.) {
35 myError = "Cone builder :: base radius is negative.";
37 } else if (myTopRadius < 0.) {
38 myError = "Cone builder :: top radius is negative.";
40 } else if (fabs(myBaseRadius-myTopRadius) < Precision::Confusion()) {
41 myError = "Cone builder :: base radius and top radius are too close.";
43 } else if (myHeight < Precision::Confusion()) {
44 myError = "Cone builder :: height is negative or null.";
50 //=================================================================================================
51 void GeomAlgoAPI_Cone::build()
53 myCreatedFaces.clear();
55 const gp_Ax2& anAxis = myAxis->impl<gp_Ax2>();
57 // Construct the torus
58 BRepPrimAPI_MakeCone *aConeMaker =
59 new BRepPrimAPI_MakeCone(anAxis, myBaseRadius, myTopRadius, myHeight);
63 if (!aConeMaker->IsDone()) {
67 TopoDS_Shape aResult = aConeMaker->Shape();
68 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
69 aShape->setImpl(new TopoDS_Shape(aResult));
73 if (!aShape.get() || aShape->isNull()) {
74 myError = "Torus builder :: resulting shape is null.";