]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
CPP API for FeaturesPlugin_Boolean
authordbv <dbv@opencascade.com>
Wed, 8 Jun 2016 12:49:52 +0000 (15:49 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 17 Jun 2016 11:41:06 +0000 (14:41 +0300)
src/FeaturesAPI/CMakeLists.txt
src/FeaturesAPI/FeaturesAPI.i
src/FeaturesAPI/FeaturesAPI_Boolean.cpp [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_Boolean.h [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_Placement.h
src/FeaturesAPI/FeaturesAPI_swig.h
src/PythonAPI/Test/TestFeatures.py

index c5701e9edcbbb83248308f2e29ef9c109de01904..4daaa9f5f59ef0dc6e50df5281c67125b0a8b565 100644 (file)
@@ -4,12 +4,14 @@ INCLUDE(Common)
 
 SET(PROJECT_HEADERS
   FeaturesAPI.h
+  FeaturesAPI_Boolean.h
   FeaturesAPI_Placement.h
   FeaturesAPI_Rotation.h
   FeaturesAPI_Translation.h
 )
 
 SET(PROJECT_SOURCES
+  FeaturesAPI_Boolean.cpp
   FeaturesAPI_Placement.cpp
   FeaturesAPI_Rotation.cpp
   FeaturesAPI_Translation.cpp
index 81ab3f8a667eae7efb3c5f44c4b3dca2c52d4999..226d74492ce87e3e9d5c443f69128ce89cd14f98 100644 (file)
 %include "std_shared_ptr.i"
 
 // shared pointers
+%shared_ptr(FeaturesAPI_Boolean)
 %shared_ptr(FeaturesAPI_Placement)
 %shared_ptr(FeaturesAPI_Rotation)
 %shared_ptr(FeaturesAPI_Translation)
 
 // all supported interfaces
+%include "FeaturesAPI_Boolean.h"
 %include "FeaturesAPI_Placement.h"
 %include "FeaturesAPI_Rotation.h"
 %include "FeaturesAPI_Translation.h"
diff --git a/src/FeaturesAPI/FeaturesAPI_Boolean.cpp b/src/FeaturesAPI/FeaturesAPI_Boolean.cpp
new file mode 100644 (file)
index 0000000..83e65fe
--- /dev/null
@@ -0,0 +1,111 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        FeaturesAPI_Boolean.cpp
+// Created:     07 June 2016
+// Author:      Dmitry Bobylev
+
+#include "FeaturesAPI_Boolean.h"
+
+#include <ModelHighAPI_Integer.h>
+#include <ModelHighAPI_Selection.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+FeaturesAPI_Boolean::FeaturesAPI_Boolean(const std::shared_ptr<ModelAPI_Feature> & theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+//==================================================================================================
+FeaturesAPI_Boolean::FeaturesAPI_Boolean(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+                                         const ModelHighAPI_Integer& theBoolType,
+                                         const std::list<ModelHighAPI_Selection>& theMainObjects,
+                                         const std::list<ModelHighAPI_Selection>& theToolObjects)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    setBoolType(theBoolType);
+    setMainObjects(theMainObjects);
+    setToolObjects(theToolObjects);
+  }
+}
+
+//==================================================================================================
+FeaturesAPI_Boolean::~FeaturesAPI_Boolean()
+{
+
+}
+
+//==================================================================================================
+void FeaturesAPI_Boolean::setBoolType(const ModelHighAPI_Integer& theBoolType)
+{
+  fillAttribute(theBoolType, myboolType);
+
+  execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Boolean::setMainObjects(const std::list<ModelHighAPI_Selection>& theMainObjects)
+{
+  fillAttribute(theMainObjects, mymainObjects);
+
+  execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Boolean::setToolObjects(const std::list<ModelHighAPI_Selection>& theToolObjects)
+{
+  fillAttribute(theToolObjects, mytoolObjects);
+
+  execute();
+}
+
+// TODO(spo): make add* as static functions of the class
+//==================================================================================================
+BooleanPtr addCut(const std::shared_ptr<ModelAPI_Document> & thePart,
+                  const std::list<ModelHighAPI_Selection>& theMainObjects,
+                  const std::list<ModelHighAPI_Selection>& theToolObjects)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
+  return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
+                                            FeaturesPlugin_Boolean::BOOL_CUT,
+                                            theMainObjects,
+                                            theToolObjects));
+}
+
+//==================================================================================================
+BooleanPtr addFuse(const std::shared_ptr<ModelAPI_Document> & thePart,
+                   const std::list<ModelHighAPI_Selection>& theObjects)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
+  std::list<ModelHighAPI_Selection> aToolObjects;
+  return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
+                                            FeaturesPlugin_Boolean::BOOL_FUSE,
+                                            theObjects,
+                                            aToolObjects));
+}
+
+//==================================================================================================
+BooleanPtr addFuse(const std::shared_ptr<ModelAPI_Document> & thePart,
+                   const std::list<ModelHighAPI_Selection>& theMainObjects,
+                   const std::list<ModelHighAPI_Selection>& theToolObjects)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
+  return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
+                                            FeaturesPlugin_Boolean::BOOL_FUSE,
+                                            theMainObjects,
+                                            theToolObjects));
+}
+
+//==================================================================================================
+BooleanPtr addCommon(const std::shared_ptr<ModelAPI_Document> & thePart,
+                     const std::list<ModelHighAPI_Selection>& theMainObjects,
+                     const std::list<ModelHighAPI_Selection>& theToolObjects)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
+  return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
+                                            FeaturesPlugin_Boolean::BOOL_COMMON,
+                                            theMainObjects,
+                                            theToolObjects));
+}
diff --git a/src/FeaturesAPI/FeaturesAPI_Boolean.h b/src/FeaturesAPI/FeaturesAPI_Boolean.h
new file mode 100644 (file)
index 0000000..bcbd40f
--- /dev/null
@@ -0,0 +1,89 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        FeaturesAPI_Boolean.h
+// Created:     07 June 2016
+// Author:      Dmitry Bobylev
+
+#ifndef FeaturesAPI_Boolean_H_
+#define FeaturesAPI_Boolean_H_
+
+#include "FeaturesAPI.h"
+
+#include <FeaturesPlugin_Boolean.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Integer;
+class ModelHighAPI_Selection;
+
+/// \class FeaturesAPI_Boolean
+/// \ingroup CPPHighAPI
+/// \brief Interface for Boolean feature.
+class FeaturesAPI_Boolean : public ModelHighAPI_Interface
+{
+public:
+  /// Constructor without values.
+  FEATURESAPI_EXPORT
+  explicit FeaturesAPI_Boolean(const std::shared_ptr<ModelAPI_Feature> & theFeature);
+
+  /// Constructor with values.
+  FEATURESAPI_EXPORT
+  FeaturesAPI_Boolean(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+                      const ModelHighAPI_Integer& theBoolType,
+                      const std::list<ModelHighAPI_Selection>& theMainObjects,
+                      const std::list<ModelHighAPI_Selection>& theToolObjects);
+
+  /// Destructor.
+  FEATURESAPI_EXPORT
+  virtual ~FeaturesAPI_Boolean();
+
+  INTERFACE_3(FeaturesPlugin_Boolean::ID(),
+              boolType, FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeInteger, /** Operation type */,
+              mainObjects, FeaturesPlugin_Boolean::OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList, /** Main objects */,
+              toolObjects, FeaturesPlugin_Boolean::TOOL_LIST_ID(), ModelAPI_AttributeSelectionList, /** Tool objects*/)
+
+  /// Set operation type.
+  FEATURESAPI_EXPORT
+  void setBoolType(const ModelHighAPI_Integer& theBoolType);
+
+  /// Set main objects.
+  FEATURESAPI_EXPORT
+  void setMainObjects(const std::list<ModelHighAPI_Selection>& theMainObjects);
+
+  /// Set tool objects.
+  FEATURESAPI_EXPORT
+  void setToolObjects(const std::list<ModelHighAPI_Selection>& theToolObjects);
+};
+
+/// Pointer on Boolean object.
+typedef std::shared_ptr<FeaturesAPI_Boolean> BooleanPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create Boolean Cut feature.
+FEATURESAPI_EXPORT
+BooleanPtr addCut(const std::shared_ptr<ModelAPI_Document> & thePart,
+                  const std::list<ModelHighAPI_Selection>& theMainObjects,
+                  const std::list<ModelHighAPI_Selection>& theToolObjects);
+
+/// \ingroup CPPHighAPI
+/// \brief Create Boolean Fuse feature.
+FEATURESAPI_EXPORT
+BooleanPtr addFuse(const std::shared_ptr<ModelAPI_Document> & thePart,
+                   const std::list<ModelHighAPI_Selection>& theObjects);
+
+/// \ingroup CPPHighAPI
+/// \brief Create Boolean Fuse feature.
+FEATURESAPI_EXPORT
+BooleanPtr addFuse(const std::shared_ptr<ModelAPI_Document> & thePart,
+                   const std::list<ModelHighAPI_Selection>& theMainObjects,
+                   const std::list<ModelHighAPI_Selection>& theToolObjects);
+
+/// \ingroup CPPHighAPI
+/// \brief Create Boolean Common feature.
+FEATURESAPI_EXPORT
+BooleanPtr addCommon(const std::shared_ptr<ModelAPI_Document> & thePart,
+                     const std::list<ModelHighAPI_Selection>& theMainObjects,
+                     const std::list<ModelHighAPI_Selection>& theToolObjects);
+
+#endif // FeaturesAPI_Boolean_H_
index 7d053e9cb218d3cdcbc49521082bcb045fcd371f..691fd509b7b283150d0ab72a479bd8687a93b91b 100644 (file)
@@ -14,7 +14,6 @@
 #include <ModelHighAPI_Interface.h>
 #include <ModelHighAPI_Macro.h>
 
