Salome HOME
Issue #1648: Dump Python in the High Level Parameterized Geometry API
authordbv <dbv@opencascade.com>
Fri, 12 Aug 2016 12:54:05 +0000 (15:54 +0300)
committerdbv <dbv@opencascade.com>
Mon, 15 Aug 2016 11:03:13 +0000 (14:03 +0300)
Dump for FeaturesAPI_Pipe

src/FeaturesAPI/FeaturesAPI_Pipe.cpp
src/FeaturesAPI/FeaturesAPI_Pipe.h
src/PythonAPI/model/features/__init__.py

index 3ca9a4e54e78263ea85fd030522843c8feeee35e..f99cccef2a3d2630b9e76c3b89649855420a33c8 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "FeaturesAPI_Pipe.h"
 
+#include <ModelHighAPI_Dumper.h>
 #include <ModelHighAPI_Tools.h>
 
 //==================================================================================================
@@ -110,6 +111,35 @@ void FeaturesAPI_Pipe::setByBasePathLocations(const std::list<ModelHighAPI_Selec
   execute();
 }
 
+//==================================================================================================
+void FeaturesAPI_Pipe::dump(ModelHighAPI_Dumper& theDumper) const
+{
+  FeaturePtr aBase = feature();
+  const std::string& aDocName = theDumper.name(aBase->document());
+
+  AttributeSelectionListPtr anAttrObjects = aBase->selectionList(FeaturesPlugin_Pipe::BASE_OBJECTS_ID());
+  AttributeSelectionPtr anAttrPath = aBase->selection(FeaturesPlugin_Pipe::PATH_OBJECT_ID());
+
+  theDumper << aBase << " = model.addPipe(" << aDocName << ", "
+            << anAttrObjects << ", " << anAttrPath;
+
+  std::string aCreationMethod = aBase->string(FeaturesPlugin_Pipe::CREATION_METHOD())->value();
+
+  if(aCreationMethod == FeaturesPlugin_Pipe::CREATION_METHOD_SIMPLE()) {
+    // Do nothing;
+  } else if(aCreationMethod == FeaturesPlugin_Pipe::CREATION_METHOD_BINORMAL()) {
+    AttributeSelectionPtr anAttrBiNormal = aBase->selection(FeaturesPlugin_Pipe::BINORMAL_ID());
+
+    theDumper << ", " << anAttrBiNormal;
+  } else if(aCreationMethod == FeaturesPlugin_Pipe::CREATION_METHOD_LOCATIONS()) {
+    AttributeSelectionListPtr anAttrLocations = aBase->selectionList(FeaturesPlugin_Pipe::LOCATIONS_ID());
+
+    theDumper << ", " << anAttrLocations;
+  }
+
+  theDumper << ")" << std::endl;
+}
+
 //==================================================================================================
 PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
                 const std::list<ModelHighAPI_Selection>& theBaseObjects,
index 1a3ee09a03810a5debbaee02b7634e1f7b978876..e45fd369f585c0acee352217d36884feffc1e5ad 100644 (file)
@@ -14,6 +14,7 @@
 #include <ModelHighAPI_Interface.h>
 #include <ModelHighAPI_Macro.h>
 
+class ModelHighAPI_Dumper;
 class ModelHighAPI_Selection;
 
 /// \class FeaturesAPI_Pipe
@@ -81,6 +82,10 @@ public:
   void setByBasePathLocations(const std::list<ModelHighAPI_Selection>& theBaseObjects,
                               const ModelHighAPI_Selection& thePath,
                               const std::list<ModelHighAPI_Selection>& theLocations);
+
+  /// Dump wrapped feature
+  FEATURESAPI_EXPORT
+  virtual void dump(ModelHighAPI_Dumper& theDumper) const;
 };
 
 /// Pointer on Pipe object.
index 186a4018fc0258e2177b71eb5d67633dfdd34724..ad4104ea13a0151685b76f87d4b0ac7785476c81 100644 (file)
@@ -2,12 +2,9 @@
 """
 
 from FeaturesAPI import addPlacement, addRotation, addTranslation
-
-from FeaturesAPI import addCut, addFuse, addCommon, addSmash, addFill
-
-from FeaturesAPI import addIntersection, addPartition
-
 from FeaturesAPI import addExtrusion, addExtrusionCut, addExtrusionFuse
 from FeaturesAPI import addRevolution, addRevolutionCut, addRevolutionFuse
-
+from FeaturesAPI import addPipe
+from FeaturesAPI import addCut, addFuse, addCommon, addSmash, addFill
+from FeaturesAPI import addIntersection, addPartition
 from FeaturesAPI import addGroup, addRecover