Salome HOME
Issue #1860: fix end lines with spaces
[modules/shaper.git] / src / SketchAPI / SketchAPI_Projection.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2 // Name   : SketchAPI_Projection.cpp
3 // Purpose:
4 //
5 // History:
6 // 16/06/16 - Sergey POKHODENKO - Creation of the file
7
8 //--------------------------------------------------------------------------------------
9 #include "SketchAPI_Projection.h"
10 //--------------------------------------------------------------------------------------
11 #include <ModelHighAPI_Dumper.h>
12 #include <ModelHighAPI_Selection.h>
13 #include <ModelHighAPI_Tools.h>
14 //--------------------------------------------------------------------------------------
15 SketchAPI_Projection::SketchAPI_Projection(
16     const std::shared_ptr<ModelAPI_Feature> & theFeature)
17 : SketchAPI_SketchEntity(theFeature)
18 {
19   initialize();
20 }
21
22 SketchAPI_Projection::SketchAPI_Projection(
23     const std::shared_ptr<ModelAPI_Feature> & theFeature,
24     const ModelHighAPI_Selection & theExternalFeature )
25 : SketchAPI_SketchEntity(theFeature)
26 {
27   if (initialize()) {
28     setExternalFeature(theExternalFeature);
29   }
30 }
31
32 SketchAPI_Projection::SketchAPI_Projection(
33     const std::shared_ptr<ModelAPI_Feature> & theFeature,
34     const std::string & theExternalName)
35 : SketchAPI_SketchEntity(theFeature)
36 {
37   if (initialize()) {
38     setByExternalName(theExternalName);
39   }
40 }
41
42 SketchAPI_Projection::~SketchAPI_Projection()
43 {
44
45 }
46
47 //--------------------------------------------------------------------------------------
48 void SketchAPI_Projection::setExternalFeature(const ModelHighAPI_Selection & theExternalFeature)
49 {
50   fillAttribute(theExternalFeature, externalFeature());
51
52   execute();
53 }
54
55 void SketchAPI_Projection::setByExternalName(const std::string& theExternalName)
56 {
57   fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
58
59   execute();
60 }
61
62 //--------------------------------------------------------------------------------------
63 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Projection::createdFeature() const
64 {
65   AttributeRefAttrPtr aProjectedRefAttr = projectedFeature();
66   FeaturePtr aProjectedFeature = ModelAPI_Feature::feature(aProjectedRefAttr->object());
67
68   return std::shared_ptr<ModelHighAPI_Interface>(new ModelHighAPI_Interface(aProjectedFeature));
69 }
70
71 //--------------------------------------------------------------------------------------
72
73 void SketchAPI_Projection::dump(ModelHighAPI_Dumper& theDumper) const
74 {
75   FeaturePtr aBase = feature();
76   const std::string& aSketchName = theDumper.parentName(aBase);
77
78   AttributeSelectionPtr anExternal = externalFeature();
79   theDumper << aBase << " = " << aSketchName << ".addProjection(" << anExternal << ")" << std::endl;
80   // dump "auxiliary" flag if necessary
81   SketchAPI_SketchEntity::dump(theDumper);
82
83   // Dump created line feature
84   AttributeRefAttrPtr aProjectedRefAttr = projectedFeature();
85   FeaturePtr aProjectedFeature = ModelAPI_Feature::feature(aProjectedRefAttr->object());
86   std::string aProjectedName = theDumper.name(aProjectedFeature, false);
87   theDumper << aProjectedName << " = " << theDumper.name(aBase) << ".createdFeature()" << std::endl;
88 }