Salome HOME
Add partition feature without tests.
authorspo <sergey.pokhodenko@opencascade.com>
Tue, 27 Oct 2015 12:25:48 +0000 (15:25 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Tue, 27 Oct 2015 12:25:48 +0000 (15:25 +0300)
src/PythonAPI/model/features/__init__.py
src/PythonAPI/model/features/partition.py [new file with mode: 0644]

index cbc6d4fa2262d3c1a2902f9ca5b01c5128975d9c..763938ccc30c978c1072634cf0f246433f7e640d 100644 (file)
@@ -6,4 +6,5 @@ from boolean   import Subtraction     as addSubtraction
 from boolean   import Intersection    as addIntersection
 
 from extrusion import addExtrusion
-from revolution import addRevolution
\ No newline at end of file
+from revolution import addRevolution
+from partition import addPartition
diff --git a/src/PythonAPI/model/features/partition.py b/src/PythonAPI/model/features/partition.py
new file mode 100644 (file)
index 0000000..d722653
--- /dev/null
@@ -0,0 +1,83 @@
+"""Partition Interface
+Author: Sergey Pokhodenko
+Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+"""
+
+from model.roots import Interface
+
+
+def addPartition(part, *args):
+    """Add an Partition feature to the Part and return Partition.
+
+    Pass all args to Partition __init__ function.
+    """
+    assert(len(args) > 0 and args[0] is not None)
+    feature = part.addFeature("Partition")
+    return Partition(feature, *args)
+
+
+class Partition(Interface):
+    """Interface on an Partition feature."""
+
+    def __init__(self, feature, main_objects=None,
+                 tool_objects=None, partition_combine=None):
+        """Initialize an Partition feature with given parameters.
+
+        Expected arguments:
+        feature -- an Partition feature
+
+        Expected arguments for initializing the feature:
+        main_objects -- list of solids.
+        tool_objects -- list of solids.
+        partition_combine -- boolean value.
+        """
+        Interface.__init__(self, feature)
+        assert(self._feature.getKind() == "Partition")
+
+        self._main_objects = self._feature.data().selectionList("main_objects")
+        self._tool_objects = self._feature.data().selectionList("tool_objects")
+        self._partition_combine = self._feature.data().boolean("partition_combine")
+
+        if main_objects is None:
+            return
+
+        self._fill_attribute(self._main_objects, main_objects)
+        self._fill_attribute(self._tool_objects, tool_objects)
+        self._fill_attribute(self._partition_combine, partition_combine)
+
+        self.__execute()
+        pass
+
+    def __execute(self):
+        if self.areInputValid():
+            self.execute()
+        else:
+            raise Exception("Cannot execute Partition: %s" %
+                            self._feature.error())
+
+    def setMainObjects(self, main_objects):
+        """Modify base attribute of the feature.
+
+        See __init__.
+        """
+        self._fill_attribute(self._main_objects, main_objects)
+        self.__execute()
+        pass
+
+    def setToolObjects(self, tool_objects):
+        """Modify the to_size, from_size attributes of the feature.
+
+        See __init__.
+        """
+        self._fill_attribute(self._tool_objects, tool_objects)
+        self.__execute()
+        pass
+
+    def setPartitionCombine(self, partition_combine):
+        """Modify planes and offsets attributes of the feature.
+
+        See __init__.
+        """
+        self._fill_attribute(self._partition_combine, partition_combine)
+        self.__execute()
+        pass