Salome HOME
Merge remote-tracking branch 'remotes/origin/HighLevelDump'
[modules/shaper.git] / src / SketchAPI / SketchAPI_Projection.cpp
1 // Name   : SketchAPI_Projection.cpp
2 // Purpose: 
3 //
4 // History:
5 // 16/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "SketchAPI_Projection.h"
9 //--------------------------------------------------------------------------------------
10 #include <ModelHighAPI_Dumper.h>
11 #include <ModelHighAPI_Selection.h>
12 #include <ModelHighAPI_Tools.h>
13 //--------------------------------------------------------------------------------------
14 SketchAPI_Projection::SketchAPI_Projection(
15     const std::shared_ptr<ModelAPI_Feature> & theFeature)
16 : SketchAPI_SketchEntity(theFeature)
17 {
18   initialize();
19 }
20
21 SketchAPI_Projection::SketchAPI_Projection(
22     const std::shared_ptr<ModelAPI_Feature> & theFeature,
23     const ModelHighAPI_Selection & theExternalFeature )
24 : SketchAPI_SketchEntity(theFeature)
25 {
26   if (initialize()) {
27     setExternalFeature(theExternalFeature);
28   }
29 }
30
31 SketchAPI_Projection::SketchAPI_Projection(
32     const std::shared_ptr<ModelAPI_Feature> & theFeature,
33     const std::string & theExternalName)
34 : SketchAPI_SketchEntity(theFeature)
35 {
36   if (initialize()) {
37     setByExternalName(theExternalName);
38   }
39 }
40
41 SketchAPI_Projection::~SketchAPI_Projection()
42 {
43
44 }
45
46 //--------------------------------------------------------------------------------------
47 void SketchAPI_Projection::setExternalFeature(const ModelHighAPI_Selection & theExternalFeature)
48 {
49   fillAttribute(theExternalFeature, externalFeature());
50
51   execute();
52 }
53
54 void SketchAPI_Projection::setByExternalName(const std::string& theExternalName)
55 {
56   fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
57
58   execute();
59 }
60
61 //--------------------------------------------------------------------------------------
62
63 void SketchAPI_Projection::dump(ModelHighAPI_Dumper& theDumper) const
64 {
65   FeaturePtr aBase = feature();
66   const std::string& aSketchName = theDumper.parentName(aBase);
67
68   AttributeSelectionPtr anExternal = externalFeature();
69   theDumper << aBase << " = " << aSketchName << ".addProjection(" << anExternal << ")" << std::endl;
70   // dump "auxiliary" flag if necessary
71   SketchAPI_SketchEntity::dump(theDumper);
72 }