1 // Copyright (C) 2017-2019 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: PrimitivesAPI_Sphere.h
21 // Created: 16 Mar 2017
22 // Author: Clarisse Genrault
24 #include "PrimitivesAPI_Sphere.h"
26 #include <ModelHighAPI_Dumper.h>
27 #include <ModelHighAPI_Selection.h>
28 #include <ModelHighAPI_Tools.h>
30 //==================================================================================================
31 PrimitivesAPI_Sphere::PrimitivesAPI_Sphere(const std::shared_ptr<ModelAPI_Feature>& theFeature)
32 : ModelHighAPI_Interface(theFeature)
37 //==================================================================================================
38 PrimitivesAPI_Sphere::PrimitivesAPI_Sphere(const std::shared_ptr<ModelAPI_Feature>& theFeature,
39 const ModelHighAPI_Selection& theCenterPoint,
40 const ModelHighAPI_Double& theRadius)
41 : ModelHighAPI_Interface(theFeature)
44 fillAttribute(theCenterPoint, centerPoint());
49 //==================================================================================================
50 PrimitivesAPI_Sphere::~PrimitivesAPI_Sphere()
54 //==================================================================================================
55 void PrimitivesAPI_Sphere::setCenterPoint(const ModelHighAPI_Selection& theCenterPoint)
57 fillAttribute(theCenterPoint, centerPoint());
61 //==================================================================================================
62 void PrimitivesAPI_Sphere::setRadius(const ModelHighAPI_Double& theRadius)
64 fillAttribute(theRadius, radius());
68 //==================================================================================================
69 void PrimitivesAPI_Sphere::dump(ModelHighAPI_Dumper& theDumper) const
71 FeaturePtr aBase = feature();
72 const std::string& aDocName = theDumper.name(aBase->document());
74 theDumper << aBase << " = model.addSphere(" << aDocName;
76 AttributeSelectionPtr anAttrCenterPoint =
77 aBase->selection(PrimitivesPlugin_Sphere::CENTER_POINT_ID());
78 AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Sphere::RADIUS_ID());
79 theDumper << ", " << anAttrCenterPoint << ", " << anAttrRadius;
81 theDumper << ")" << std::endl;
84 //==================================================================================================
85 SpherePtr addSphere(const std::shared_ptr<ModelAPI_Document>& thePart,
86 const ModelHighAPI_Selection& theCenterPoint,
87 const ModelHighAPI_Double& theRadius)
89 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Sphere::ID());
90 return SpherePtr(new PrimitivesAPI_Sphere(aFeature, theCenterPoint, theRadius));
93 //==================================================================================================
94 SpherePtr addSphere(const std::shared_ptr<ModelAPI_Document>& thePart,
95 const ModelHighAPI_Double& theRadius)
97 ModelHighAPI_Selection aCenterPoint("VERTEX", "PartSet/Origin");
98 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Sphere::ID());
99 return SpherePtr(new PrimitivesAPI_Sphere(aFeature, aCenterPoint, theRadius));