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(std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
13 const double theRadius)
15 myCenterPoint = theCenterPoint;
19 //=================================================================================================
20 bool GeomAlgoAPI_Sphere::check()
23 myError = "Sphere builder :: center is not valid.";
26 if (myRadius < Precision::Confusion()) {
27 myError = "Sphere builder :: radius is negative or null.";
33 //=================================================================================================
34 void GeomAlgoAPI_Sphere::build()
36 myCreatedFaces.clear();
38 const gp_Pnt& aCenterPoint = myCenterPoint->impl<gp_Pnt>();
40 // Construct the sphere
41 BRepPrimAPI_MakeSphere *aSphereMaker = new BRepPrimAPI_MakeSphere(aCenterPoint, myRadius);
43 aSphereMaker->Build();
45 if (!aSphereMaker->IsDone()) {
49 TopoDS_Shape aResult = aSphereMaker->Shape();
50 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
51 aShape->setImpl(new TopoDS_Shape(aResult));
55 if (!aShape.get() || aShape->isNull()) {
56 myError = "Sphere builder :: resulting shape is null.";
60 setImpl(aSphereMaker);