]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchAPI/SketchAPI_Sketch.cpp
Salome HOME
c19290dbf4090dbdb2bd6d82317c1442c791d9f2
[modules/shaper.git] / src / SketchAPI / SketchAPI_Sketch.cpp
1 // Name   : SketchAPI_Sketch.cpp
2 // Purpose: 
3 //
4 // History:
5 // 07/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "SketchAPI_Sketch.h"
9 //--------------------------------------------------------------------------------------
10 #include <SketchPlugin_Constraint.h>
11 #include <SketchPlugin_ConstraintAngle.h>
12 #include <SketchPlugin_ConstraintCoincidence.h>
13 #include <SketchPlugin_ConstraintCollinear.h>
14 #include <SketchPlugin_ConstraintDistance.h>
15 #include <SketchPlugin_ConstraintEqual.h>
16 #include <SketchPlugin_ConstraintFillet.h>
17 #include <SketchPlugin_ConstraintHorizontal.h>
18 #include <SketchPlugin_ConstraintLength.h>
19 #include <SketchPlugin_ConstraintMiddle.h>
20 #include <SketchPlugin_ConstraintMirror.h>
21 #include <SketchPlugin_ConstraintParallel.h>
22 #include <SketchPlugin_ConstraintPerpendicular.h>
23 #include <SketchPlugin_ConstraintRadius.h>
24 #include <SketchPlugin_ConstraintRigid.h>
25 #include <SketchPlugin_ConstraintTangent.h>
26 #include <SketchPlugin_ConstraintVertical.h>
27 //--------------------------------------------------------------------------------------
28 #include <ModelAPI_CompositeFeature.h>
29 #include <ModelAPI_ResultConstruction.h>
30 #include <ModelHighAPI_RefAttr.h>
31 #include <ModelHighAPI_Selection.h>
32 #include <ModelHighAPI_Tools.h>
33 //--------------------------------------------------------------------------------------
34 #include "SketchAPI_Arc.h"
35 #include "SketchAPI_Circle.h"
36 #include "SketchAPI_IntersectionPoint.h"
37 #include "SketchAPI_Line.h"
38 #include "SketchAPI_Mirror.h"
39 #include "SketchAPI_Point.h"
40 #include "SketchAPI_Projection.h"
41 #include "SketchAPI_Rectangle.h"
42 #include "SketchAPI_Rotation.h"
43 #include "SketchAPI_Translation.h"
44 //--------------------------------------------------------------------------------------
45 SketchAPI_Sketch::SketchAPI_Sketch(
46     const std::shared_ptr<ModelAPI_Feature> & theFeature)
47 : ModelHighAPI_Interface(theFeature)
48 {
49   initialize();
50 }
51
52 SketchAPI_Sketch::SketchAPI_Sketch(
53     const std::shared_ptr<ModelAPI_Feature> & theFeature,
54     const std::shared_ptr<GeomAPI_Ax3> & thePlane)
55 : ModelHighAPI_Interface(theFeature)
56 {
57   if (initialize()) {
58     setPlane(thePlane);
59   }
60 }
61
62 SketchAPI_Sketch::SketchAPI_Sketch(
63     const std::shared_ptr<ModelAPI_Feature> & theFeature,
64     const ModelHighAPI_Selection & theExternal)
65 : ModelHighAPI_Interface(theFeature)
66 {
67   if (initialize()) {
68     setExternal(theExternal);
69   }
70 }
71
72 SketchAPI_Sketch::~SketchAPI_Sketch()
73 {
74
75 }
76
77 //--------------------------------------------------------------------------------------
78 std::shared_ptr<ModelAPI_CompositeFeature> SketchAPI_Sketch::compositeFeature() const
79 {
80   return std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(feature());
81 }
82
83 //--------------------------------------------------------------------------------------
84 void SketchAPI_Sketch::setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane)
85 {
86   fillAttribute(thePlane->origin(), myorigin);
87   fillAttribute(thePlane->dirX(), mydirX);
88   fillAttribute(thePlane->normal(), mynormal);
89
90   execute();
91 }
92
93 void SketchAPI_Sketch::setExternal(const ModelHighAPI_Selection & theExternal)
94 {
95   fillAttribute(theExternal, myexternal);
96
97   execute();
98 }
99
100 //--------------------------------------------------------------------------------------
101 void SketchAPI_Sketch::setValue(
102     const std::shared_ptr<ModelAPI_Feature> & theConstraint,
103     const ModelHighAPI_Double & theValue)
104 {
105   // TODO(spo): check somehow that the feature is a constraint or eliminate crash if the feature have no real attribute VALUE
106   fillAttribute(theValue, theConstraint->real(SketchPlugin_Constraint::VALUE()));
107
108 //  theConstraint->execute();
109 }
110
111 //--------------------------------------------------------------------------------------
112 std::list<ModelHighAPI_Selection> SketchAPI_Sketch::selectFace() const
113 {
114   const_cast<SketchAPI_Sketch*>(this)->execute();
115
116   std::list<ModelHighAPI_Selection> aSelectionList;
117
118   ResultConstructionPtr aResultConstruction =
119       std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(feature()->firstResult());
120   if (aResultConstruction.get() == NULL)
121     return aSelectionList;
122
123   for (int anIndex = 0; anIndex < aResultConstruction->facesNum(); ++anIndex) {
124     aSelectionList.push_back(
125         ModelHighAPI_Selection(aResultConstruction,
126                                aResultConstruction->face(anIndex)));
127   }
128
129   return aSelectionList;
130 }
131
132 //--------------------------------------------------------------------------------------
133 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
134                     const std::shared_ptr<GeomAPI_Ax3> & thePlane)
135 {
136   // TODO(spo): check that thePart is not empty
137   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(SketchAPI_Sketch::ID());
138   return SketchPtr(new SketchAPI_Sketch(aFeature, thePlane));
139 }
140
141 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
142                     const ModelHighAPI_Selection & theExternal)
143 {
144   // TODO(spo): check that thePart is not empty
145   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(SketchAPI_Sketch::ID());
146   return SketchPtr(new SketchAPI_Sketch(aFeature, theExternal));
147 }
148
149 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
150                     const std::string & theExternalName)
151 {
152   // TODO(spo): check that thePart is not empty
153   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(SketchAPI_Sketch::ID());
154   return SketchPtr(new SketchAPI_Sketch(aFeature, ModelHighAPI_Selection("FACE", theExternalName)));
155 }
156
157 //--------------------------------------------------------------------------------------
158 std::shared_ptr<SketchAPI_Point> SketchAPI_Sketch::addPoint(
159     double theX, double theY)
160 {
161   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Point::ID());
162   return PointPtr(new SketchAPI_Point(aFeature, theX, theY));
163 }
164 std::shared_ptr<SketchAPI_Point> SketchAPI_Sketch::addPoint(
165     const std::shared_ptr<GeomAPI_Pnt2d> & thePoint)
166 {
167   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Point::ID());
168   return PointPtr(new SketchAPI_Point(aFeature, thePoint));
169 }
170 std::shared_ptr<SketchAPI_Point> SketchAPI_Sketch::addPoint(const ModelHighAPI_Selection & theExternal)
171 {
172   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Point::ID());
173   return PointPtr(new SketchAPI_Point(aFeature, theExternal));
174 }
175 std::shared_ptr<SketchAPI_Point> SketchAPI_Sketch::addPoint(const std::string & theExternalName)
176 {
177   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Point::ID());
178   return PointPtr(new SketchAPI_Point(aFeature, theExternalName));
179 }
180
181 //--------------------------------------------------------------------------------------
182 std::shared_ptr<SketchAPI_IntersectionPoint> SketchAPI_Sketch::addIntersectionPoint(
183     const ModelHighAPI_Selection & theExternal)
184 {
185   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_IntersectionPoint::ID());
186   return IntersectionPointPtr(new SketchAPI_IntersectionPoint(aFeature, theExternal));
187 }
188 std::shared_ptr<SketchAPI_IntersectionPoint> SketchAPI_Sketch::addIntersectionPoint(
189     const std::string & theExternalName)
190 {
191   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_IntersectionPoint::ID());
192   return IntersectionPointPtr(new SketchAPI_IntersectionPoint(aFeature, theExternalName));
193 }
194
195 //--------------------------------------------------------------------------------------
196 std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(double theX1, double theY1, double theX2, double theY2)
197 {
198   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
199   return LinePtr(new SketchAPI_Line(aFeature, theX1, theY1, theX2, theY2));
200 }
201 std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(
202     const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
203     const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
204 {
205   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
206   return LinePtr(new SketchAPI_Line(aFeature, theStartPoint, theEndPoint));
207 }
208 std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(const ModelHighAPI_Selection & theExternal)
209 {
210   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
211   return LinePtr(new SketchAPI_Line(aFeature, theExternal));
212 }
213 std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(const std::string & theExternalName)
214 {
215   // TODO(spo): Add constraint SketchConstraintRigid like in PythonAPI. Is it necessary?
216   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
217   return LinePtr(new SketchAPI_Line(aFeature, theExternalName));
218 }
219
220 //--------------------------------------------------------------------------------------
221 std::shared_ptr<SketchAPI_Rectangle> SketchAPI_Sketch::addRectangle(double theX1, double theY1, double theX2, double theY2)
222 {
223   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchAPI_Rectangle::ID());
224   return RectanglePtr(new SketchAPI_Rectangle(aFeature, theX1, theY1, theX2, theY2));
225 }
226 std::shared_ptr<SketchAPI_Rectangle> SketchAPI_Sketch::addRectangle(
227     const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
228     const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
229 {
230   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchAPI_Rectangle::ID());
231   return RectanglePtr(new SketchAPI_Rectangle(aFeature, theStartPoint, theEndPoint));
232 }
233
234 //--------------------------------------------------------------------------------------
235 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(double theCenterX,
236                                                               double theCenterY,
237                                                               double theRadius)
238 {
239   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID());
240   return CirclePtr(new SketchAPI_Circle(aFeature, theCenterX, theCenterY, theRadius));
241 }
242
243 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
244                                                               double theRadius)
245 {
246   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID());
247   return CirclePtr(new SketchAPI_Circle(aFeature, theCenter, theRadius));
248 }
249
250 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(double theX1, double theY1,
251                                                               double theX2, double theY2,
252                                                               double theX3, double theY3)
253 {
254   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID());
255   return CirclePtr(new SketchAPI_Circle(aFeature, theX1, theY1, theX2, theY2, theX3, theY3));
256 }
257
258 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
259                                                               const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
260                                                               const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3)
261 {
262   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID());
263   return CirclePtr(new SketchAPI_Circle(aFeature, thePoint1, thePoint2, thePoint3));
264 }
265
266 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(const ModelHighAPI_Selection & theExternal)
267 {
268   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID());
269   return CirclePtr(new SketchAPI_Circle(aFeature, theExternal));
270 }
271
272 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(const std::string & theExternalName)
273 {
274   // TODO(spo): Add constraint SketchConstraintRigid like in PythonAPI. Is it necessary?
275   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID());
276   return CirclePtr(new SketchAPI_Circle(aFeature, theExternalName));
277 }
278
279 //--------------------------------------------------------------------------------------
280 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(double theCenterX, double theCenterY,
281                                                         double theStartX, double theStartY,
282                                                         double theEndX, double theEndY,
283                                                         bool theInversed)
284 {
285   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
286   return ArcPtr(new SketchAPI_Arc(aFeature,
287                                   theCenterX, theCenterY,
288                                   theStartX, theStartY,
289                                   theEndX, theEndY,
290                                   theInversed));
291 }
292
293 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
294                                                         const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
295                                                         const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
296                                                         bool theInversed)
297 {
298   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
299   return ArcPtr(new SketchAPI_Arc(aFeature, theCenter, theStart, theEnd, theInversed));
300 }
301
302 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(double theStartX, double theStartY,
303                                                         double theEndX, double theEndY,
304                                                         double thePassedX, double thePassedY)
305 {
306   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
307   return ArcPtr(new SketchAPI_Arc(aFeature,
308                                   theStartX, theStartY,
309                                   theEndX, theEndY,
310                                   thePassedX, thePassedY));
311 }
312
313 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
314                                                         const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
315                                                         const std::shared_ptr<GeomAPI_Pnt2d>& thePassed)
316 {
317   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
318   return ArcPtr(new SketchAPI_Arc(aFeature, theStart, theEnd, thePassed));
319 }
320
321 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const ModelHighAPI_RefAttr& theTangentPoint,
322                                                         double theEndX, double theEndY,
323                                                         bool theInversed)
324 {
325   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
326   return ArcPtr(new SketchAPI_Arc(aFeature, theTangentPoint, theEndX, theEndY, theInversed));
327 }
328
329 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const ModelHighAPI_RefAttr& theTangentPoint,
330                                                         const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
331                                                         bool theInversed)
332 {
333   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
334   return ArcPtr(new SketchAPI_Arc(aFeature, theTangentPoint, theEnd, theInversed));
335 }
336
337 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const ModelHighAPI_Selection & theExternal)
338 {
339   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
340   return ArcPtr(new SketchAPI_Arc(aFeature, theExternal));
341 }
342
343 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const std::string & theExternalName)
344 {
345   // TODO(spo): Add constraint SketchConstraintRigid like in PythonAPI. Is it necessary?
346   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
347   return ArcPtr(new SketchAPI_Arc(aFeature, theExternalName));
348 }
349
350 //--------------------------------------------------------------------------------------
351 std::shared_ptr<SketchAPI_Projection> SketchAPI_Sketch::addProjection(
352     const ModelHighAPI_Selection & theExternalFeature)
353 {
354   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Projection::ID());
355   return ProjectionPtr(new SketchAPI_Projection(aFeature, theExternalFeature));
356 }
357
358 //--------------------------------------------------------------------------------------
359 std::shared_ptr<SketchAPI_Mirror> SketchAPI_Sketch::addMirror(
360     const ModelHighAPI_RefAttr & theMirrorLine,
361     const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects)
362 {
363   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_ConstraintMirror::ID());
364   return MirrorPtr(new SketchAPI_Mirror(aFeature, theMirrorLine, theObjects));
365 }
366
367 //--------------------------------------------------------------------------------------
368 std::shared_ptr<SketchAPI_Translation> SketchAPI_Sketch::addTranslation(
369     const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
370     const ModelHighAPI_RefAttr & thePoint1,
371     const ModelHighAPI_RefAttr & thePoint2,
372     const ModelHighAPI_Integer & theNumberOfObjects,
373     bool theFullValue)
374 {
375   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_MultiTranslation::ID());
376   return TranslationPtr(new SketchAPI_Translation(aFeature, theObjects, thePoint1, thePoint2, theNumberOfObjects, theFullValue));
377 }
378
379 //--------------------------------------------------------------------------------------
380 std::shared_ptr<SketchAPI_Rotation> SketchAPI_Sketch::addRotation(
381     const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
382     const ModelHighAPI_RefAttr & theCenter,
383     const ModelHighAPI_Double & theAngle,
384     const ModelHighAPI_Integer & theNumberOfObjects,
385     bool theFullValue)
386 {
387   std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_MultiRotation::ID());
388   return RotationPtr(new SketchAPI_Rotation(aFeature, theObjects, theCenter, theAngle, theNumberOfObjects, theFullValue));
389 }
390
391 //--------------------------------------------------------------------------------------
392 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setAngle(
393     const ModelHighAPI_RefAttr & theLine1,
394     const ModelHighAPI_RefAttr & theLine2,
395     const ModelHighAPI_Double & theValue)
396 {
397   // TODO(spo): is support of angle type necessary?
398   std::shared_ptr<ModelAPI_Feature> aFeature =
399       compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
400   fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
401   fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
402   fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
403   aFeature->execute();
404   return aFeature;
405 }
406
407 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setCoincident(
408     const ModelHighAPI_RefAttr & thePoint1,
409     const ModelHighAPI_RefAttr & thePoint2)
410 {
411   std::shared_ptr<ModelAPI_Feature> aFeature =
412       compositeFeature()->addFeature(SketchPlugin_ConstraintCoincidence::ID());
413   fillAttribute(thePoint1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
414   fillAttribute(thePoint2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
415   aFeature->execute();
416   return aFeature;
417 }
418
419 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setCollinear(
420     const ModelHighAPI_RefAttr & theLine1,
421     const ModelHighAPI_RefAttr & theLine2)
422 {
423   std::shared_ptr<ModelAPI_Feature> aFeature =
424       compositeFeature()->addFeature(SketchPlugin_ConstraintCollinear::ID());
425   fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
426   fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
427   aFeature->execute();
428   return aFeature;
429 }
430
431 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setDistance(
432     const ModelHighAPI_RefAttr & thePoint,
433     const ModelHighAPI_RefAttr & thePointOrLine,
434     const ModelHighAPI_Double & theValue)
435 {
436   std::shared_ptr<ModelAPI_Feature> aFeature =
437       compositeFeature()->addFeature(SketchPlugin_ConstraintDistance::ID());
438   fillAttribute(thePoint, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
439   fillAttribute(thePointOrLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
440   fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
441   aFeature->execute();
442   return aFeature;
443 }
444
445 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setEqual(
446     const ModelHighAPI_RefAttr & theObject1,
447     const ModelHighAPI_RefAttr & theObject2)
448 {
449   std::shared_ptr<ModelAPI_Feature> aFeature =
450       compositeFeature()->addFeature(SketchPlugin_ConstraintEqual::ID());
451   fillAttribute(theObject1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
452   fillAttribute(theObject2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
453   aFeature->execute();
454   return aFeature;
455 }
456
457 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setFillet(
458     const std::list<ModelHighAPI_RefAttr> & thePoints,
459     const ModelHighAPI_Double & theRadius)
460 {
461   std::shared_ptr<ModelAPI_Feature> aFeature =
462       compositeFeature()->addFeature(SketchPlugin_ConstraintFillet::ID());
463   fillAttribute(thePoints, aFeature->data()->refattrlist(SketchPlugin_Constraint::ENTITY_A()));
464   fillAttribute(theRadius, aFeature->real(SketchPlugin_Constraint::VALUE()));
465   aFeature->execute();
466   return aFeature;
467 }
468
469 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setHorizontal(
470     const ModelHighAPI_RefAttr & theLine)
471 {
472   std::shared_ptr<ModelAPI_Feature> aFeature =
473       compositeFeature()->addFeature(SketchPlugin_ConstraintHorizontal::ID());
474   fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
475   aFeature->execute();
476   return aFeature;
477 }
478
479 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setLength(
480     const ModelHighAPI_RefAttr & theLine,
481     const ModelHighAPI_Double & theValue)
482 {
483   std::shared_ptr<ModelAPI_Feature> aFeature =
484       compositeFeature()->addFeature(SketchPlugin_ConstraintLength::ID());
485   fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
486   fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
487   aFeature->execute();
488   return aFeature;
489 }
490
491 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setMiddlePoint(
492     const ModelHighAPI_RefAttr & thePoint,
493     const ModelHighAPI_RefAttr & theLine)
494 {
495   std::shared_ptr<ModelAPI_Feature> aFeature =
496       compositeFeature()->addFeature(SketchPlugin_ConstraintMiddle::ID());
497   fillAttribute(thePoint, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
498   fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
499   aFeature->execute();
500   return aFeature;
501 }
502
503 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setParallel(
504     const ModelHighAPI_RefAttr & theLine1,
505     const ModelHighAPI_RefAttr & theLine2)
506 {
507   std::shared_ptr<ModelAPI_Feature> aFeature =
508       compositeFeature()->addFeature(SketchPlugin_ConstraintParallel::ID());
509   fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
510   fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
511   aFeature->execute();
512   return aFeature;
513 }
514
515 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setPerpendicular(
516     const ModelHighAPI_RefAttr & theLine1,
517     const ModelHighAPI_RefAttr & theLine2)
518 {
519   std::shared_ptr<ModelAPI_Feature> aFeature =
520       compositeFeature()->addFeature(SketchPlugin_ConstraintPerpendicular::ID());
521   fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
522   fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
523   aFeature->execute();
524   return aFeature;
525 }
526
527 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setRadius(
528     const ModelHighAPI_RefAttr & theCircleOrArc,
529     const ModelHighAPI_Double & theValue)
530 {
531   std::shared_ptr<ModelAPI_Feature> aFeature =
532       compositeFeature()->addFeature(SketchPlugin_ConstraintRadius::ID());
533   fillAttribute(theCircleOrArc, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
534   fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
535   aFeature->execute();
536   return aFeature;
537 }
538
539 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setRigid(
540     const ModelHighAPI_RefAttr & theObject)
541 {
542   // TODO(spo): should it be renamed to Fixed?
543   std::shared_ptr<ModelAPI_Feature> aFeature =
544       compositeFeature()->addFeature(SketchPlugin_ConstraintRigid::ID());
545   fillAttribute(theObject, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
546   aFeature->execute();
547   return aFeature;
548 }
549
550 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setTangent(
551     const ModelHighAPI_RefAttr & theLine,
552     const ModelHighAPI_RefAttr & theCircle)
553 {
554   std::shared_ptr<ModelAPI_Feature> aFeature =
555       compositeFeature()->addFeature(SketchPlugin_ConstraintTangent::ID());
556   fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
557   fillAttribute(theCircle, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
558   aFeature->execute();
559   return aFeature;
560 }
561
562 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setVertical(
563     const ModelHighAPI_RefAttr & theLine)
564 {
565   std::shared_ptr<ModelAPI_Feature> aFeature =
566       compositeFeature()->addFeature(SketchPlugin_ConstraintVertical::ID());
567   fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
568   aFeature->execute();
569   return aFeature;
570 }
571
572 //--------------------------------------------------------------------------------------