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