1 // Name : SketchAPI_Projection.cpp
5 // 16/06/16 - Sergey POKHODENKO - Creation of the file
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)
21 SketchAPI_Projection::SketchAPI_Projection(
22 const std::shared_ptr<ModelAPI_Feature> & theFeature,
23 const ModelHighAPI_Selection & theExternalFeature )
24 : SketchAPI_SketchEntity(theFeature)
27 setExternalFeature(theExternalFeature);
31 SketchAPI_Projection::SketchAPI_Projection(
32 const std::shared_ptr<ModelAPI_Feature> & theFeature,
33 const std::string & theExternalName)
34 : SketchAPI_SketchEntity(theFeature)
37 setByExternalName(theExternalName);
41 SketchAPI_Projection::~SketchAPI_Projection()
46 //--------------------------------------------------------------------------------------
47 void SketchAPI_Projection::setExternalFeature(const ModelHighAPI_Selection & theExternalFeature)
49 fillAttribute(theExternalFeature, externalFeature());
54 void SketchAPI_Projection::setByExternalName(const std::string& theExternalName)
56 fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
61 //--------------------------------------------------------------------------------------
62 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Projection::createdFeature() const
64 AttributeRefAttrPtr aProjectedRefAttr = projectedFeature();
65 FeaturePtr aProjectedFeature = ModelAPI_Feature::feature(aProjectedRefAttr->object());
67 return std::shared_ptr<ModelHighAPI_Interface>(new ModelHighAPI_Interface(aProjectedFeature));
70 //--------------------------------------------------------------------------------------
72 void SketchAPI_Projection::dump(ModelHighAPI_Dumper& theDumper) const
74 FeaturePtr aBase = feature();
75 const std::string& aSketchName = theDumper.parentName(aBase);
77 AttributeSelectionPtr anExternal = externalFeature();
78 theDumper << aBase << " = " << aSketchName << ".addProjection(" << anExternal << ")" << std::endl;
79 // dump "auxiliary" flag if necessary
80 SketchAPI_SketchEntity::dump(theDumper);
82 // Dump created line feature
83 AttributeRefAttrPtr aProjectedRefAttr = projectedFeature();
84 FeaturePtr aProjectedFeature = ModelAPI_Feature::feature(aProjectedRefAttr->object());
85 std::string aProjectedName = theDumper.name(aProjectedFeature, false);
86 theDumper << aProjectedName << " = " << theDumper.name(aBase) << ".createdFeature()" << std::endl;