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