1 // Name : SketchAPI_Sketch.cpp
5 // 07/06/16 - Sergey POKHODENKO - Creation of the file
7 //--------------------------------------------------------------------------------------
8 #include "SketchAPI_Sketch.h"
9 //--------------------------------------------------------------------------------------
10 #include <SketchPlugin_Constraint.h>
11 #include <SketchPlugin_ConstraintAngle.h>
12 #include <SketchPlugin_ConstraintCoincidence.h>
13 #include <SketchPlugin_ConstraintCollinear.h>
14 #include <SketchPlugin_ConstraintDistance.h>
15 #include <SketchPlugin_ConstraintEqual.h>
16 #include <SketchPlugin_ConstraintFillet.h>
17 #include <SketchPlugin_ConstraintHorizontal.h>
18 #include <SketchPlugin_ConstraintLength.h>
19 #include <SketchPlugin_ConstraintMiddle.h>
20 #include <SketchPlugin_ConstraintMirror.h>
21 #include <SketchPlugin_ConstraintParallel.h>
22 #include <SketchPlugin_ConstraintPerpendicular.h>
23 #include <SketchPlugin_ConstraintRadius.h>
24 #include <SketchPlugin_ConstraintRigid.h>
25 #include <SketchPlugin_ConstraintTangent.h>
26 #include <SketchPlugin_ConstraintVertical.h>
27 //--------------------------------------------------------------------------------------
28 #include <ModelAPI_CompositeFeature.h>
29 #include <ModelAPI_ResultConstruction.h>
30 #include <ModelHighAPI_RefAttr.h>
31 #include <ModelHighAPI_Selection.h>
32 #include <ModelHighAPI_Tools.h>
33 //--------------------------------------------------------------------------------------
34 #include "SketchAPI_Arc.h"
35 #include "SketchAPI_Circle.h"
36 #include "SketchAPI_IntersectionPoint.h"
37 #include "SketchAPI_Line.h"
38 #include "SketchAPI_Mirror.h"
39 #include "SketchAPI_Point.h"
40 #include "SketchAPI_Projection.h"
41 #include "SketchAPI_Rectangle.h"
42 #include "SketchAPI_Rotation.h"
43 #include "SketchAPI_Translation.h"
44 //--------------------------------------------------------------------------------------
45 SketchAPI_Sketch::SketchAPI_Sketch(
46 const std::shared_ptr<ModelAPI_Feature> & theFeature)
47 : ModelHighAPI_Interface(theFeature)
52 SketchAPI_Sketch::SketchAPI_Sketch(
53 const std::shared_ptr<ModelAPI_Feature> & theFeature,
54 const std::shared_ptr<GeomAPI_Ax3> & thePlane)
55 : ModelHighAPI_Interface(theFeature)
62 SketchAPI_Sketch::SketchAPI_Sketch(
63 const std::shared_ptr<ModelAPI_Feature> & theFeature,
64 const ModelHighAPI_Selection & theExternal)
65 : ModelHighAPI_Interface(theFeature)
68 setExternal(theExternal);
72 SketchAPI_Sketch::~SketchAPI_Sketch()
77 //--------------------------------------------------------------------------------------
78 std::shared_ptr<ModelAPI_CompositeFeature> SketchAPI_Sketch::compositeFeature() const
80 return std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(feature());
83 //--------------------------------------------------------------------------------------
84 void SketchAPI_Sketch::setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane)
86 fillAttribute(thePlane->origin(), myorigin);
87 fillAttribute(thePlane->dirX(), mydirX);
88 fillAttribute(thePlane->normal(), mynormal);
93 void SketchAPI_Sketch::setExternal(const ModelHighAPI_Selection & theExternal)
95 fillAttribute(theExternal, myexternal);
100 //--------------------------------------------------------------------------------------
101 void SketchAPI_Sketch::setValue(
102 const std::shared_ptr<ModelAPI_Feature> & theConstraint,
103 const ModelHighAPI_Double & theValue)
105 // TODO(spo): check somehow that the feature is a constraint or eliminate crash if the feature have no real attribute VALUE
106 fillAttribute(theValue, theConstraint->real(SketchPlugin_Constraint::VALUE()));
108 // theConstraint->execute();
111 //--------------------------------------------------------------------------------------
112 std::list<ModelHighAPI_Selection> SketchAPI_Sketch::selectFace() const
114 const_cast<SketchAPI_Sketch*>(this)->execute();
116 std::list<ModelHighAPI_Selection> aSelectionList;
118 ResultConstructionPtr aResultConstruction =
119 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(feature()->firstResult());
120 if (aResultConstruction.get() == NULL)
121 return aSelectionList;
123 for (int anIndex = 0; anIndex < aResultConstruction->facesNum(); ++anIndex) {
124 aSelectionList.push_back(
125 ModelHighAPI_Selection(aResultConstruction,
126 aResultConstruction->face(anIndex)));
129 return aSelectionList;
132 //--------------------------------------------------------------------------------------
133 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
134 const std::shared_ptr<GeomAPI_Ax3> & thePlane)
136 // TODO(spo): check that thePart is not empty
137 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(SketchAPI_Sketch::ID());
138 return SketchPtr(new SketchAPI_Sketch(aFeature, thePlane));
141 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
142 const ModelHighAPI_Selection & theExternal)
144 // TODO(spo): check that thePart is not empty
145 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(SketchAPI_Sketch::ID());
146 return SketchPtr(new SketchAPI_Sketch(aFeature, theExternal));
149 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
150 const std::string & theExternalName)
152 // TODO(spo): check that thePart is not empty
153 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(SketchAPI_Sketch::ID());
154 return SketchPtr(new SketchAPI_Sketch(aFeature, ModelHighAPI_Selection("FACE", theExternalName)));
157 //--------------------------------------------------------------------------------------
158 std::shared_ptr<SketchAPI_Point> SketchAPI_Sketch::addPoint(
159 double theX, double theY)
161 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Point::ID());
162 return PointPtr(new SketchAPI_Point(aFeature, theX, theY));
164 std::shared_ptr<SketchAPI_Point> SketchAPI_Sketch::addPoint(
165 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint)
167 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Point::ID());
168 return PointPtr(new SketchAPI_Point(aFeature, thePoint));
170 std::shared_ptr<SketchAPI_Point> SketchAPI_Sketch::addPoint(const ModelHighAPI_Selection & theExternal)
172 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Point::ID());
173 return PointPtr(new SketchAPI_Point(aFeature, theExternal));
175 std::shared_ptr<SketchAPI_Point> SketchAPI_Sketch::addPoint(const std::string & theExternalName)
177 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Point::ID());
178 return PointPtr(new SketchAPI_Point(aFeature, theExternalName));
181 //--------------------------------------------------------------------------------------
182 std::shared_ptr<SketchAPI_IntersectionPoint> SketchAPI_Sketch::addIntersectionPoint(
183 const ModelHighAPI_Selection & theExternal)
185 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_IntersectionPoint::ID());
186 return IntersectionPointPtr(new SketchAPI_IntersectionPoint(aFeature, theExternal));
188 std::shared_ptr<SketchAPI_IntersectionPoint> SketchAPI_Sketch::addIntersectionPoint(
189 const std::string & theExternalName)
191 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_IntersectionPoint::ID());
192 return IntersectionPointPtr(new SketchAPI_IntersectionPoint(aFeature, theExternalName));
195 //--------------------------------------------------------------------------------------
196 std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(double theX1, double theY1, double theX2, double theY2)
198 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
199 return LinePtr(new SketchAPI_Line(aFeature, theX1, theY1, theX2, theY2));
201 std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(
202 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
203 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
205 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
206 return LinePtr(new SketchAPI_Line(aFeature, theStartPoint, theEndPoint));
208 std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(const ModelHighAPI_Selection & theExternal)
210 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
211 LinePtr aLine(new SketchAPI_Line(aFeature, theExternal));
212 setFixed(InterfacePtr(aLine));
215 std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(const std::string & theExternalName)
217 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
218 LinePtr aLine(new SketchAPI_Line(aFeature, theExternalName));
219 setFixed(InterfacePtr(aLine));
223 //--------------------------------------------------------------------------------------
224 std::shared_ptr<SketchAPI_Rectangle> SketchAPI_Sketch::addRectangle(double theX1, double theY1, double theX2, double theY2)
226 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchAPI_Rectangle::ID());
227 return RectanglePtr(new SketchAPI_Rectangle(aFeature, theX1, theY1, theX2, theY2));
229 std::shared_ptr<SketchAPI_Rectangle> SketchAPI_Sketch::addRectangle(
230 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
231 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
233 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchAPI_Rectangle::ID());
234 return RectanglePtr(new SketchAPI_Rectangle(aFeature, theStartPoint, theEndPoint));
237 //--------------------------------------------------------------------------------------
238 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(double theCenterX,
242 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID());
243 return CirclePtr(new SketchAPI_Circle(aFeature, theCenterX, theCenterY, theRadius));
246 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
249 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID());
250 return CirclePtr(new SketchAPI_Circle(aFeature, theCenter, theRadius));
253 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(double theX1, double theY1,
254 double theX2, double theY2,
255 double theX3, double theY3)
257 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID());
258 return CirclePtr(new SketchAPI_Circle(aFeature, theX1, theY1, theX2, theY2, theX3, theY3));
261 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
262 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
263 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3)
265 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID());
266 return CirclePtr(new SketchAPI_Circle(aFeature, thePoint1, thePoint2, thePoint3));
269 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(const ModelHighAPI_Selection & theExternal)
271 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID());
272 return CirclePtr(new SketchAPI_Circle(aFeature, theExternal));
275 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(const std::string & theExternalName)
277 // TODO(spo): Add constraint SketchConstraintRigid like in PythonAPI. Is it necessary?
278 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Circle::ID());
279 return CirclePtr(new SketchAPI_Circle(aFeature, theExternalName));
282 //--------------------------------------------------------------------------------------
283 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(double theCenterX, double theCenterY,
284 double theStartX, double theStartY,
285 double theEndX, double theEndY,
288 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
289 return ArcPtr(new SketchAPI_Arc(aFeature,
290 theCenterX, theCenterY,
291 theStartX, theStartY,
296 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
297 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
298 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
301 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
302 return ArcPtr(new SketchAPI_Arc(aFeature, theCenter, theStart, theEnd, theInversed));
305 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(double theStartX, double theStartY,
306 double theEndX, double theEndY,
307 double thePassedX, double thePassedY)
309 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
310 return ArcPtr(new SketchAPI_Arc(aFeature,
311 theStartX, theStartY,
313 thePassedX, thePassedY));
316 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
317 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
318 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed)
320 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
321 return ArcPtr(new SketchAPI_Arc(aFeature, theStart, theEnd, thePassed));
324 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const ModelHighAPI_RefAttr& theTangentPoint,
325 double theEndX, double theEndY,
328 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
329 return ArcPtr(new SketchAPI_Arc(aFeature, theTangentPoint, theEndX, theEndY, theInversed));
332 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const ModelHighAPI_RefAttr& theTangentPoint,
333 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
336 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
337 return ArcPtr(new SketchAPI_Arc(aFeature, theTangentPoint, theEnd, theInversed));
340 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const ModelHighAPI_Selection & theExternal)
342 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
343 return ArcPtr(new SketchAPI_Arc(aFeature, theExternal));
346 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const std::string & theExternalName)
348 // TODO(spo): Add constraint SketchConstraintRigid like in PythonAPI. Is it necessary?
349 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
350 return ArcPtr(new SketchAPI_Arc(aFeature, theExternalName));
353 //--------------------------------------------------------------------------------------
354 std::shared_ptr<SketchAPI_Projection> SketchAPI_Sketch::addProjection(
355 const ModelHighAPI_Selection & theExternalFeature)
357 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Projection::ID());
358 return ProjectionPtr(new SketchAPI_Projection(aFeature, theExternalFeature));
361 //--------------------------------------------------------------------------------------
362 std::shared_ptr<SketchAPI_Mirror> SketchAPI_Sketch::addMirror(
363 const ModelHighAPI_RefAttr & theMirrorLine,
364 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects)
366 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_ConstraintMirror::ID());
367 return MirrorPtr(new SketchAPI_Mirror(aFeature, theMirrorLine, theObjects));
370 //--------------------------------------------------------------------------------------
371 std::shared_ptr<SketchAPI_Translation> SketchAPI_Sketch::addTranslation(
372 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
373 const ModelHighAPI_RefAttr & thePoint1,
374 const ModelHighAPI_RefAttr & thePoint2,
375 const ModelHighAPI_Integer & theNumberOfObjects,
378 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_MultiTranslation::ID());
379 return TranslationPtr(new SketchAPI_Translation(aFeature, theObjects, thePoint1, thePoint2, theNumberOfObjects, theFullValue));
382 //--------------------------------------------------------------------------------------
383 std::shared_ptr<SketchAPI_Rotation> SketchAPI_Sketch::addRotation(
384 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
385 const ModelHighAPI_RefAttr & theCenter,
386 const ModelHighAPI_Double & theAngle,
387 const ModelHighAPI_Integer & theNumberOfObjects,
390 std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_MultiRotation::ID());
391 return RotationPtr(new SketchAPI_Rotation(aFeature, theObjects, theCenter, theAngle, theNumberOfObjects, theFullValue));
394 //--------------------------------------------------------------------------------------
395 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setAngle(
396 const ModelHighAPI_RefAttr & theLine1,
397 const ModelHighAPI_RefAttr & theLine2,
398 const ModelHighAPI_Double & theValue)
400 // TODO(spo): is support of angle type necessary?
401 std::shared_ptr<ModelAPI_Feature> aFeature =
402 compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
403 fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
404 fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
405 fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
410 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setCoincident(
411 const ModelHighAPI_RefAttr & thePoint1,
412 const ModelHighAPI_RefAttr & thePoint2)
414 std::shared_ptr<ModelAPI_Feature> aFeature =
415 compositeFeature()->addFeature(SketchPlugin_ConstraintCoincidence::ID());
416 fillAttribute(thePoint1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
417 fillAttribute(thePoint2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
422 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setCollinear(
423 const ModelHighAPI_RefAttr & theLine1,
424 const ModelHighAPI_RefAttr & theLine2)
426 std::shared_ptr<ModelAPI_Feature> aFeature =
427 compositeFeature()->addFeature(SketchPlugin_ConstraintCollinear::ID());
428 fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
429 fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
434 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setDistance(
435 const ModelHighAPI_RefAttr & thePoint,
436 const ModelHighAPI_RefAttr & thePointOrLine,
437 const ModelHighAPI_Double & theValue)
439 std::shared_ptr<ModelAPI_Feature> aFeature =
440 compositeFeature()->addFeature(SketchPlugin_ConstraintDistance::ID());
441 fillAttribute(thePoint, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
442 fillAttribute(thePointOrLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
443 fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
448 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setEqual(
449 const ModelHighAPI_RefAttr & theObject1,
450 const ModelHighAPI_RefAttr & theObject2)
452 std::shared_ptr<ModelAPI_Feature> aFeature =
453 compositeFeature()->addFeature(SketchPlugin_ConstraintEqual::ID());
454 fillAttribute(theObject1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
455 fillAttribute(theObject2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
460 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setFillet(
461 const std::list<ModelHighAPI_RefAttr> & thePoints,
462 const ModelHighAPI_Double & theRadius)
464 std::shared_ptr<ModelAPI_Feature> aFeature =
465 compositeFeature()->addFeature(SketchPlugin_ConstraintFillet::ID());
466 fillAttribute(thePoints, aFeature->data()->refattrlist(SketchPlugin_Constraint::ENTITY_A()));
467 fillAttribute(theRadius, aFeature->real(SketchPlugin_Constraint::VALUE()));
472 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setFixed(
473 const ModelHighAPI_RefAttr & theObject)
475 std::shared_ptr<ModelAPI_Feature> aFeature =
476 compositeFeature()->addFeature(SketchPlugin_ConstraintRigid::ID());
477 fillAttribute(theObject, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
482 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setHorizontal(
483 const ModelHighAPI_RefAttr & theLine)
485 std::shared_ptr<ModelAPI_Feature> aFeature =
486 compositeFeature()->addFeature(SketchPlugin_ConstraintHorizontal::ID());
487 fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
492 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setLength(
493 const ModelHighAPI_RefAttr & theLine,
494 const ModelHighAPI_Double & theValue)
496 std::shared_ptr<ModelAPI_Feature> aFeature =
497 compositeFeature()->addFeature(SketchPlugin_ConstraintLength::ID());
498 fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
499 fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
504 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setMiddlePoint(
505 const ModelHighAPI_RefAttr & thePoint,
506 const ModelHighAPI_RefAttr & theLine)
508 std::shared_ptr<ModelAPI_Feature> aFeature =
509 compositeFeature()->addFeature(SketchPlugin_ConstraintMiddle::ID());
510 fillAttribute(thePoint, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
511 fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
516 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setParallel(
517 const ModelHighAPI_RefAttr & theLine1,
518 const ModelHighAPI_RefAttr & theLine2)
520 std::shared_ptr<ModelAPI_Feature> aFeature =
521 compositeFeature()->addFeature(SketchPlugin_ConstraintParallel::ID());
522 fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
523 fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
528 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setPerpendicular(
529 const ModelHighAPI_RefAttr & theLine1,
530 const ModelHighAPI_RefAttr & theLine2)
532 std::shared_ptr<ModelAPI_Feature> aFeature =
533 compositeFeature()->addFeature(SketchPlugin_ConstraintPerpendicular::ID());
534 fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
535 fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
540 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setRadius(
541 const ModelHighAPI_RefAttr & theCircleOrArc,
542 const ModelHighAPI_Double & theValue)
544 std::shared_ptr<ModelAPI_Feature> aFeature =
545 compositeFeature()->addFeature(SketchPlugin_ConstraintRadius::ID());
546 fillAttribute(theCircleOrArc, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
547 fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
552 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setTangent(
553 const ModelHighAPI_RefAttr & theLine,
554 const ModelHighAPI_RefAttr & theCircle)
556 std::shared_ptr<ModelAPI_Feature> aFeature =
557 compositeFeature()->addFeature(SketchPlugin_ConstraintTangent::ID());
558 fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
559 fillAttribute(theCircle, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
564 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setVertical(
565 const ModelHighAPI_RefAttr & theLine)
567 std::shared_ptr<ModelAPI_Feature> aFeature =
568 compositeFeature()->addFeature(SketchPlugin_ConstraintVertical::ID());
569 fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
574 //--------------------------------------------------------------------------------------