1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2 // Name : SketchAPI_Sketch.cpp
6 // 07/06/16 - Sergey POKHODENKO - Creation of the file
8 //--------------------------------------------------------------------------------------
9 #include "SketchAPI_Sketch.h"
10 //--------------------------------------------------------------------------------------
11 #include <SketchPlugin_Constraint.h>
12 #include <SketchPlugin_ConstraintAngle.h>
13 #include <SketchPlugin_ConstraintCoincidence.h>
14 #include <SketchPlugin_ConstraintCollinear.h>
15 #include <SketchPlugin_ConstraintDistance.h>
16 #include <SketchPlugin_ConstraintDistanceHorizontal.h>
17 #include <SketchPlugin_ConstraintDistanceVertical.h>
18 #include <SketchPlugin_ConstraintEqual.h>
19 #include <SketchPlugin_Fillet.h>
20 #include <SketchPlugin_ConstraintHorizontal.h>
21 #include <SketchPlugin_ConstraintLength.h>
22 #include <SketchPlugin_ConstraintMiddle.h>
23 #include <SketchPlugin_ConstraintMirror.h>
24 #include <SketchPlugin_ConstraintParallel.h>
25 #include <SketchPlugin_ConstraintPerpendicular.h>
26 #include <SketchPlugin_ConstraintRadius.h>
27 #include <SketchPlugin_ConstraintRigid.h>
28 #include <SketchPlugin_ConstraintSplit.h>
29 #include <SketchPlugin_Trim.h>
30 #include <SketchPlugin_ConstraintTangent.h>
31 #include <SketchPlugin_ConstraintVertical.h>
32 #include <SketcherPrs_Tools.h>
33 //--------------------------------------------------------------------------------------
34 #include <ModelAPI_Events.h>
35 #include <ModelAPI_CompositeFeature.h>
36 #include <ModelAPI_ResultConstruction.h>
37 #include <ModelHighAPI_Double.h>
38 #include <ModelHighAPI_Dumper.h>
39 #include <ModelHighAPI_RefAttr.h>
40 #include <ModelHighAPI_Selection.h>
41 #include <ModelHighAPI_Services.h>
42 #include <ModelHighAPI_Tools.h>
43 //--------------------------------------------------------------------------------------
44 #include "SketchAPI_Arc.h"
45 #include "SketchAPI_MacroArc.h"
46 #include "SketchAPI_Circle.h"
47 #include "SketchAPI_IntersectionPoint.h"
48 #include "SketchAPI_Line.h"
49 #include "SketchAPI_MacroCircle.h"
50 #include "SketchAPI_Mirror.h"
51 #include "SketchAPI_Point.h"
52 #include "SketchAPI_Projection.h"
53 #include "SketchAPI_Rectangle.h"
54 #include "SketchAPI_Rotation.h"
55 #include "SketchAPI_Translation.h"
56 //--------------------------------------------------------------------------------------
57 #include <GeomAPI_Dir2d.h>
58 #include <GeomAPI_XY.h>
60 //--------------------------------------------------------------------------------------
61 SketchAPI_Sketch::SketchAPI_Sketch(
62 const std::shared_ptr<ModelAPI_Feature> & theFeature)
63 : ModelHighAPI_Interface(theFeature)
68 SketchAPI_Sketch::SketchAPI_Sketch(
69 const std::shared_ptr<ModelAPI_Feature> & theFeature,
70 const std::shared_ptr<GeomAPI_Ax3> & thePlane)
71 : ModelHighAPI_Interface(theFeature)
78 SketchAPI_Sketch::SketchAPI_Sketch(
79 const std::shared_ptr<ModelAPI_Feature> & theFeature,
80 const ModelHighAPI_Selection & theExternal)
81 : ModelHighAPI_Interface(theFeature)
84 setExternal(theExternal);
88 SketchAPI_Sketch::SketchAPI_Sketch(
89 const std::shared_ptr<ModelAPI_Feature> & theFeature,
90 std::shared_ptr<ModelAPI_Object> thePlaneObject)
91 : ModelHighAPI_Interface(theFeature)
94 setExternal(thePlaneObject);
98 SketchAPI_Sketch::~SketchAPI_Sketch()
103 //--------------------------------------------------------------------------------------
104 std::shared_ptr<ModelAPI_CompositeFeature> SketchAPI_Sketch::compositeFeature() const
106 return std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(feature());
109 //--------------------------------------------------------------------------------------
110 void SketchAPI_Sketch::setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane)
112 fillAttribute(thePlane->origin(), myorigin);
113 fillAttribute(thePlane->dirX(), mydirX);
114 fillAttribute(thePlane->normal(), mynormal);
119 void SketchAPI_Sketch::setExternal(const ModelHighAPI_Selection & theExternal)
121 fillAttribute(theExternal, myexternal);
126 void SketchAPI_Sketch::setExternal(std::shared_ptr<ModelAPI_Object> thePlaneObject)
128 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(thePlaneObject);
129 ModelHighAPI_Selection aSel(aRes);
133 //--------------------------------------------------------------------------------------
134 void SketchAPI_Sketch::setValue(
135 const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
136 const ModelHighAPI_Double & theValue)
138 fillAttribute(theValue, theConstraint->feature()->real(SketchPlugin_Constraint::VALUE()));
140 // theConstraint->execute();
143 //--------------------------------------------------------------------------------------
144 std::list<ModelHighAPI_Selection> SketchAPI_Sketch::selectFace() const
146 const_cast<SketchAPI_Sketch*>(this)->execute();
148 std::list<ModelHighAPI_Selection> aSelectionList;
150 ResultConstructionPtr aResultConstruction =
151 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(feature()->firstResult());
152 if (aResultConstruction.get() == NULL)
153 return aSelectionList;
155 for (int anIndex = 0; anIndex < aResultConstruction->facesNum(); ++anIndex) {
156 aSelectionList.push_back(
157 ModelHighAPI_Selection(aResultConstruction,
158 aResultConstruction->face(anIndex)));
161 return aSelectionList;
164 //--------------------------------------------------------------------------------------
165 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
166 const std::shared_ptr<GeomAPI_Ax3> & thePlane)
168 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(SketchAPI_Sketch::ID());
169 return SketchPtr(new SketchAPI_Sketch(aFeature, thePlane));
172 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
173 const ModelHighAPI_Selection & theExternal)
175 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(SketchAPI_Sketch::ID());
176 return SketchPtr(new SketchAPI_Sketch(aFeature, theExternal));
179 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
180 const std::string & theExternalName)
182 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(SketchAPI_Sketch::ID());
184 new SketchAPI_Sketch(aFeature, ModelHighAPI_Selection("FACE", theExternalName)));
187 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
188 std::shared_ptr<ModelAPI_Object> thePlaneObject)
190 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(SketchAPI_Sketch::ID());
191 return SketchPtr(new SketchAPI_Sketch(aFeature, thePlaneObject));
195 //--------------------------------------------------------------------------------------
196 std::shared_ptr<SketchAPI_Point> SketchAPI_Sketch::addPoint(
197 double theX, double theY)
199 std::shared_ptr<ModelAPI_Feature> aFeature =
200 compositeFeature()->addFeature(SketchPlugin_Point::ID());
201 return PointPtr(new SketchAPI_Point(aFeature, theX, theY));
203 std::shared_ptr<SketchAPI_Point> SketchAPI_Sketch::addPoint(
204 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint)
206 std::shared_ptr<ModelAPI_Feature> aFeature =
207 compositeFeature()->addFeature(SketchPlugin_Point::ID());
208 return PointPtr(new SketchAPI_Point(aFeature, thePoint));
210 std::shared_ptr<SketchAPI_Point>
211 SketchAPI_Sketch::addPoint(const ModelHighAPI_Selection & theExternal)
213 std::shared_ptr<ModelAPI_Feature> aFeature =
214 compositeFeature()->addFeature(SketchPlugin_Point::ID());
215 return PointPtr(new SketchAPI_Point(aFeature, theExternal));
217 std::shared_ptr<SketchAPI_Point> SketchAPI_Sketch::addPoint(const std::string & theExternalName)
219 std::shared_ptr<ModelAPI_Feature> aFeature =
220 compositeFeature()->addFeature(SketchPlugin_Point::ID());
221 return PointPtr(new SketchAPI_Point(aFeature, theExternalName));
224 //--------------------------------------------------------------------------------------
225 std::shared_ptr<SketchAPI_IntersectionPoint> SketchAPI_Sketch::addIntersectionPoint(
226 const ModelHighAPI_Selection & theExternal)
228 std::shared_ptr<ModelAPI_Feature> aFeature =
229 compositeFeature()->addFeature(SketchPlugin_IntersectionPoint::ID());
230 return IntersectionPointPtr(new SketchAPI_IntersectionPoint(aFeature, theExternal));
232 std::shared_ptr<SketchAPI_IntersectionPoint> SketchAPI_Sketch::addIntersectionPoint(
233 const std::string & theExternalName)
235 std::shared_ptr<ModelAPI_Feature> aFeature =
236 compositeFeature()->addFeature(SketchPlugin_IntersectionPoint::ID());
237 return IntersectionPointPtr(new SketchAPI_IntersectionPoint(aFeature, theExternalName));
240 //--------------------------------------------------------------------------------------
241 std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(double theX1, double theY1,
242 double theX2, double theY2)
244 std::shared_ptr<ModelAPI_Feature> aFeature =
245 compositeFeature()->addFeature(SketchPlugin_Line::ID());
246 return LinePtr(new SketchAPI_Line(aFeature, theX1, theY1, theX2, theY2));
248 std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(
249 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
250 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
252 std::shared_ptr<ModelAPI_Feature> aFeature =
253 compositeFeature()->addFeature(SketchPlugin_Line::ID());
254 return LinePtr(new SketchAPI_Line(aFeature, theStartPoint, theEndPoint));
256 std::shared_ptr<SketchAPI_Line>
257 SketchAPI_Sketch::addLine(const ModelHighAPI_Selection & theExternal)
259 std::shared_ptr<ModelAPI_Feature> aFeature =
260 compositeFeature()->addFeature(SketchPlugin_Line::ID());
261 return LinePtr(new SketchAPI_Line(aFeature, theExternal));
263 std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(const std::string & theExternalName)
265 std::shared_ptr<ModelAPI_Feature> aFeature =
266 compositeFeature()->addFeature(SketchPlugin_Line::ID());
267 return LinePtr(new SketchAPI_Line(aFeature, theExternalName));
270 //--------------------------------------------------------------------------------------
271 std::shared_ptr<SketchAPI_Rectangle> SketchAPI_Sketch::addRectangle(double theX1, double theY1,
272 double theX2, double theY2)
274 std::shared_ptr<ModelAPI_Feature> aFeature =
275 compositeFeature()->addFeature(SketchAPI_Rectangle::ID());
276 return RectanglePtr(new SketchAPI_Rectangle(aFeature, theX1, theY1, theX2, theY2));
278 std::shared_ptr<SketchAPI_Rectangle> SketchAPI_Sketch::addRectangle(
279 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
280 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
282 std::shared_ptr<ModelAPI_Feature> aFeature =
283 compositeFeature()->addFeature(SketchAPI_Rectangle::ID());
284 return RectanglePtr(new SketchAPI_Rectangle(aFeature, theStartPoint, theEndPoint));
287 //--------------------------------------------------------------------------------------
288 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(double theCenterX,
292 std::shared_ptr<ModelAPI_Feature> aFeature =
293 compositeFeature()->addFeature(SketchPlugin_Circle::ID());
294 return CirclePtr(new SketchAPI_Circle(aFeature, theCenterX, theCenterY, theRadius));
297 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(
298 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
301 std::shared_ptr<ModelAPI_Feature> aFeature =
302 compositeFeature()->addFeature(SketchPlugin_Circle::ID());
303 return CirclePtr(new SketchAPI_Circle(aFeature, theCenter, theRadius));
306 std::shared_ptr<SketchAPI_MacroCircle> SketchAPI_Sketch::addCircle(double theCenterX,
311 std::shared_ptr<ModelAPI_Feature> aFeature =
312 compositeFeature()->addFeature(SketchPlugin_MacroCircle::ID());
313 return MacroCirclePtr(new SketchAPI_MacroCircle(aFeature, theCenterX, theCenterY,
314 thePassedX, thePassedY));
317 std::shared_ptr<SketchAPI_MacroCircle> SketchAPI_Sketch::addCircle(
318 const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
319 const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint)
321 std::shared_ptr<ModelAPI_Feature> aFeature =
322 compositeFeature()->addFeature(SketchPlugin_MacroCircle::ID());
323 return MacroCirclePtr(new SketchAPI_MacroCircle(aFeature, theCenterPoint, thePassedPoint));
326 std::shared_ptr<SketchAPI_MacroCircle> SketchAPI_Sketch::addCircle(double theX1, double theY1,
327 double theX2, double theY2,
328 double theX3, double theY3)
330 std::shared_ptr<ModelAPI_Feature> aFeature =
331 compositeFeature()->addFeature(SketchPlugin_MacroCircle::ID());
332 return MacroCirclePtr(new SketchAPI_MacroCircle(aFeature, theX1, theY1,
337 std::shared_ptr<SketchAPI_MacroCircle> SketchAPI_Sketch::addCircle(
338 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
339 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
340 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3)
342 std::shared_ptr<ModelAPI_Feature> aFeature =
343 compositeFeature()->addFeature(SketchPlugin_MacroCircle::ID());
344 return MacroCirclePtr(new SketchAPI_MacroCircle(aFeature, thePoint1, thePoint2, thePoint3));
347 std::shared_ptr<SketchAPI_Circle>
348 SketchAPI_Sketch::addCircle(const ModelHighAPI_Selection & theExternal)
350 std::shared_ptr<ModelAPI_Feature> aFeature =
351 compositeFeature()->addFeature(SketchPlugin_Circle::ID());
352 return CirclePtr(new SketchAPI_Circle(aFeature, theExternal));
355 std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(const std::string & theExternalName)
357 // TODO(spo): Add constraint SketchConstraintRigid like in PythonAPI. Is it necessary?
358 std::shared_ptr<ModelAPI_Feature> aFeature =
359 compositeFeature()->addFeature(SketchPlugin_Circle::ID());
360 return CirclePtr(new SketchAPI_Circle(aFeature, theExternalName));
363 //--------------------------------------------------------------------------------------
364 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(double theCenterX, double theCenterY,
365 double theStartX, double theStartY,
366 double theEndX, double theEndY,
369 std::shared_ptr<ModelAPI_Feature> aFeature =
370 compositeFeature()->addFeature(SketchPlugin_Arc::ID());
371 return ArcPtr(new SketchAPI_Arc(aFeature,
372 theCenterX, theCenterY,
373 theStartX, theStartY,
378 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(
379 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
380 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
381 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
384 std::shared_ptr<ModelAPI_Feature> aFeature =
385 compositeFeature()->addFeature(SketchPlugin_Arc::ID());
386 return ArcPtr(new SketchAPI_Arc(aFeature, theCenter, theStart, theEnd, theInversed));
389 std::shared_ptr<SketchAPI_MacroArc> SketchAPI_Sketch::addArc(double theStartX, double theStartY,
390 double theEndX, double theEndY,
391 double thePassedX, double thePassedY)
393 std::shared_ptr<ModelAPI_Feature> aFeature =
394 compositeFeature()->addFeature(SketchPlugin_MacroArc::ID());
395 return MacroArcPtr(new SketchAPI_MacroArc(aFeature,
396 theStartX, theStartY,
398 thePassedX, thePassedY));
401 std::shared_ptr<SketchAPI_MacroArc> SketchAPI_Sketch::addArc(
402 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
403 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
404 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed)
406 std::shared_ptr<ModelAPI_Feature> aFeature =
407 compositeFeature()->addFeature(SketchPlugin_MacroArc::ID());
408 return MacroArcPtr(new SketchAPI_MacroArc(aFeature, theStart, theEnd, thePassed));
411 std::shared_ptr<SketchAPI_MacroArc> SketchAPI_Sketch::addArc(
412 const ModelHighAPI_RefAttr& theTangentPoint,
413 double theEndX, double theEndY,
416 std::shared_ptr<ModelAPI_Feature> aFeature =
417 compositeFeature()->addFeature(SketchPlugin_MacroArc::ID());
418 return MacroArcPtr(new SketchAPI_MacroArc(
419 aFeature, theTangentPoint, theEndX, theEndY, theInversed));
422 std::shared_ptr<SketchAPI_MacroArc> SketchAPI_Sketch::addArc(
423 const ModelHighAPI_RefAttr& theTangentPoint,
424 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
427 std::shared_ptr<ModelAPI_Feature> aFeature =
428 compositeFeature()->addFeature(SketchPlugin_MacroArc::ID());
429 return MacroArcPtr(new SketchAPI_MacroArc(aFeature, theTangentPoint, theEnd, theInversed));
432 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const ModelHighAPI_Selection & theExternal)
434 std::shared_ptr<ModelAPI_Feature> aFeature =
435 compositeFeature()->addFeature(SketchPlugin_Arc::ID());
436 return ArcPtr(new SketchAPI_Arc(aFeature, theExternal));
439 std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const std::string & theExternalName)
441 // TODO(spo): Add constraint SketchConstraintRigid like in PythonAPI. Is it necessary?
442 std::shared_ptr<ModelAPI_Feature> aFeature =
443 compositeFeature()->addFeature(SketchPlugin_Arc::ID());
444 return ArcPtr(new SketchAPI_Arc(aFeature, theExternalName));
447 //--------------------------------------------------------------------------------------
448 std::shared_ptr<SketchAPI_Projection> SketchAPI_Sketch::addProjection(
449 const ModelHighAPI_Selection & theExternalFeature)
451 std::shared_ptr<ModelAPI_Feature> aFeature =
452 compositeFeature()->addFeature(SketchPlugin_Projection::ID());
453 return ProjectionPtr(new SketchAPI_Projection(aFeature, theExternalFeature));
456 std::shared_ptr<SketchAPI_Projection> SketchAPI_Sketch::addProjection(
457 const std::string & theExternalName)
459 std::shared_ptr<ModelAPI_Feature> aFeature =
460 compositeFeature()->addFeature(SketchPlugin_Projection::ID());
461 return ProjectionPtr(new SketchAPI_Projection(aFeature, theExternalName));
464 //--------------------------------------------------------------------------------------
465 std::shared_ptr<SketchAPI_Mirror> SketchAPI_Sketch::addMirror(
466 const ModelHighAPI_RefAttr & theMirrorLine,
467 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects)
469 std::shared_ptr<ModelAPI_Feature> aFeature =
470 compositeFeature()->addFeature(SketchPlugin_ConstraintMirror::ID());
471 return MirrorPtr(new SketchAPI_Mirror(aFeature, theMirrorLine, theObjects));
474 //--------------------------------------------------------------------------------------
475 std::shared_ptr<SketchAPI_Translation> SketchAPI_Sketch::addTranslation(
476 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
477 const ModelHighAPI_RefAttr & thePoint1,
478 const ModelHighAPI_RefAttr & thePoint2,
479 const ModelHighAPI_Integer & theNumberOfObjects,
482 std::shared_ptr<ModelAPI_Feature> aFeature =
483 compositeFeature()->addFeature(SketchPlugin_MultiTranslation::ID());
484 return TranslationPtr(new SketchAPI_Translation(aFeature, theObjects, thePoint1,
485 thePoint2, theNumberOfObjects, theFullValue));
488 //--------------------------------------------------------------------------------------
489 std::shared_ptr<SketchAPI_Rotation> SketchAPI_Sketch::addRotation(
490 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
491 const ModelHighAPI_RefAttr & theCenter,
492 const ModelHighAPI_Double & theAngle,
493 const ModelHighAPI_Integer & theNumberOfObjects,
496 std::shared_ptr<ModelAPI_Feature> aFeature =
497 compositeFeature()->addFeature(SketchPlugin_MultiRotation::ID());
499 new SketchAPI_Rotation(aFeature, theObjects, theCenter,
500 theAngle, theNumberOfObjects, theFullValue));
503 //--------------------------------------------------------------------------------------
504 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::addSplit(
505 const ModelHighAPI_Reference& theFeature,
506 const ModelHighAPI_RefAttr& thePoint1,
507 const ModelHighAPI_RefAttr& thePoint2)
509 std::shared_ptr<ModelAPI_Feature> aFeature =
510 compositeFeature()->addFeature(SketchPlugin_ConstraintSplit::ID());
511 fillAttribute(theFeature, aFeature->reference(SketchPlugin_Constraint::VALUE()));
512 fillAttribute(thePoint1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
513 fillAttribute(thePoint2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
514 //aFeature->execute();
515 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
518 //--------------------------------------------------------------------------------------
519 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::addTrim(
520 const ModelHighAPI_Reference& theFeature,
521 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint)
523 std::shared_ptr<ModelAPI_Feature> aFeature =
524 compositeFeature()->addFeature(SketchPlugin_Trim::ID());
525 fillAttribute(theFeature, aFeature->reference(SketchPlugin_Trim::SELECTED_OBJECT()));
527 AttributePtr anAttribute = aFeature->attribute(SketchPlugin_Trim::SELECTED_POINT());
528 if (anAttribute->attributeType() == GeomDataAPI_Point2D::typeId()) {
529 AttributePoint2DPtr aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttribute);
530 fillAttribute(thePositionPoint, aPointAttr);
533 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
536 //--------------------------------------------------------------------------------------
537 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setAngle(
538 const ModelHighAPI_RefAttr & theLine1,
539 const ModelHighAPI_RefAttr & theLine2,
540 const ModelHighAPI_Double & theValue)
542 std::shared_ptr<ModelAPI_Feature> aFeature =
543 compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
544 fillAttribute(SketcherPrs_Tools::ANGLE_DIRECT,
545 aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID()));
546 // fill the value before llines to avoid calculation of angle value by the Angle feature
547 fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
548 fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
549 fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
551 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
554 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setAngleComplementary(
555 const ModelHighAPI_RefAttr & theLine1,
556 const ModelHighAPI_RefAttr & theLine2,
557 const ModelHighAPI_Double & theValue)
559 std::shared_ptr<ModelAPI_Feature> aFeature =
560 compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
561 fillAttribute(SketcherPrs_Tools::ANGLE_COMPLEMENTARY,
562 aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID()));
563 fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
564 fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
565 fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
566 // fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
568 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
571 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setAngleBackward(
572 const ModelHighAPI_RefAttr & theLine1,
573 const ModelHighAPI_RefAttr & theLine2,
574 const ModelHighAPI_Double & theValue)
576 std::shared_ptr<ModelAPI_Feature> aFeature =
577 compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
578 fillAttribute(SketcherPrs_Tools::ANGLE_BACKWARD,
579 aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID()));
580 fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
581 fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
582 fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
583 // fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
585 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
588 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setCoincident(
589 const ModelHighAPI_RefAttr & thePoint1,
590 const ModelHighAPI_RefAttr & thePoint2)
592 std::shared_ptr<ModelAPI_Feature> aFeature =
593 compositeFeature()->addFeature(SketchPlugin_ConstraintCoincidence::ID());
594 fillAttribute(thePoint1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
595 fillAttribute(thePoint2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
597 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
600 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setCollinear(
601 const ModelHighAPI_RefAttr & theLine1,
602 const ModelHighAPI_RefAttr & theLine2)
604 std::shared_ptr<ModelAPI_Feature> aFeature =
605 compositeFeature()->addFeature(SketchPlugin_ConstraintCollinear::ID());
606 fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
607 fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
609 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
612 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setDistance(
613 const ModelHighAPI_RefAttr & thePoint,
614 const ModelHighAPI_RefAttr & thePointOrLine,
615 const ModelHighAPI_Double & theValue)
617 std::shared_ptr<ModelAPI_Feature> aFeature =
618 compositeFeature()->addFeature(SketchPlugin_ConstraintDistance::ID());
619 fillAttribute(thePoint, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
620 fillAttribute(thePointOrLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
621 fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
623 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
626 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setHorizontalDistance(
627 const ModelHighAPI_RefAttr & thePoint1,
628 const ModelHighAPI_RefAttr & thePoint2,
629 const ModelHighAPI_Double & theValue)
631 std::shared_ptr<ModelAPI_Feature> aFeature =
632 compositeFeature()->addFeature(SketchPlugin_ConstraintDistanceHorizontal::ID());
633 fillAttribute(thePoint1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
634 fillAttribute(thePoint2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
635 fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
637 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
640 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setVerticalDistance(
641 const ModelHighAPI_RefAttr & thePoint1,
642 const ModelHighAPI_RefAttr & thePoint2,
643 const ModelHighAPI_Double & theValue)
645 std::shared_ptr<ModelAPI_Feature> aFeature =
646 compositeFeature()->addFeature(SketchPlugin_ConstraintDistanceVertical::ID());
647 fillAttribute(thePoint1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
648 fillAttribute(thePoint2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
649 fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
651 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
654 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setEqual(
655 const ModelHighAPI_RefAttr & theObject1,
656 const ModelHighAPI_RefAttr & theObject2)
658 std::shared_ptr<ModelAPI_Feature> aFeature =
659 compositeFeature()->addFeature(SketchPlugin_ConstraintEqual::ID());
660 fillAttribute(theObject1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
661 fillAttribute(theObject2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
663 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
666 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setFillet(
667 const ModelHighAPI_RefAttr & thePoint)
669 std::shared_ptr<ModelAPI_Feature> aFeature =
670 compositeFeature()->addFeature(SketchPlugin_Fillet::ID());
671 fillAttribute(thePoint, aFeature->data()->refattr(SketchPlugin_Fillet::FILLET_POINT_ID()));
672 apply(); // finish operation to remove Fillet feature correcly
673 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
676 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setFilletWithRadius(
677 const ModelHighAPI_RefAttr & thePoint,
678 const ModelHighAPI_Double & theRadius)
680 CompositeFeaturePtr aSketch = compositeFeature();
681 int aNbSubs = aSketch->numberOfSubs();
684 InterfacePtr aFilletFeature = setFillet(thePoint);
686 // set radius for just created arc
687 FeaturePtr anArc = aSketch->subFeature(aNbSubs - 1);
688 if (anArc->getKind() == SketchPlugin_Arc::ID())
689 setRadius(ModelHighAPI_RefAttr(ObjectPtr(anArc->lastResult())), ModelHighAPI_Double(theRadius));
691 return aFilletFeature;
694 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setFixed(
695 const ModelHighAPI_RefAttr & theObject)
697 std::shared_ptr<ModelAPI_Feature> aFeature =
698 compositeFeature()->addFeature(SketchPlugin_ConstraintRigid::ID());
699 fillAttribute(theObject, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
701 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
704 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setHorizontal(
705 const ModelHighAPI_RefAttr & theLine)
707 std::shared_ptr<ModelAPI_Feature> aFeature =
708 compositeFeature()->addFeature(SketchPlugin_ConstraintHorizontal::ID());
709 fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
711 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
714 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setLength(
715 const ModelHighAPI_RefAttr & theLine,
716 const ModelHighAPI_Double & theValue)
718 std::shared_ptr<ModelAPI_Feature> aFeature =
719 compositeFeature()->addFeature(SketchPlugin_ConstraintLength::ID());
720 fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
721 fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
723 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
726 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setMiddlePoint(
727 const ModelHighAPI_RefAttr & thePoint,
728 const ModelHighAPI_RefAttr & theLine)
730 std::shared_ptr<ModelAPI_Feature> aFeature =
731 compositeFeature()->addFeature(SketchPlugin_ConstraintMiddle::ID());
732 fillAttribute(thePoint, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
733 fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
735 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
738 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setParallel(
739 const ModelHighAPI_RefAttr & theLine1,
740 const ModelHighAPI_RefAttr & theLine2)
742 std::shared_ptr<ModelAPI_Feature> aFeature =
743 compositeFeature()->addFeature(SketchPlugin_ConstraintParallel::ID());
744 fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
745 fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
747 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
750 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setPerpendicular(
751 const ModelHighAPI_RefAttr & theLine1,
752 const ModelHighAPI_RefAttr & theLine2)
754 std::shared_ptr<ModelAPI_Feature> aFeature =
755 compositeFeature()->addFeature(SketchPlugin_ConstraintPerpendicular::ID());
756 fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
757 fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
759 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
762 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setRadius(
763 const ModelHighAPI_RefAttr & theCircleOrArc,
764 const ModelHighAPI_Double & theValue)
766 std::shared_ptr<ModelAPI_Feature> aFeature =
767 compositeFeature()->addFeature(SketchPlugin_ConstraintRadius::ID());
768 fillAttribute(theCircleOrArc, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
769 fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
771 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
774 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setTangent(
775 const ModelHighAPI_RefAttr & theLine,
776 const ModelHighAPI_RefAttr & theCircle)
778 std::shared_ptr<ModelAPI_Feature> aFeature =
779 compositeFeature()->addFeature(SketchPlugin_ConstraintTangent::ID());
780 fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
781 fillAttribute(theCircle, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
783 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
786 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setVertical(
787 const ModelHighAPI_RefAttr & theLine)
789 std::shared_ptr<ModelAPI_Feature> aFeature =
790 compositeFeature()->addFeature(SketchPlugin_ConstraintVertical::ID());
791 fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
793 return InterfacePtr(new ModelHighAPI_Interface(aFeature));
796 //--------------------------------------------------------------------------------------
798 static std::shared_ptr<GeomAPI_Pnt2d> pointCoordinates(const AttributePtr& thePoint)
800 AttributePoint2DPtr aPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(thePoint);
803 return std::shared_ptr<GeomAPI_Pnt2d>();
806 static std::shared_ptr<GeomAPI_Pnt2d> middlePointOnLine(const FeaturePtr& theFeature)
808 AttributePoint2DPtr aStartAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
809 theFeature->attribute(SketchPlugin_Line::START_ID()));
810 AttributePoint2DPtr aEndAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
811 theFeature->attribute(SketchPlugin_Line::END_ID()));
813 if (!aStartAttr || !aEndAttr)
814 return std::shared_ptr<GeomAPI_Pnt2d>();
816 std::shared_ptr<GeomAPI_XY> aStartPoint = aStartAttr->pnt()->xy();
817 std::shared_ptr<GeomAPI_XY> aEndPoint = aEndAttr->pnt()->xy();
818 return std::shared_ptr<GeomAPI_Pnt2d>(
819 new GeomAPI_Pnt2d(aStartPoint->added(aEndPoint)->multiplied(0.5)));
822 static std::shared_ptr<GeomAPI_Pnt2d> pointOnCircle(const FeaturePtr& theFeature)
824 AttributePoint2DPtr aCenter = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
825 theFeature->attribute(SketchPlugin_Circle::CENTER_ID()));
826 AttributeDoublePtr aRadius = theFeature->real(SketchPlugin_Circle::RADIUS_ID());
828 if (!aCenter || !aRadius)
829 return std::shared_ptr<GeomAPI_Pnt2d>();
831 return std::shared_ptr<GeomAPI_Pnt2d>(
832 new GeomAPI_Pnt2d(aCenter->x() + aRadius->value(), aCenter->y()));
835 static std::shared_ptr<GeomAPI_Pnt2d> middlePointOnArc(const FeaturePtr& theFeature)
837 static const double PI = 3.141592653589793238463;
839 AttributePoint2DPtr aCenterAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
840 theFeature->attribute(SketchPlugin_Arc::CENTER_ID()));
841 AttributePoint2DPtr aStartAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
842 theFeature->attribute(SketchPlugin_Arc::START_ID()));
843 AttributePoint2DPtr aEndAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
844 theFeature->attribute(SketchPlugin_Arc::END_ID()));
846 if (!aCenterAttr || !aStartAttr || !aEndAttr)
847 return std::shared_ptr<GeomAPI_Pnt2d>();
849 std::shared_ptr<GeomAPI_Dir2d> aStartDir(new GeomAPI_Dir2d(
850 aStartAttr->x() - aCenterAttr->x(), aStartAttr->y() - aCenterAttr->y()));
851 std::shared_ptr<GeomAPI_Dir2d> aEndDir(new GeomAPI_Dir2d(
852 aEndAttr->x() - aCenterAttr->x(), aEndAttr->y() - aCenterAttr->y()));
854 double anAngle = aStartDir->angle(aEndDir);
855 bool isReversed = theFeature->boolean(SketchPlugin_Arc::REVERSED_ID())->value();
856 if (isReversed && anAngle > 0.)
858 else if (!isReversed && anAngle <= 0.)
861 double cosA = cos(anAngle);
862 double sinA = sin(anAngle);
864 // rotate start dir to find middle point on arc
865 double aRadius = aStartAttr->pnt()->distance(aCenterAttr->pnt());
866 double x = aCenterAttr->x() + aRadius * (aStartDir->x() * cosA - aStartDir->y() * sinA);
867 double y = aCenterAttr->y() + aRadius * (aStartDir->x() * sinA + aStartDir->y() * cosA);
869 return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(x, y));
872 static std::shared_ptr<GeomAPI_Pnt2d> middlePoint(const ObjectPtr& theObject)
874 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
876 const std::string& aFeatureKind = aFeature->getKind();
877 if (aFeatureKind == SketchPlugin_Point::ID())
878 return pointCoordinates(aFeature->attribute(SketchPlugin_Point::COORD_ID()));
879 else if (aFeatureKind == SketchPlugin_Line::ID())
880 return middlePointOnLine(aFeature);
881 else if (aFeatureKind == SketchPlugin_Circle::ID())
882 return pointOnCircle(aFeature);
883 else if (aFeatureKind == SketchPlugin_Arc::ID())
884 return middlePointOnArc(aFeature);
886 // do not move other types of features
887 return std::shared_ptr<GeomAPI_Pnt2d>();
890 void SketchAPI_Sketch::move(const ModelHighAPI_RefAttr& theMovedEntity,
891 const std::shared_ptr<GeomAPI_Pnt2d>& theTargetPoint)
893 std::shared_ptr<ModelAPI_ObjectMovedMessage> aMessage(new ModelAPI_ObjectMovedMessage);
894 theMovedEntity.fillMessage(aMessage);
896 std::shared_ptr<GeomAPI_Pnt2d> anOriginalPosition;
897 if (aMessage->movedAttribute())
898 anOriginalPosition = pointCoordinates(aMessage->movedAttribute());
900 anOriginalPosition = middlePoint(aMessage->movedObject());
902 if (!anOriginalPosition)
903 return; // something has gone wrong, do not process movement
905 aMessage->setOriginalPosition(anOriginalPosition);
906 aMessage->setCurrentPosition(theTargetPoint);
907 Events_Loop::loop()->send(aMessage);
910 void SketchAPI_Sketch::move(const ModelHighAPI_RefAttr& theMovedEntity,
911 double theTargetX, double theTargetY)
913 std::shared_ptr<GeomAPI_Pnt2d> aTargetPoint(new GeomAPI_Pnt2d(theTargetX, theTargetY));
914 move(theMovedEntity, aTargetPoint);
917 //--------------------------------------------------------------------------------------
919 std::shared_ptr<GeomAPI_Pnt2d> SketchAPI_Sketch::to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint)
921 FeaturePtr aBase = feature();
922 std::shared_ptr<GeomDataAPI_Point> aC = std::dynamic_pointer_cast<GeomDataAPI_Point>(
923 aBase->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
924 std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
925 aBase->attribute(SketchPlugin_Sketch::NORM_ID()));
926 std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
927 aBase->attribute(SketchPlugin_Sketch::DIRX_ID()));
928 std::shared_ptr<GeomAPI_Dir> aY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir())));
930 return thePoint->to2D(aC->pnt(), aX->dir(), aY);
933 //--------------------------------------------------------------------------------------
935 void SketchAPI_Sketch::dump(ModelHighAPI_Dumper& theDumper) const
937 FeaturePtr aBase = feature();
938 const std::string& aDocName = theDumper.name(aBase->document());
940 AttributeSelectionPtr anExternal = aBase->selection(SketchPlugin_SketchEntity::EXTERNAL_ID());
941 if (anExternal->value()) {
942 theDumper << aBase << " = model.addSketch(" << aDocName <<
943 ", " << anExternal << ")" << std::endl;
945 // Sketch is base on a plane.
946 std::shared_ptr<GeomAPI_Pnt> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
947 aBase->attribute(SketchPlugin_Sketch::ORIGIN_ID()))->pnt();
948 std::shared_ptr<GeomAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
949 aBase->attribute(SketchPlugin_Sketch::NORM_ID()))->dir();
950 std::shared_ptr<GeomAPI_Dir> aDirX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
951 aBase->attribute(SketchPlugin_Sketch::DIRX_ID()))->dir();
953 // Check the plane is coordinate plane
954 std::string aPlaneName = defaultPlane(anOrigin, aNormal, aDirX);
955 if(anExternal->context()) { // checking for selected planes
956 if (!aPlaneName.empty()
957 && anExternal->context()->data()
958 && anExternal->context()->data()->name() == aPlaneName) {
959 // dump sketch based on coordinate plane
960 theDumper << aBase << " = model.addSketch(" << aDocName
961 << ", model.standardPlane(\"" << aPlaneName << "\"))" << std::endl;
962 } else { // some other plane
963 theDumper << aBase << " = model.addSketch(" << aDocName <<
964 ", " << anExternal<< ")" << std::endl;
967 if (aPlaneName.empty()) {
968 // needs import additional module
969 theDumper.importModule("GeomAPI");
970 // dump plane parameters
971 const std::string& aSketchName = theDumper.name(aBase);
972 std::string anOriginName = aSketchName + "_origin";
973 std::string aNormalName = aSketchName + "_norm";
974 std::string aDirXName = aSketchName + "_dirx";
975 // use "\n" instead of std::endl to avoid automatic dumping sketch here
976 // and then dumplicate dumping it in the next line
977 theDumper << anOriginName << " = " << anOrigin << "\n"
978 << aNormalName << " = " << aNormal << "\n"
979 << aDirXName << " = " << aDirX << "\n";
980 // dump sketch based on arbitrary plane
981 theDumper << aBase << " = model.addSketch(" << aDocName << ", GeomAPI_Ax3("
982 << anOriginName << ", " << aDirXName << ", " << aNormalName << "))" << std::endl;
984 // dump sketch based on coordinate plane
985 theDumper << aBase << " = model.addSketch(" << aDocName
986 << ", model.defaultPlane(\"" << aPlaneName << "\"))" << std::endl;
991 // dump sketch's subfeatures
992 CompositeFeaturePtr aCompFeat = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aBase);
993 theDumper.processSubs(aCompFeat, true);