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(std::shared_ptr<GeomAPI_Ax2> theAxis,
15 const double theRadius,
16 const double theRingRadius)
20 myRingRadius = theRingRadius;
23 //=================================================================================================
24 bool GeomAlgoAPI_Torus::check()
27 myError = "Torus builder :: axis is not valid.";
29 } else if (myRadius < Precision::Confusion()) {
30 myError = "Torus builder :: radius is negative or null.";
32 } else if (myRingRadius < Precision::Confusion()) {
33 myError = "Torus builder :: ring radius is negative or null.";
35 } else if (myRadius < myRingRadius) {
36 myError = "Torus builder :: ring radius is greater than the radius.";
42 //=================================================================================================
43 void GeomAlgoAPI_Torus::build()
45 myCreatedFaces.clear();
47 const gp_Ax2& anAxis = myAxis->impl<gp_Ax2>();
49 // Construct the torus
50 BRepPrimAPI_MakeTorus *aTorusMaker =
51 new BRepPrimAPI_MakeTorus(anAxis, myRadius, myRingRadius);
55 if (!aTorusMaker->IsDone()) {
59 TopoDS_Shape aResult = aTorusMaker->Shape();
60 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
61 aShape->setImpl(new TopoDS_Shape(aResult));
65 if (!aShape.get() || aShape->isNull()) {
66 myError = "Torus builder :: resulting shape is null.";