1 // Copyright (C) 2014-2019 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 email : webmaster.salome@opencascade.com
20 #include "SketchAPI_MacroArc.h"
22 #include <GeomAPI_Pnt2d.h>
24 #include <ModelHighAPI_Double.h>
25 #include <ModelHighAPI_Dumper.h>
26 #include <ModelHighAPI_Selection.h>
27 #include <ModelHighAPI_Tools.h>
29 #include <SketchPlugin_ConstraintCoincidence.h>
30 #include <SketchPlugin_ConstraintTangent.h>
32 /// Obtain constraints prepared by tangent arc
33 static std::list<FeaturePtr> tangentArcConstraints(const FeaturePtr& theArc);
35 //================================================================================================
36 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature> & theFeature)
37 : SketchAPI_SketchEntity(theFeature)
42 //================================================================================================
43 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
44 double theCenterX, double theCenterY,
45 double theStartX, double theStartY,
46 double theEndX, double theEndY,
48 : SketchAPI_SketchEntity(theFeature)
51 setByCenterStartEnd(theCenterX, theCenterY, theStartX,
52 theStartY, theEndX, theEndY, theInversed);
56 //================================================================================================
57 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
58 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
59 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
60 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
62 : SketchAPI_SketchEntity(theFeature)
65 setByCenterStartEnd(theCenter, theStart, theEnd, theInversed);
69 //================================================================================================
70 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
71 double theStartX, double theStartY,
72 double theEndX, double theEndY,
73 double thePassedX, double thePassedY)
74 : SketchAPI_SketchEntity(theFeature)
77 setByStartEndPassed(theStartX, theStartY, theEndX, theEndY, thePassedX, thePassedY);
81 //===============================================================================================
82 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
83 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
84 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
85 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed)
86 : SketchAPI_SketchEntity(theFeature)
89 setByStartEndPassed(theStart, theEnd, thePassed);
93 //================================================================================================
94 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
95 const ModelHighAPI_RefAttr& theTangentPoint,
96 double theEndX, double theEndY,
98 : SketchAPI_SketchEntity(theFeature)
101 setByTangent(theTangentPoint, theEndX, theEndY, theInversed);
105 //================================================================================================
106 SketchAPI_MacroArc::SketchAPI_MacroArc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
107 const ModelHighAPI_RefAttr& theTangentPoint,
108 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
110 : SketchAPI_SketchEntity(theFeature)
113 setByTangent(theTangentPoint, theEnd, theInversed);
117 //================================================================================================
118 SketchAPI_MacroArc::~SketchAPI_MacroArc()
123 //================================================================================================
124 void SketchAPI_MacroArc::setByCenterStartEnd(double theCenterX, double theCenterY,
125 double theStartX, double theStartY,
126 double theEndX, double theEndY,
129 fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_CENTER_AND_POINTS(), myarcType);
130 fillAttribute(center(), theCenterX, theCenterY);
131 fillAttribute(startPoint1(), theStartX, theStartY);
132 fillAttribute(endPoint1(), theEndX, theEndY);
133 fillAttribute(theInversed, myreversed);
138 //================================================================================================
139 void SketchAPI_MacroArc::setByCenterStartEnd(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
140 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
141 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
144 fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_CENTER_AND_POINTS(), myarcType);
145 fillAttribute(theCenter, mycenter);
146 fillAttribute(theStart, mystartPoint1);
147 fillAttribute(theEnd, myendPoint1);
148 fillAttribute(theInversed, myreversed);
153 //================================================================================================
154 void SketchAPI_MacroArc::setByStartEndPassed(double theStartX, double theStartY,
155 double theEndX, double theEndY,
156 double thePassedX, double thePassedY)
158 fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_THREE_POINTS(), myarcType);
159 fillAttribute(startPoint2(), theStartX, theStartY);
160 fillAttribute(endPoint2(), theEndX, theEndY);
161 fillAttribute(passedPoint(), thePassedX, thePassedY);
166 //================================================================================================
167 void SketchAPI_MacroArc::setByStartEndPassed(const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
168 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
169 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed)
171 fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_THREE_POINTS(), myarcType);
172 fillAttribute(theStart, mystartPoint2);
173 fillAttribute(theEnd, myendPoint2);
174 fillAttribute(thePassed, mypassedPoint);
179 //================================================================================================
180 void SketchAPI_MacroArc::setByTangent(const ModelHighAPI_RefAttr& theTangentPoint,
181 double theEndX, double theEndY,
184 fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_TANGENT_EDGE(), myarcType);
185 fillAttribute(theTangentPoint, mytangentPoint);
186 fillAttribute(endPoint3(), theEndX, theEndY);
187 fillAttribute(theInversed, myreversed);
192 //================================================================================================
193 void SketchAPI_MacroArc::setByTangent(const ModelHighAPI_RefAttr& theTangentPoint,
194 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
197 fillAttribute(SketchPlugin_MacroArc::ARC_TYPE_BY_TANGENT_EDGE(), myarcType);
198 fillAttribute(theTangentPoint, mytangentPoint);
199 fillAttribute(theEnd, myendPoint3);
200 fillAttribute(theInversed, myreversed);