1 // Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
3 // File: PrimitivesAPI_Sphere.h
4 // Created: 16 Mar 2017
5 // Author: Clarisse Genrault
7 #include "PrimitivesAPI_Sphere.h"
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Selection.h>
11 #include <ModelHighAPI_Tools.h>
13 //==================================================================================================
14 PrimitivesAPI_Sphere::PrimitivesAPI_Sphere(const std::shared_ptr<ModelAPI_Feature>& theFeature)
15 : ModelHighAPI_Interface(theFeature)
20 //==================================================================================================
21 PrimitivesAPI_Sphere::PrimitivesAPI_Sphere(const std::shared_ptr<ModelAPI_Feature>& theFeature,
22 const ModelHighAPI_Selection& theCenterPoint,
23 const ModelHighAPI_Double& theRadius)
24 : ModelHighAPI_Interface(theFeature)
27 fillAttribute(theCenterPoint, centerPoint());
32 //==================================================================================================
33 PrimitivesAPI_Sphere::~PrimitivesAPI_Sphere()
37 //==================================================================================================
38 void PrimitivesAPI_Sphere::setCenterPoint(const ModelHighAPI_Selection& theCenterPoint)
40 fillAttribute(theCenterPoint, centerPoint());
44 //==================================================================================================
45 void PrimitivesAPI_Sphere::setRadius(const ModelHighAPI_Double& theRadius)
47 fillAttribute(theRadius, radius());
51 //==================================================================================================
52 void PrimitivesAPI_Sphere::dump(ModelHighAPI_Dumper& theDumper) const
54 FeaturePtr aBase = feature();
55 const std::string& aDocName = theDumper.name(aBase->document());
57 theDumper << aBase << " = model.addSphere(" << aDocName;
59 AttributeSelectionPtr anAttrCenterPoint =
60 aBase->selection(PrimitivesPlugin_Sphere::CENTER_POINT_ID());
61 AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Sphere::RADIUS_ID());
62 theDumper << ", " << anAttrCenterPoint << ", " << anAttrRadius;
64 theDumper << ")" << std::endl;
67 //==================================================================================================
68 SpherePtr addSphere(const std::shared_ptr<ModelAPI_Document>& thePart,
69 const ModelHighAPI_Selection& theCenterPoint,
70 const ModelHighAPI_Double& theRadius)
72 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Sphere::ID());
73 return SpherePtr(new PrimitivesAPI_Sphere(aFeature, theCenterPoint, theRadius));
76 //==================================================================================================
77 SpherePtr addSphere(const std::shared_ptr<ModelAPI_Document>& thePart,
78 const ModelHighAPI_Double& theRadius)
80 ModelHighAPI_Selection aCenterPoint("VERTEX", "PartSet/Origin");
81 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Sphere::ID());
82 return SpherePtr(new PrimitivesAPI_Sphere(aFeature, aCenterPoint, theRadius));