1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAlgoAPI_Torus.cpp
4 // Created: 20 Mar 2017
5 // Author: Clarisse Genrault (CEA)
7 #include <GeomAlgoAPI_Torus.h>
11 #include <BRepPrimAPI_MakeTorus.hxx>
13 //=================================================================================================
14 GeomAlgoAPI_Torus::GeomAlgoAPI_Torus()
18 //=================================================================================================
19 GeomAlgoAPI_Torus::GeomAlgoAPI_Torus(std::shared_ptr<GeomAPI_Ax2> theAxis,
20 const double theRadius,
21 const double theRingRadius)
25 myRingRadius = theRingRadius;
28 //=================================================================================================
29 bool GeomAlgoAPI_Torus::check()
32 myError = "Torus builder :: axis is not valid.";
34 } else if (myRadius < Precision::Confusion()) {
35 myError = "Torus builder :: radius is negative or null.";
37 } else if (myRingRadius < Precision::Confusion()) {
38 myError = "Torus builder :: ring radius is negative or null.";
40 } else if (myRadius < myRingRadius) {
41 myError = "Torus builder :: ring radius is greater than the radius.";
47 //=================================================================================================
48 void GeomAlgoAPI_Torus::build()
50 myCreatedFaces.clear();
52 const gp_Ax2& anAxis = myAxis->impl<gp_Ax2>();
54 // Construct the torus
55 BRepPrimAPI_MakeTorus *aTorusMaker =
56 new BRepPrimAPI_MakeTorus(anAxis, myRadius, myRingRadius);
60 if (!aTorusMaker->IsDone()) {
64 TopoDS_Shape aResult = aTorusMaker->Shape();
65 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
66 aShape->setImpl(new TopoDS_Shape(aResult));
70 if (!aShape.get() || aShape->isNull()) {
71 myError = "Torus builder :: resulting shape is null.";