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