1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: SketchAPI_MacroArc.cpp
4 // Created: 09 June 2016
5 // Author: Dmitry Bobylev
7 #include "SketchAPI_MacroArc.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 #include <SketchPlugin_ConstraintCoincidence.h>
17 #include <SketchPlugin_ConstraintTangent.h>
19 /// Obtain constraints prepared by tangent arc
20 static std::list<FeaturePtr> tangentArcConstraints(const FeaturePtr& theArc);
22 //================================================================================================
23 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature> & theFeature)
24 : SketchAPI_SketchEntity(theFeature)
29 //================================================================================================
30 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
31 double theCenterX, double theCenterY,
32 double theStartX, double theStartY,
33 double theEndX, double theEndY,
35 : SketchAPI_SketchEntity(theFeature)
38 setByCenterStartEnd(theCenterX, theCenterY, theStartX,
39 theStartY, theEndX, theEndY, theInversed);
43 //================================================================================================
44 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
45 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
46 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
47 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
49 : SketchAPI_SketchEntity(theFeature)
52 setByCenterStartEnd(theCenter, theStart, theEnd, theInversed);
56 //================================================================================================
57 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
58 double theStartX, double theStartY,
59 double theEndX, double theEndY,
60 double thePassedX, double thePassedY)
61 : SketchAPI_SketchEntity(theFeature)
64 setByStartEndPassed(theStartX, theStartY, theEndX, theEndY, thePassedX, thePassedY);
68 //===============================================================================================
69 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
70 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
71 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
72 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed)
73 : SketchAPI_SketchEntity(theFeature)
76 setByStartEndPassed(theStart, theEnd, thePassed);
80 //================================================================================================
81 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
82 const ModelHighAPI_RefAttr& theTangentPoint,
83 double theEndX, double theEndY,
85 : SketchAPI_SketchEntity(theFeature)
88 setByTangent(theTangentPoint, theEndX, theEndY, theInversed);
92 //================================================================================================
93 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
94 const ModelHighAPI_RefAttr& theTangentPoint,
95 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
97 : SketchAPI_SketchEntity(theFeature)
100 setByTangent(theTangentPoint, theEnd, theInversed);
104 //================================================================================================
105 SketchAPI_MacroArc::~SketchAPI_MacroArc()
110 //================================================================================================
111 void SketchAPI_MacroArc::setByCenterStartEnd(double theCenterX, double theCenterY,
112 double theStartX, double theStartY,
113 double theEndX, double theEndY,
116 fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_CENTER_AND_POINTS(), myarcType);
117 fillAttribute(center(), theCenterX, theCenterY);
118 fillAttribute(startPoint1(), theStartX, theStartY);
119 fillAttribute(endPoint1(), theEndX, theEndY);
120 fillAttribute(theInversed, myreversed);
125 //================================================================================================
126 void SketchAPI_MacroArc::setByCenterStartEnd(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
127 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
128 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
131 fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_CENTER_AND_POINTS(), myarcType);
132 fillAttribute(theCenter, mycenter);
133 fillAttribute(theStart, mystartPoint1);
134 fillAttribute(theEnd, myendPoint1);
135 fillAttribute(theInversed, myreversed);
140 //================================================================================================
141 void SketchAPI_MacroArc::setByStartEndPassed(double theStartX, double theStartY,
142 double theEndX, double theEndY,
143 double thePassedX, double thePassedY)
145 fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_THREE_POINTS(), myarcType);
146 fillAttribute(startPoint2(), theStartX, theStartY);
147 fillAttribute(endPoint2(), theEndX, theEndY);
148 fillAttribute(passedPoint(), thePassedX, thePassedY);
153 //================================================================================================
154 void SketchAPI_MacroArc::setByStartEndPassed(const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
155 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
156 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed)
158 fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_THREE_POINTS(), myarcType);
159 fillAttribute(theStart, mystartPoint2);
160 fillAttribute(theEnd, myendPoint2);
161 fillAttribute(thePassed, mypassedPoint);
166 //================================================================================================
167 void SketchAPI_MacroArc::setByTangent(const ModelHighAPI_RefAttr& theTangentPoint,
168 double theEndX, double theEndY,
171 fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_TANGENT_EDGE(), myarcType);
172 fillAttribute(theTangentPoint, mytangentPoint);
173 fillAttribute(endPoint3(), theEndX, theEndY);
174 fillAttribute(theInversed, myreversed);
179 //================================================================================================
180 void SketchAPI_MacroArc::setByTangent(const ModelHighAPI_RefAttr& theTangentPoint,
181 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
184 fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_TANGENT_EDGE(), myarcType);
185 fillAttribute(theTangentPoint, mytangentPoint);
186 fillAttribute(theEnd, myendPoint3);
187 fillAttribute(theInversed, myreversed);