]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1648: Dump Python in the High Level Parameterized Geometry API
authordbv <dbv@opencascade.com>
Wed, 10 Aug 2016 12:04:44 +0000 (15:04 +0300)
committerdbv <dbv@opencascade.com>
Wed, 10 Aug 2016 12:04:44 +0000 (15:04 +0300)
Added dump for FeaturesAPI_Revolution and FeaturesAPI_Boolean

src/FeaturesAPI/FeaturesAPI_Boolean.cpp
src/FeaturesAPI/FeaturesAPI_Boolean.h
src/FeaturesAPI/FeaturesAPI_Extrusion.h
src/FeaturesAPI/FeaturesAPI_Revolution.cpp
src/FeaturesAPI/FeaturesAPI_Revolution.h

index 4ee728c6c45132dee6e2606b599a74b76652dbd8..062731c89972585ea13c405c912139ac57f46f68 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "FeaturesAPI_Boolean.h"
 
+#include <ModelHighAPI_Dumper.h>
 #include <ModelHighAPI_Integer.h>
 #include <ModelHighAPI_Selection.h>
 #include <ModelHighAPI_Tools.h>
@@ -63,6 +64,31 @@ void FeaturesAPI_Boolean::setToolObjects(const std::list<ModelHighAPI_Selection>
   execute();
 }
 
+//==================================================================================================
+void FeaturesAPI_Boolean::dump(ModelHighAPI_Dumper& theDumper) const
+{
+  FeaturePtr aBase = feature();
+
+  FeaturesPlugin_Boolean::OperationType aType =
+      (FeaturesPlugin_Boolean::OperationType)aBase->integer(FeaturesPlugin_Boolean::TYPE_ID())->value();
+
+  theDumper << aBase << " = model.add";
+
+  switch(aType) {
+    case FeaturesPlugin_Boolean::BOOL_CUT:    theDumper << "Cut";    break;
+    case FeaturesPlugin_Boolean::BOOL_FUSE:   theDumper << "Fuse";   break;
+    case FeaturesPlugin_Boolean::BOOL_COMMON: theDumper << "Common"; break;
+    case FeaturesPlugin_Boolean::BOOL_FILL:   theDumper << "Fill";   break;
+    case FeaturesPlugin_Boolean::BOOL_SMASH:  theDumper << "Smash";  break;
+  }
+
+  const std::string& aDocName = theDumper.name(aBase->document());
+  AttributeSelectionListPtr anObjects = aBase->selectionList(FeaturesPlugin_Boolean::OBJECT_LIST_ID());
+  AttributeSelectionListPtr aTools = aBase->selectionList(FeaturesPlugin_Boolean::TOOL_LIST_ID());
+
+  theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools << ")" << std::endl;
+}
+
 //==================================================================================================
 BooleanPtr addCut(const std::shared_ptr<ModelAPI_Document>& thePart,
                   const std::list<ModelHighAPI_Selection>& theMainObjects,
index 9ad38f4bcf4b462cb0cb8a3c1db36a8b4f441f1e..f314158cd851905708017ebc6aa5d03d64f1032a 100644 (file)
@@ -54,6 +54,10 @@ public:
   /// Set tool objects.
   FEATURESAPI_EXPORT
   void setToolObjects(const std::list<ModelHighAPI_Selection>& theToolObjects);
+
+  /// Dump wrapped feature
+  FEATURESAPI_EXPORT
+  virtual void dump(ModelHighAPI_Dumper& theDumper) const;
 };
 
 /// Pointer on Boolean object.
index f2ca23485e8176a367fcafef9b3b207a2054a1a9..456da2c044457ea3fe4a4af850ae1358a0631f1f 100644 (file)
@@ -112,7 +112,7 @@ public:
                            const ModelHighAPI_Selection& theFromObject,
                            const ModelHighAPI_Double& theFromOffset);
 
-    /// Dump wrapped feature
+  /// Dump wrapped feature
   FEATURESAPI_EXPORT
   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
 };
index fc982e9c1e00431c407fab17dc869489ae7f62b8..d54b660fb9d4c9c8b460410b0a0c788c376f8077 100644 (file)
@@ -7,6 +7,7 @@
 #include "FeaturesAPI_Revolution.h"
 
 #include <ModelHighAPI_Double.h>
+#include <ModelHighAPI_Dumper.h>
 #include <ModelHighAPI_Tools.h>
 
 //==================================================================================================
@@ -120,6 +121,36 @@ void FeaturesAPI_Revolution::setPlanesAndOffsets(const ModelHighAPI_Selection& t
   execute();
 }
 
+//==================================================================================================
+void FeaturesAPI_Revolution::dump(ModelHighAPI_Dumper& theDumper) const
+{
+  FeaturePtr aBase = feature();
+  const std::string& aDocName = theDumper.name(aBase->document());
+
+  AttributeSelectionListPtr anObjects = aBase->selectionList(FeaturesPlugin_Revolution::BASE_OBJECTS_ID());
+  AttributeSelectionPtr anAxis = aBase->selection(FeaturesPlugin_Revolution::AXIS_OBJECT_ID());
+
+  theDumper << aBase << " = model.addRevolution(" << aDocName << ", " << anObjects << ", " << anAxis;
+
+  std::string aCreationMethod = aBase->string(FeaturesPlugin_Revolution::CREATION_METHOD())->value();
+
+  if(aCreationMethod == FeaturesPlugin_Revolution::CREATION_METHOD_BY_ANGLES()) {
+    AttributeDoublePtr anAttrToAngle = aBase->real(FeaturesPlugin_Revolution::TO_ANGLE_ID());
+    AttributeDoublePtr anAttrFromAngle = aBase->real(FeaturesPlugin_Revolution::FROM_ANGLE_ID());
+
+    theDumper << ", " << anAttrToAngle << ", " << anAttrFromAngle;
+  } else if(aCreationMethod == FeaturesPlugin_Revolution::CREATION_METHOD_BY_PLANES()) {
+    AttributeSelectionPtr anAttrToObject = aBase->selection(FeaturesPlugin_Revolution::TO_OBJECT_ID());
+    AttributeDoublePtr anAttrToOffset = aBase->real(FeaturesPlugin_Revolution::TO_OFFSET_ID());
+    AttributeSelectionPtr anAttrFromObject = aBase->selection(FeaturesPlugin_Revolution::FROM_OBJECT_ID());
+    AttributeDoublePtr anAttrFromOffset = aBase->real(FeaturesPlugin_Revolution::FROM_OFFSET_ID());
+
+    theDumper << ", " << anAttrToObject << ", " << anAttrToOffset << ", " << anAttrFromObject << ", " << anAttrFromOffset;
+  }
+
+  theDumper << ")" << std::endl;
+}
+
 //==================================================================================================
 RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
                             const std::list<ModelHighAPI_Selection>& theBaseObjects,
index a8e4bc6dd80eb36cef3c55cba3335dd40b6611ac..5b296ba6c2f995fac2eac7df08dfa154d71986f4 100644 (file)
@@ -90,6 +90,10 @@ public:
                            const ModelHighAPI_Double& theToOffset,
                            const ModelHighAPI_Selection& theFromObject,
                            const ModelHighAPI_Double& theFromOffset);
+
+  /// Dump wrapped feature
+  FEATURESAPI_EXPORT
+  virtual void dump(ModelHighAPI_Dumper& theDumper) const;
 };
 
 /// Pointer on Revolution object.