1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAlgoAPI_Sphere.h
4 // Created: 16 Mar 2017
5 // Author: Clarisse Genrault (CEA)
7 #include <GeomAlgoAPI_Sphere.h>
9 #include <BRepPrimAPI_MakeSphere.hxx>
11 //=================================================================================================
12 GeomAlgoAPI_Sphere::GeomAlgoAPI_Sphere()
16 //=================================================================================================
17 GeomAlgoAPI_Sphere::GeomAlgoAPI_Sphere(std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
18 const double theRadius)
20 myCenterPoint = theCenterPoint;
24 //=================================================================================================
25 bool GeomAlgoAPI_Sphere::check()
28 myError = "Sphere builder :: center is not valid.";
31 if (myRadius < Precision::Confusion()) {
32 myError = "Sphere builder :: radius is negative or null.";
38 //=================================================================================================
39 void GeomAlgoAPI_Sphere::build()
41 myCreatedFaces.clear();
43 const gp_Pnt& aCenterPoint = myCenterPoint->impl<gp_Pnt>();
45 // Construct the sphere
46 BRepPrimAPI_MakeSphere *aSphereMaker = new BRepPrimAPI_MakeSphere(aCenterPoint, myRadius);
48 aSphereMaker->Build();
50 if (!aSphereMaker->IsDone()) {
54 TopoDS_Shape aResult = aSphereMaker->Shape();
55 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
56 aShape->setImpl(new TopoDS_Shape(aResult));
60 if (!aShape.get() || aShape->isNull()) {
61 myError = "Sphere builder :: resulting shape is null.";
65 setImpl(aSphereMaker);