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_Selection.h>
13 #include <ModelHighAPI_Tools.h>
15 //==================================================================================================
16 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature> & theFeature)
17 : SketchAPI_SketchEntity(theFeature)
22 //==================================================================================================
23 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
27 : SketchAPI_SketchEntity(theFeature)
30 setByCenterAndRadius(theCenterX, theCenterY, theRadius);
34 //==================================================================================================
35 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
36 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
38 : SketchAPI_SketchEntity(theFeature)
41 setByCenterAndRadius(theCenter, theRadius);
45 //==================================================================================================
46 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
47 double theX1, double theY1,
48 double theX2, double theY2,
49 double theX3, double theY3)
50 : SketchAPI_SketchEntity(theFeature)
53 setByThreePoints(theX1, theY1, theX2, theY2, theX3, theY3);
57 //==================================================================================================
58 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
59 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
60 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
61 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3)
62 : SketchAPI_SketchEntity(theFeature)
65 setByThreePoints(thePoint1, thePoint2, thePoint3);
69 //==================================================================================================
70 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
71 const ModelHighAPI_Selection& theExternal)
72 : SketchAPI_SketchEntity(theFeature)
75 setByExternal(theExternal);
79 //==================================================================================================
80 SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr<ModelAPI_Feature>& theFeature,
81 const std::string& theExternalName)
82 : SketchAPI_SketchEntity(theFeature)
85 setByExternalName(theExternalName);
89 //==================================================================================================
90 SketchAPI_Circle::~SketchAPI_Circle()
95 //==================================================================================================
96 void SketchAPI_Circle::setByCenterAndRadius(double theCenterX, double theCenterY, double theRadius)
98 fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_CENTER_AND_RADIUS(), mycircleType);
99 fillAttribute(center(), theCenterX, theCenterY);
100 fillAttribute(theRadius, myradius);
105 //==================================================================================================
106 void SketchAPI_Circle::setByCenterAndRadius(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
109 fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_CENTER_AND_RADIUS(), mycircleType);
110 fillAttribute(theCenter, mycenter);
111 fillAttribute(theRadius, myradius);
116 //==================================================================================================
117 void SketchAPI_Circle::setByThreePoints(double theX1, double theY1,
118 double theX2, double theY2,
119 double theX3, double theY3)
121 fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType);
122 fillAttribute(firstPoint(), theX1, theY1);
123 fillAttribute(secondPoint(), theX2, theY2);
124 fillAttribute(thirdPoint(), theX3, theY3);
129 //==================================================================================================
130 void SketchAPI_Circle::setByThreePoints(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
131 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
132 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3)
134 fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType);
135 fillAttribute(thePoint1, myfirstPoint);
136 fillAttribute(thePoint2, mysecondPoint);
137 fillAttribute(thePoint3, mythirdPoint);
142 //==================================================================================================
143 void SketchAPI_Circle::setByExternal(const ModelHighAPI_Selection & theExternal)
145 fillAttribute(theExternal, external());
150 //==================================================================================================
151 void SketchAPI_Circle::setByExternalName(const std::string & theExternalName)
153 fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
158 //==================================================================================================
159 void SketchAPI_Circle::setCenter(double theX, double theY)
161 fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_CENTER_AND_RADIUS(), mycircleType);
162 fillAttribute(center(), theX, theY);
167 //==================================================================================================
168 void SketchAPI_Circle::setCenter(const std::shared_ptr<GeomAPI_Pnt2d> & theCenter)
170 fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_CENTER_AND_RADIUS(), mycircleType);
171 fillAttribute(theCenter, mycenter);
176 //==================================================================================================
177 void SketchAPI_Circle::setRadius(double theRadius)
179 fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_CENTER_AND_RADIUS(), mycircleType);
180 fillAttribute(ModelHighAPI_Double(theRadius), myradius);
185 //==================================================================================================
186 void SketchAPI_Circle::setFirstPoint(double theX, double theY)
188 fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType);
189 fillAttribute(firstPoint(), theX, theY);
194 //==================================================================================================
195 void SketchAPI_Circle::setFirstPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
197 fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType);
198 fillAttribute(thePoint, myfirstPoint);
203 //==================================================================================================
204 void SketchAPI_Circle::setSecondPoint(double theX, double theY)
206 fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType);
207 fillAttribute(secondPoint(), theX, theY);
212 //==================================================================================================
213 void SketchAPI_Circle::setSecondPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
215 fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType);
216 fillAttribute(thePoint, mysecondPoint);
221 //==================================================================================================
222 void SketchAPI_Circle::setThirdPoint(double theX, double theY)
224 fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType);
225 fillAttribute(thirdPoint(), theX, theY);
230 //==================================================================================================
231 void SketchAPI_Circle::setThirdPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
233 fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType);
234 fillAttribute(thePoint, mythirdPoint);