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