1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2 // Name : SketchAPI_Projection.cpp
6 // 16/06/16 - Sergey POKHODENKO - Creation of the file
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)
22 SketchAPI_Projection::SketchAPI_Projection(
23 const std::shared_ptr<ModelAPI_Feature> & theFeature,
24 const ModelHighAPI_Selection & theExternalFeature )
25 : SketchAPI_SketchEntity(theFeature)
28 setExternalFeature(theExternalFeature);
32 SketchAPI_Projection::SketchAPI_Projection(
33 const std::shared_ptr<ModelAPI_Feature> & theFeature,
34 const std::string & theExternalName)
35 : SketchAPI_SketchEntity(theFeature)
38 setByExternalName(theExternalName);
42 SketchAPI_Projection::~SketchAPI_Projection()
47 //--------------------------------------------------------------------------------------
48 void SketchAPI_Projection::setExternalFeature(const ModelHighAPI_Selection & theExternalFeature)
50 fillAttribute(theExternalFeature, externalFeature());
55 void SketchAPI_Projection::setByExternalName(const std::string& theExternalName)
57 fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
62 //--------------------------------------------------------------------------------------
63 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Projection::createdFeature() const
65 AttributeRefAttrPtr aProjectedRefAttr = projectedFeature();
66 FeaturePtr aProjectedFeature = ModelAPI_Feature::feature(aProjectedRefAttr->object());
68 return std::shared_ptr<ModelHighAPI_Interface>(new ModelHighAPI_Interface(aProjectedFeature));
71 //--------------------------------------------------------------------------------------
73 void SketchAPI_Projection::dump(ModelHighAPI_Dumper& theDumper) const
75 FeaturePtr aBase = feature();
76 const std::string& aSketchName = theDumper.parentName(aBase);
78 AttributeSelectionPtr anExternal = externalFeature();
79 theDumper << aBase << " = " << aSketchName << ".addProjection(" << anExternal << ")" << std::endl;
80 // dump "auxiliary" flag if necessary
81 SketchAPI_SketchEntity::dump(theDumper);
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;