1 // Copyright (C) 2017-2021 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: GeomAlgoAPI_Sphere.h
21 // Created: 16 Mar 2017
22 // Author: Clarisse Genrault (CEA)
24 #include <GeomAlgoAPI_Sphere.h>
26 #include <BRepPrimAPI_MakeSphere.hxx>
28 //=================================================================================================
29 GeomAlgoAPI_Sphere::GeomAlgoAPI_Sphere(std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
30 const double theRadius)
32 myCenterPoint = theCenterPoint;
36 //=================================================================================================
37 bool GeomAlgoAPI_Sphere::check()
40 myError = "Sphere builder :: center is not valid.";
43 if (myRadius < Precision::Confusion()) {
44 myError = "Sphere builder :: radius is negative or null.";
50 //=================================================================================================
51 void GeomAlgoAPI_Sphere::build()
53 myCreatedFaces.clear();
55 const gp_Pnt& aCenterPoint = myCenterPoint->impl<gp_Pnt>();
57 // Construct the sphere
58 BRepPrimAPI_MakeSphere *aSphereMaker = new BRepPrimAPI_MakeSphere(aCenterPoint, myRadius);
60 aSphereMaker->Build();
62 if (!aSphereMaker->IsDone()) {
66 TopoDS_Shape aResult = aSphereMaker->Shape();
67 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
68 aShape->setImpl(new TopoDS_Shape(aResult));
72 if (!aShape.get() || aShape->isNull()) {
73 myError = "Sphere builder :: resulting shape is null.";
77 setImpl(aSphereMaker);