1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: SketchAPI_Arc.cpp
4 // Created: 09 June 2016
5 // Author: Dmitry Bobylev
7 #include "SketchAPI_Arc.h"
9 #include <GeomAPI_Pnt2d.h>
11 #include <ModelHighAPI_Double.h>
12 #include <ModelHighAPI_Selection.h>
13 #include <ModelHighAPI_Tools.h>
15 //==================================================================================================
16 SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature> & theFeature)
17 : SketchAPI_SketchEntity(theFeature)
22 //==================================================================================================
23 SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
24 double theCenterX, double theCenterY,
25 double theStartX, double theStartY,
26 double theEndX, double theEndY,
28 : SketchAPI_SketchEntity(theFeature)
31 setByCenterStartEnd(theCenterX, theCenterY, theStartX, theStartY, theEndX, theEndY, theInversed);
35 //==================================================================================================
36 SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
37 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
38 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
39 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
41 : SketchAPI_SketchEntity(theFeature)
44 setByCenterStartEnd(theCenter, theStart, theEnd, theInversed);
48 //==================================================================================================
49 SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
50 double theStartX, double theStartY,
51 double theEndX, double theEndY,
52 double thePassedX, double thePassedY)
53 : SketchAPI_SketchEntity(theFeature)
56 setByStartEndPassed(theStartX, theStartY, theEndX, theEndY, thePassedX, thePassedY);
60 //==================================================================================================
61 SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
62 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
63 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
64 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed)
65 : SketchAPI_SketchEntity(theFeature)
68 setByStartEndPassed(theStart, theEnd, thePassed);
72 //==================================================================================================
73 SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
74 const ModelHighAPI_RefAttr& theTangentPoint,
75 double theEndX, double theEndY,
77 : SketchAPI_SketchEntity(theFeature)
80 setByTangent(theTangentPoint, theEndX, theEndY, theInversed);
84 //==================================================================================================
85 SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
86 const ModelHighAPI_RefAttr& theTangentPoint,
87 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
89 : SketchAPI_SketchEntity(theFeature)
92 setByTangent(theTangentPoint, theEnd, theInversed);
96 //==================================================================================================
97 SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
98 const ModelHighAPI_Selection& theExternal)
99 : SketchAPI_SketchEntity(theFeature)
102 setByExternal(theExternal);
106 //==================================================================================================
107 SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
108 const std::string& theExternalName)
109 : SketchAPI_SketchEntity(theFeature)
112 setByExternalName(theExternalName);
116 //==================================================================================================
117 SketchAPI_Arc::~SketchAPI_Arc()
122 //==================================================================================================
123 void SketchAPI_Arc::setByCenterStartEnd(double theCenterX, double theCenterY,
124 double theStartX, double theStartY,
125 double theEndX, double theEndY,
128 fillAttribute(SketchPlugin_Arc::ARC_TYPE_CENTER_START_END(), myarcType);
129 fillAttribute(center(), theCenterX, theCenterY);
130 fillAttribute(startPoint(), theStartX, theStartY);
131 fillAttribute(endPoint(), theEndX, theEndY);
132 fillAttribute(theInversed, myinversed);
137 //==================================================================================================
138 void SketchAPI_Arc::setByCenterStartEnd(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
139 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
140 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
143 fillAttribute(SketchPlugin_Arc::ARC_TYPE_CENTER_START_END(), myarcType);
144 fillAttribute(theCenter, mycenter);
145 fillAttribute(theStart, mystartPoint);
146 fillAttribute(theEnd, myendPoint);
147 fillAttribute(theInversed, myinversed);
152 //==================================================================================================
153 void SketchAPI_Arc::setByStartEndPassed(double theStartX, double theStartY,
154 double theEndX, double theEndY,
155 double thePassedX, double thePassedY)
157 fillAttribute(SketchPlugin_Arc::ARC_TYPE_THREE_POINTS(), myarcType);
158 fillAttribute(startPoint(), theStartX, theStartY);
159 fillAttribute(endPoint(), theEndX, theEndY);
160 fillAttribute(passedPoint(), thePassedX, thePassedY);
165 //==================================================================================================
166 void SketchAPI_Arc::setByStartEndPassed(const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
167 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
168 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed)
170 fillAttribute(SketchPlugin_Arc::ARC_TYPE_THREE_POINTS(), myarcType);
171 fillAttribute(theStart, mystartPoint);
172 fillAttribute(theEnd, myendPoint);
173 fillAttribute(thePassed, mypassedPoint);
178 //==================================================================================================
179 void SketchAPI_Arc::setByTangent(const ModelHighAPI_RefAttr& theTangentPoint,
180 double theEndX, double theEndY,
183 fillAttribute(SketchPlugin_Arc::ARC_TYPE_TANGENT(), myarcType);
184 fillAttribute(theTangentPoint, mytangentPoint);
185 fillAttribute(endPoint(), theEndX, theEndY);
186 fillAttribute(theInversed, myinversed);
191 //==================================================================================================
192 void SketchAPI_Arc::setByTangent(const ModelHighAPI_RefAttr& theTangentPoint,
193 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
196 fillAttribute(SketchPlugin_Arc::ARC_TYPE_TANGENT(), myarcType);
197 fillAttribute(theTangentPoint, mytangentPoint);
198 fillAttribute(theEnd, myendPoint);
199 fillAttribute(theInversed, myinversed);
204 //==================================================================================================
205 void SketchAPI_Arc::setByExternal(const ModelHighAPI_Selection & theExternal)
207 fillAttribute(theExternal, external());
212 //==================================================================================================
213 void SketchAPI_Arc::setByExternalName(const std::string & theExternalName)
215 fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
220 //==================================================================================================
221 void SketchAPI_Arc::setRadius(double theRadius)
223 fillAttribute(ModelHighAPI_Double(theRadius), myradius);
228 //==================================================================================================
229 void SketchAPI_Arc::setAngle(double theAngle)
231 fillAttribute(ModelHighAPI_Double(theAngle), myangle);