]> 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, 17 Aug 2016 07:41:07 +0000 (10:41 +0300)
committerdbv <dbv@opencascade.com>
Thu, 18 Aug 2016 07:02:50 +0000 (10:02 +0300)
CPP High API for FeaturesPlugin_Union;
Dump for FeaturesAPI_Union.

src/FeaturesAPI/CMakeLists.txt
src/FeaturesAPI/FeaturesAPI.i
src/FeaturesAPI/FeaturesAPI_Union.cpp [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_Union.h [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_swig.h
src/PythonAPI/model/features/__init__.py

index 1db8f2dd69765e6b3b03ad9ee6bb28c9ef633c1b..70ea1166d1cc9a8d8dd4b2569cd17d97da963e8a 100644 (file)
@@ -18,6 +18,7 @@ SET(PROJECT_HEADERS
   FeaturesAPI_RevolutionBoolean.h
   FeaturesAPI_Rotation.h
   FeaturesAPI_Translation.h
+  FeaturesAPI_Union.h
 )
 
 SET(PROJECT_SOURCES
@@ -35,6 +36,7 @@ SET(PROJECT_SOURCES
   FeaturesAPI_RevolutionBoolean.cpp
   FeaturesAPI_Rotation.cpp
   FeaturesAPI_Translation.cpp
+  FeaturesAPI_Union.cpp
 )
 
 SET(PROJECT_LIBRARIES
index d2c9f968a0ecba19b569ca9a027bf4070447b359..cc7cbdd54b18dc6d4553d9855ce800624bbb91e9 100644 (file)
@@ -37,6 +37,7 @@
 %shared_ptr(FeaturesAPI_RevolutionFuse)
 %shared_ptr(FeaturesAPI_Rotation)
 %shared_ptr(FeaturesAPI_Translation)
+%shared_ptr(FeaturesAPI_Union)
 
 // all supported interfaces
 %include "FeaturesAPI_Boolean.h"
@@ -53,3 +54,4 @@
 %include "FeaturesAPI_RevolutionBoolean.h"
 %include "FeaturesAPI_Rotation.h"
 %include "FeaturesAPI_Translation.h"
+%include "FeaturesAPI_Union.h"
diff --git a/src/FeaturesAPI/FeaturesAPI_Union.cpp b/src/FeaturesAPI/FeaturesAPI_Union.cpp
new file mode 100644 (file)
index 0000000..a3580a3
--- /dev/null
@@ -0,0 +1,60 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        FeaturesAPI_Union.cpp
+// Created:     09 June 2016
+// Author:      Dmitry Bobylev
+
+#include "FeaturesAPI_Union.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+FeaturesAPI_Union::FeaturesAPI_Union(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+//==================================================================================================
+FeaturesAPI_Union::FeaturesAPI_Union(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                     const std::list<ModelHighAPI_Selection>& theBaseObjects)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    setBase(theBaseObjects);
+  }
+}
+
+//==================================================================================================
+FeaturesAPI_Union::~FeaturesAPI_Union()
+{
+
+}
+
+//==================================================================================================
+void FeaturesAPI_Union::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
+{
+  fillAttribute(theBaseObjects, mybaseObjects);
+
+  execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Union::dump(ModelHighAPI_Dumper& theDumper) const
+{
+  FeaturePtr aBase = feature();
+  const std::string& aDocName = theDumper.name(aBase->document());
+
+  AttributeSelectionListPtr anAttrObjects = aBase->selectionList(FeaturesPlugin_Union::BASE_OBJECTS_ID());
+
+  theDumper << aBase << " = model.addUnion(" << aDocName << ", " << anAttrObjects << ")" << std::endl;
+}
+
+//==================================================================================================
+UnionPtr addUnion(const std::shared_ptr<ModelAPI_Document>& thePart,
+                  const std::list<ModelHighAPI_Selection>& theBaseObjects)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Union::ID());
+  return UnionPtr(new FeaturesAPI_Union(aFeature, theBaseObjects));
+}
diff --git a/src/FeaturesAPI/FeaturesAPI_Union.h b/src/FeaturesAPI/FeaturesAPI_Union.h
new file mode 100644 (file)
index 0000000..e07a9b1
--- /dev/null
@@ -0,0 +1,60 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        FeaturesAPI_Union.h
+// Created:     09 June 2016
+// Author:      Dmitry Bobylev
+
+#ifndef FeaturesAPI_Union_H_
+#define FeaturesAPI_Union_H_
+
+#include "FeaturesAPI.h"
+
+#include <FeaturesPlugin_Union.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Dumper;
+class ModelHighAPI_Selection;
+
+/// \class FeaturesAPI_Union
+/// \ingroup CPPHighAPI
+/// \brief Interface for Union feature.
+class FeaturesAPI_Union: public ModelHighAPI_Interface
+{
+public:
+  /// Constructor without values.
+  FEATURESAPI_EXPORT
+  explicit FeaturesAPI_Union(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+  /// Constructor with values.
+  FEATURESAPI_EXPORT
+  explicit FeaturesAPI_Union(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                             const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+  /// Destructor.
+  FEATURESAPI_EXPORT
+  virtual ~FeaturesAPI_Union();
+
+  INTERFACE_1(FeaturesPlugin_Union::ID(),
+              baseObjects, FeaturesPlugin_Union::BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Base objects */)
+
+  /// Modify base attribute of the feature.
+  FEATURESAPI_EXPORT
+  void setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+  /// Dump wrapped feature
+  FEATURESAPI_EXPORT
+  virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on Union object.
+typedef std::shared_ptr<FeaturesAPI_Union> UnionPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create Union feature.
+FEATURESAPI_EXPORT
+UnionPtr addUnion(const std::shared_ptr<ModelAPI_Document>& thePart,
+                  const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+#endif // FeaturesAPI_Union_H_
index f8da2bcfafc44d752b452ac95d54bc04efccc205..8fff1a42b580a2d93da1a5053a3182f02861aa75 100644 (file)
@@ -24,5 +24,6 @@
   #include "FeaturesAPI_RevolutionBoolean.h"
   #include "FeaturesAPI_Rotation.h"
   #include "FeaturesAPI_Translation.h"
+  #include "FeaturesAPI_Union.h"
 
 #endif // FeaturesAPI_swig_H_
index e7ff9b1c5ba5000a4134fed34c28e3578ebd0ac1..f0b31740715257ac1a46573634ed93d2027910fc 100644 (file)
@@ -6,5 +6,5 @@ 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, addRemoveSubShapes
+from FeaturesAPI import addIntersection, addPartition, addUnion, addRemoveSubShapes
 from FeaturesAPI import addGroup, addRecover