1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "SketchAPI_MacroArc.h"
23 #include <GeomAPI_Pnt2d.h>
25 #include <ModelHighAPI_Double.h>
26 #include <ModelHighAPI_Dumper.h>
27 #include <ModelHighAPI_Selection.h>
28 #include <ModelHighAPI_Tools.h>
30 #include <SketchPlugin_ConstraintCoincidence.h>
31 #include <SketchPlugin_ConstraintTangent.h>
33 /// Obtain constraints prepared by tangent arc
34 static std::list<FeaturePtr> tangentArcConstraints(const FeaturePtr& theArc);
36 //================================================================================================
37 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature> & theFeature)
38 : SketchAPI_SketchEntity(theFeature)
43 //================================================================================================
44 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
45 double theCenterX, double theCenterY,
46 double theStartX, double theStartY,
47 double theEndX, double theEndY,
49 : SketchAPI_SketchEntity(theFeature)
52 setByCenterStartEnd(theCenterX, theCenterY, theStartX,
53 theStartY, theEndX, theEndY, theInversed);
57 //================================================================================================
58 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
59 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
60 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
61 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
63 : SketchAPI_SketchEntity(theFeature)
66 setByCenterStartEnd(theCenter, theStart, theEnd, theInversed);
70 //================================================================================================
71 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
72 double theStartX, double theStartY,
73 double theEndX, double theEndY,
74 double thePassedX, double thePassedY)
75 : SketchAPI_SketchEntity(theFeature)
78 setByStartEndPassed(theStartX, theStartY, theEndX, theEndY, thePassedX, thePassedY);
82 //===============================================================================================
83 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
84 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
85 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
86 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed)
87 : SketchAPI_SketchEntity(theFeature)
90 setByStartEndPassed(theStart, theEnd, thePassed);
94 //================================================================================================
95 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
96 const ModelHighAPI_RefAttr& theTangentPoint,
97 double theEndX, double theEndY,
99 : SketchAPI_SketchEntity(theFeature)
102 setByTangent(theTangentPoint, theEndX, theEndY, theInversed);
106 //================================================================================================
107 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
108 const ModelHighAPI_RefAttr& theTangentPoint,
109 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
111 : SketchAPI_SketchEntity(theFeature)
114 setByTangent(theTangentPoint, theEnd, theInversed);
118 //================================================================================================
119 SketchAPI_MacroArc::~SketchAPI_MacroArc()
124 //================================================================================================
125 void SketchAPI_MacroArc::setByCenterStartEnd(double theCenterX, double theCenterY,
126 double theStartX, double theStartY,
127 double theEndX, double theEndY,
130 fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_CENTER_AND_POINTS(), myarcType);
131 fillAttribute(center(), theCenterX, theCenterY);
132 fillAttribute(startPoint1(), theStartX, theStartY);
133 fillAttribute(endPoint1(), theEndX, theEndY);
134 fillAttribute(theInversed, myreversed);
139 //================================================================================================
140 void SketchAPI_MacroArc::setByCenterStartEnd(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
141 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
142 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
145 fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_CENTER_AND_POINTS(), myarcType);
146 fillAttribute(theCenter, mycenter);
147 fillAttribute(theStart, mystartPoint1);
148 fillAttribute(theEnd, myendPoint1);
149 fillAttribute(theInversed, myreversed);
154 //================================================================================================
155 void SketchAPI_MacroArc::setByStartEndPassed(double theStartX, double theStartY,
156 double theEndX, double theEndY,
157 double thePassedX, double thePassedY)
159 fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_THREE_POINTS(), myarcType);
160 fillAttribute(startPoint2(), theStartX, theStartY);
161 fillAttribute(endPoint2(), theEndX, theEndY);
162 fillAttribute(passedPoint(), thePassedX, thePassedY);
167 //================================================================================================
168 void SketchAPI_MacroArc::setByStartEndPassed(const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
169 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
170 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed)
172 fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_THREE_POINTS(), myarcType);
173 fillAttribute(theStart, mystartPoint2);
174 fillAttribute(theEnd, myendPoint2);
175 fillAttribute(thePassed, mypassedPoint);
180 //================================================================================================
181 void SketchAPI_MacroArc::setByTangent(const ModelHighAPI_RefAttr& theTangentPoint,
182 double theEndX, double theEndY,
185 fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_TANGENT_EDGE(), myarcType);
186 fillAttribute(theTangentPoint, mytangentPoint);
187 fillAttribute(endPoint3(), theEndX, theEndY);
188 fillAttribute(theInversed, myreversed);
193 //================================================================================================
194 void SketchAPI_MacroArc::setByTangent(const ModelHighAPI_RefAttr& theTangentPoint,
195 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
198 fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_TANGENT_EDGE(), myarcType);
199 fillAttribute(theTangentPoint, mytangentPoint);
200 fillAttribute(theEnd, myendPoint3);
201 fillAttribute(theInversed, myreversed);