-class ModelHighAPI_Double;
 class ModelHighAPI_Selection;
 
 /// \class FeaturesAPI_Placement
index e73a541b6e37fc41dff663e30968f2232b1f58ab..61571735a2b3f01b3adc29f004bf7cafe2da416d 100644 (file)
@@ -10,6 +10,7 @@
   #include <ModelHighAPI_swig.h>
 
   #include "FeaturesAPI.h"
+  #include "FeaturesAPI_Boolean.h"
   #include "FeaturesAPI_Placement.h"
   #include "FeaturesAPI_Rotation.h"
   #include "FeaturesAPI_Translation.h"
index d7e6130105186c7b13ed2ba100a1cf2a473ef491..a5e98ba651eb99aa1cdecc664b404313bb58f694 100644 (file)
@@ -32,7 +32,7 @@ class FeaturesTestCase(FeaturesFixture):
             # "addImport", "exportToFile",
 
             "addAxis",
-            "addAddition", "addSubtraction", "addIntersection",
+            "addCut", "addFuse", "addCommon",
             "addExtrusion",
             # "addExtrusionCut", "addExtrusionFuse",
             "addRevolution",
@@ -62,7 +62,7 @@ class FeaturesTestCase(FeaturesFixture):
         ExchangeAPI.ExchangeAPI_Export(self.part.addFeature("Export"))
 
         import FeaturesAPI
-        model.features.boolean.Boolean(self.part.addFeature("Boolean"))
+        FeaturesAPI.FeaturesAPI_Boolean(self.part.addFeature("Boolean"))
         model.features.extrusion.Extrusion(self.part.addFeature("Extrusion"))
         # model.features.extrusion_boolean.ExtrusionBoolean(self.part.addFeature("ExtrusionCut"))
         # model.features.extrusion_boolean.ExtrusionBoolean(self.part.addFeature("ExtrusionFuse"))