1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: SketchAPI_Circle.cpp
4 // Created: 09 June 2016
5 // Author: Dmitry Bobylev
7 #include "SketchAPI_Circle.h"
9 #include <GeomAPI_Pnt2d.h>
11 #include <ModelHighAPI_Double.h>
12 #include <ModelHighAPI_Dumper.h>
13 #include <ModelHighAPI_Selection.h>
14 #include <ModelHighAPI_Tools.h>
16 //==================================================================================================
17 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature> & theFeature)
18 : SketchAPI_SketchEntity(theFeature)
23 //==================================================================================================
24 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
28 : SketchAPI_SketchEntity(theFeature)
31 setByCenterAndRadius(theCenterX, theCenterY, theRadius);
35 //==================================================================================================
36 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
37 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
39 : SketchAPI_SketchEntity(theFeature)
42 setByCenterAndRadius(theCenter, theRadius);
46 //==================================================================================================
47 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
48 const ModelHighAPI_Selection& theExternal)
49 : SketchAPI_SketchEntity(theFeature)
52 setByExternal(theExternal);
56 //==================================================================================================
57 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
58 const std::string& theExternalName)
59 : SketchAPI_SketchEntity(theFeature)
62 setByExternalName(theExternalName);
66 //==================================================================================================
67 SketchAPI_Circle::~SketchAPI_Circle()
72 //==================================================================================================
73 void SketchAPI_Circle::setByCenterAndRadius(double theCenterX, double theCenterY, double theRadius)
75 fillAttribute(center(), theCenterX, theCenterY);
76 fillAttribute(theRadius, myradius);
81 //==================================================================================================
82 void SketchAPI_Circle::setByCenterAndRadius(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
85 fillAttribute(theCenter, mycenter);
86 fillAttribute(theRadius, myradius);
91 //==================================================================================================
92 void SketchAPI_Circle::setByExternal(const ModelHighAPI_Selection & theExternal)
94 fillAttribute(theExternal, external());
99 //==================================================================================================
100 void SketchAPI_Circle::setByExternalName(const std::string & theExternalName)
102 fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
107 //==================================================================================================
108 void SketchAPI_Circle::setCenter(double theX, double theY)
110 fillAttribute(center(), theX, theY);
115 //==================================================================================================
116 void SketchAPI_Circle::setCenter(const std::shared_ptr<GeomAPI_Pnt2d> & theCenter)
118 fillAttribute(theCenter, mycenter);
123 //==================================================================================================
124 void SketchAPI_Circle::setRadius(double theRadius)
126 fillAttribute(ModelHighAPI_Double(theRadius), myradius);
131 //==================================================================================================
132 void SketchAPI_Circle::dump(ModelHighAPI_Dumper& theDumper) const
135 return; // no need to dump copied feature
137 FeaturePtr aBase = feature();
138 const std::string& aSketchName = theDumper.parentName(aBase);
140 AttributeSelectionPtr anExternal = aBase->selection(SketchPlugin_SketchEntity::EXTERNAL_ID());
141 if (anExternal->context()) {
142 // circle is external
143 theDumper << aBase << " = " << aSketchName << ".addCircle(" << anExternal << ")" << std::endl;
145 // circle given by center and radius
146 theDumper << aBase << " = " << aSketchName << ".addCircle("
147 << center() << ", " << radius() << ")" << std::endl;
149 // dump "auxiliary" flag if necessary
150 SketchAPI_SketchEntity::dump(theDumper);