From: azv Date: Mon, 8 Aug 2016 09:46:07 +0000 (+0300) Subject: Dump Python in the High Level Parameterized Geometry API (issue #1648) X-Git-Tag: V_2.5.0~137^2~86 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5944daf4fc389aee952abc5ace5a618512684f87;p=modules%2Fshaper.git Dump Python in the High Level Parameterized Geometry API (issue #1648) Dump "Intersection point" and "Projection". --- diff --git a/src/SketchAPI/SketchAPI_IntersectionPoint.cpp b/src/SketchAPI/SketchAPI_IntersectionPoint.cpp index 75ddb603c..ce33717b1 100644 --- a/src/SketchAPI/SketchAPI_IntersectionPoint.cpp +++ b/src/SketchAPI/SketchAPI_IntersectionPoint.cpp @@ -9,6 +9,7 @@ //-------------------------------------------------------------------------------------- #include //-------------------------------------------------------------------------------------- +#include #include #include //-------------------------------------------------------------------------------------- @@ -60,3 +61,14 @@ void SketchAPI_IntersectionPoint::setByExternalLineName(const std::string & theE } //-------------------------------------------------------------------------------------- + +void SketchAPI_IntersectionPoint::dump(ModelHighAPI_Dumper& theDumper) const +{ + FeaturePtr aBase = feature(); + const std::string& aSketchName = theDumper.parentName(aBase); + + AttributeSelectionPtr aLine = externalLine(); + theDumper << aBase << " = " << aSketchName << ".addIntersectionPoint(" << aLine << ")" << std::endl; + // dump "auxiliary" flag if necessary + SketchAPI_SketchEntity::dump(theDumper); +} diff --git a/src/SketchAPI/SketchAPI_IntersectionPoint.h b/src/SketchAPI/SketchAPI_IntersectionPoint.h index 7f0bdfbd8..4460f3df5 100644 --- a/src/SketchAPI/SketchAPI_IntersectionPoint.h +++ b/src/SketchAPI/SketchAPI_IntersectionPoint.h @@ -50,6 +50,10 @@ public: /// Set by external name SKETCHAPI_EXPORT void setByExternalLineName(const std::string & theExternalLineName); + + /// Dump wrapped feature + SKETCHAPI_EXPORT + virtual void dump(ModelHighAPI_Dumper& theDumper) const; }; //! Pointer on IntersectionPoint object diff --git a/src/SketchAPI/SketchAPI_Projection.cpp b/src/SketchAPI/SketchAPI_Projection.cpp index 7ac33fc91..3a2f45702 100644 --- a/src/SketchAPI/SketchAPI_Projection.cpp +++ b/src/SketchAPI/SketchAPI_Projection.cpp @@ -7,6 +7,8 @@ //-------------------------------------------------------------------------------------- #include "SketchAPI_Projection.h" //-------------------------------------------------------------------------------------- +#include +#include #include //-------------------------------------------------------------------------------------- SketchAPI_Projection::SketchAPI_Projection( @@ -26,6 +28,16 @@ SketchAPI_Projection::SketchAPI_Projection( } } +SketchAPI_Projection::SketchAPI_Projection( + const std::shared_ptr & theFeature, + const std::string & theExternalName) +: SketchAPI_SketchEntity(theFeature) +{ + if (initialize()) { + setByExternalName(theExternalName); + } +} + SketchAPI_Projection::~SketchAPI_Projection() { @@ -39,4 +51,22 @@ void SketchAPI_Projection::setExternalFeature(const ModelHighAPI_Selection & the execute(); } +void SketchAPI_Projection::setByExternalName(const std::string& theExternalName) +{ + fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external()); + + execute(); +} + //-------------------------------------------------------------------------------------- + +void SketchAPI_Projection::dump(ModelHighAPI_Dumper& theDumper) const +{ + FeaturePtr aBase = feature(); + const std::string& aSketchName = theDumper.parentName(aBase); + + AttributeSelectionPtr anExternal = externalFeature(); + theDumper << aBase << " = " << aSketchName << ".addProjection(" << anExternal << ")" << std::endl; + // dump "auxiliary" flag if necessary + SketchAPI_SketchEntity::dump(theDumper); +} diff --git a/src/SketchAPI/SketchAPI_Projection.h b/src/SketchAPI/SketchAPI_Projection.h index cf18e20f3..b704f3f71 100644 --- a/src/SketchAPI/SketchAPI_Projection.h +++ b/src/SketchAPI/SketchAPI_Projection.h @@ -30,6 +30,10 @@ public: SKETCHAPI_EXPORT SketchAPI_Projection(const std::shared_ptr & theFeature, const ModelHighAPI_Selection & theExternalFeature); + /// Constructor with values + SKETCHAPI_EXPORT + SketchAPI_Projection(const std::shared_ptr & theFeature, + const std::string & theExternalName); /// Destructor SKETCHAPI_EXPORT virtual ~SketchAPI_Projection(); @@ -43,6 +47,14 @@ public: /// Set external feature SKETCHAPI_EXPORT void setExternalFeature(const ModelHighAPI_Selection & theExternalLine); + + /// Set by external name + SKETCHAPI_EXPORT + void setByExternalName(const std::string & theExternalName); + + /// Dump wrapped feature + SKETCHAPI_EXPORT + virtual void dump(ModelHighAPI_Dumper& theDumper) const; }; //! Pointer on Projection object diff --git a/src/SketchAPI/SketchAPI_Sketch.cpp b/src/SketchAPI/SketchAPI_Sketch.cpp index 32ed616d3..d86f075df 100644 --- a/src/SketchAPI/SketchAPI_Sketch.cpp +++ b/src/SketchAPI/SketchAPI_Sketch.cpp @@ -360,6 +360,13 @@ std::shared_ptr SketchAPI_Sketch::addProjection( return ProjectionPtr(new SketchAPI_Projection(aFeature, theExternalFeature)); } +std::shared_ptr SketchAPI_Sketch::addProjection( + const std::string & theExternalName) +{ + std::shared_ptr aFeature = compositeFeature()->addFeature(SketchPlugin_Projection::ID()); + return ProjectionPtr(new SketchAPI_Projection(aFeature, theExternalName)); +} + //-------------------------------------------------------------------------------------- std::shared_ptr SketchAPI_Sketch::addMirror( const ModelHighAPI_RefAttr & theMirrorLine, diff --git a/src/SketchAPI/SketchAPI_Sketch.h b/src/SketchAPI/SketchAPI_Sketch.h index e74096348..1e17d9daa 100644 --- a/src/SketchAPI/SketchAPI_Sketch.h +++ b/src/SketchAPI/SketchAPI_Sketch.h @@ -209,6 +209,10 @@ public: std::shared_ptr addProjection( const ModelHighAPI_Selection & theExternalFeature); + /// Add projection + SKETCHAPI_EXPORT + std::shared_ptr addProjection(const std::string & theExternalName); + /// Add mirror SKETCHAPI_EXPORT std::shared_ptr addMirror(