Salome HOME
Dump Python in the High Level Parameterized Geometry API (issue #1648)
[modules/shaper.git] / src / SketchAPI / SketchAPI_IntersectionPoint.cpp
1 // Name   : SketchAPI_IntersectionPoint.cpp
2 // Purpose: 
3 //
4 // History:
5 // 16/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "SketchAPI_IntersectionPoint.h"
9 //--------------------------------------------------------------------------------------
10 #include <GeomAPI_Pnt2d.h>
11 //--------------------------------------------------------------------------------------
12 #include <ModelHighAPI_Dumper.h>
13 #include <ModelHighAPI_Selection.h>
14 #include <ModelHighAPI_Tools.h>
15 //--------------------------------------------------------------------------------------
16 SketchAPI_IntersectionPoint::SketchAPI_IntersectionPoint(
17     const std::shared_ptr<ModelAPI_Feature> & theFeature)
18 : SketchAPI_SketchEntity(theFeature)
19 {
20   initialize();
21 }
22
23 SketchAPI_IntersectionPoint::SketchAPI_IntersectionPoint(
24     const std::shared_ptr<ModelAPI_Feature> & theFeature,
25     const ModelHighAPI_Selection & theExternal )
26 : SketchAPI_SketchEntity(theFeature)
27 {
28   if (initialize()) {
29     setByExternalLine(theExternal);
30   }
31 }
32
33 SketchAPI_IntersectionPoint::SketchAPI_IntersectionPoint(
34     const std::shared_ptr<ModelAPI_Feature> & theFeature,
35     const std::string & theExternalName )
36 : SketchAPI_SketchEntity(theFeature)
37 {
38   if (initialize()) {
39     setByExternalLineName(theExternalName);
40   }
41 }
42
43 SketchAPI_IntersectionPoint::~SketchAPI_IntersectionPoint()
44 {
45
46 }
47
48 //--------------------------------------------------------------------------------------
49 void SketchAPI_IntersectionPoint::setByExternalLine(const ModelHighAPI_Selection & theExternalLine)
50 {
51   fillAttribute(theExternalLine, externalLine());
52
53   execute();
54 }
55
56 void SketchAPI_IntersectionPoint::setByExternalLineName(const std::string & theExternalLineName)
57 {
58   fillAttribute(ModelHighAPI_Selection("EDGE", theExternalLineName), externalLine());
59
60   execute();
61 }
62
63 //--------------------------------------------------------------------------------------
64
65 void SketchAPI_IntersectionPoint::dump(ModelHighAPI_Dumper& theDumper) const
66 {
67   FeaturePtr aBase = feature();
68   const std::string& aSketchName = theDumper.parentName(aBase);
69
70   AttributeSelectionPtr aLine = externalLine();
71   theDumper << aBase << " = " << aSketchName << ".addIntersectionPoint(" << aLine << ")" << std::endl;
72   // dump "auxiliary" flag if necessary
73   SketchAPI_SketchEntity::dump(theDumper);
74 }