]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Dump Python in the High Level Parameterized Geometry API (issue #1648)
authorazv <azv@opencascade.com>
Mon, 8 Aug 2016 09:46:07 +0000 (12:46 +0300)
committerazv <azv@opencascade.com>
Mon, 8 Aug 2016 09:46:07 +0000 (12:46 +0300)
Dump "Intersection point" and "Projection".

src/SketchAPI/SketchAPI_IntersectionPoint.cpp
src/SketchAPI/SketchAPI_IntersectionPoint.h
src/SketchAPI/SketchAPI_Projection.cpp
src/SketchAPI/SketchAPI_Projection.h
src/SketchAPI/SketchAPI_Sketch.cpp
src/SketchAPI/SketchAPI_Sketch.h

index 75ddb603ce5d90885d4bd94a725be5efa345c1d2..ce33717b16b1287ae120f1939f6f98a03866079f 100644 (file)
@@ -9,6 +9,7 @@
 //--------------------------------------------------------------------------------------
 #include <GeomAPI_Pnt2d.h>
 //--------------------------------------------------------------------------------------
+#include <ModelHighAPI_Dumper.h>
 #include <ModelHighAPI_Selection.h>
 #include <ModelHighAPI_Tools.h>
 //--------------------------------------------------------------------------------------
@@ -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);
+}
index 7f0bdfbd86fbb4502cedb33f64a3c75b68353c45..4460f3df577daf76a3cbe9aa793de663baa08232 100644 (file)
@@ -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
index 7ac33fc9193e46eed7cdfb64fd5ce972453e55e5..3a2f457025483a0150cd9e878d5f30b14a492655 100644 (file)
@@ -7,6 +7,8 @@
 //--------------------------------------------------------------------------------------
 #include "SketchAPI_Projection.h"
 //--------------------------------------------------------------------------------------
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Selection.h>
 #include <ModelHighAPI_Tools.h>
 //--------------------------------------------------------------------------------------
 SketchAPI_Projection::SketchAPI_Projection(
@@ -26,6 +28,16 @@ SketchAPI_Projection::SketchAPI_Projection(
   }
 }
 
+SketchAPI_Projection::SketchAPI_Projection(
+    const std::shared_ptr<ModelAPI_Feature> & 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);
+}
index cf18e20f3a0671d4b93c594781af709d1b6a43ee..b704f3f715d82c34a7574138b8ec9f9108607bd3 100644 (file)
@@ -30,6 +30,10 @@ public:
   SKETCHAPI_EXPORT
   SketchAPI_Projection(const std::shared_ptr<ModelAPI_Feature> & theFeature,
                        const ModelHighAPI_Selection & theExternalFeature);
+  /// Constructor with values
+  SKETCHAPI_EXPORT
+  SketchAPI_Projection(const std::shared_ptr<ModelAPI_Feature> & 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
index 32ed616d36adfb38692bb29fb3d75d88d0110a4a..d86f075dffc9683d6cd38683114fe2b35eccebe0 100644 (file)
@@ -360,6 +360,13 @@ std::shared_ptr<SketchAPI_Projection> SketchAPI_Sketch::addProjection(
   return ProjectionPtr(new SketchAPI_Projection(aFeature, theExternalFeature));
 }
 
+std::shared_ptr<SketchAPI_Projection> SketchAPI_Sketch::addProjection(
+    const std::string & theExternalName)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Projection::ID());
+  return ProjectionPtr(new SketchAPI_Projection(aFeature, theExternalName));
+}
+
 //--------------------------------------------------------------------------------------
 std::shared_ptr<SketchAPI_Mirror> SketchAPI_Sketch::addMirror(
     const ModelHighAPI_RefAttr & theMirrorLine,
index e74096348eeda06487d5b7981f90c05fc1b3a2cf..1e17d9daa22c079f03caea22e816a9553ca9ce0b 100644 (file)
@@ -209,6 +209,10 @@ public:
   std::shared_ptr<SketchAPI_Projection> addProjection(
       const ModelHighAPI_Selection & theExternalFeature);
 
+  /// Add projection
+  SKETCHAPI_EXPORT
+  std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName);
+
   /// Add mirror
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_Mirror> addMirror(