]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add features RevolutionCut/Fuse/Sketch and ExtrusionCut/Fuse/Sketch without tests.
authorspo <sergey.pokhodenko@opencascade.com>
Tue, 27 Oct 2015 13:33:26 +0000 (16:33 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Tue, 27 Oct 2015 14:01:40 +0000 (17:01 +0300)
src/PythonAPI/model/features/__init__.py
src/PythonAPI/model/features/extrusion_boolean.py [new file with mode: 0644]
src/PythonAPI/model/features/extrusion_sketch.py [new file with mode: 0644]
src/PythonAPI/model/features/revolution_boolean.py [new file with mode: 0644]
src/PythonAPI/model/features/revolution_sketch.py [new file with mode: 0644]
src/PythonAPI/model/features/roots.py [new file with mode: 0644]

index 763938ccc30c978c1072634cf0f246433f7e640d..f38dee15eeb0e620cb869efa96f49fbac49b2bcb 100644 (file)
@@ -5,6 +5,12 @@ from boolean   import Addition        as addAddition
 from boolean   import Subtraction     as addSubtraction
 from boolean   import Intersection    as addIntersection
 
+from partition import addPartition
+
 from extrusion import addExtrusion
+from extrusion_boolean import addExtrusionCut, addExtrusionFuse
+from extrusion_sketch import addExtrusionSketch
+
 from revolution import addRevolution
-from partition import addPartition
+from revolution_boolean import addRevolutionCut, addRevolutionFuse
+from revolution_sketch import addRevolutionSketch
diff --git a/src/PythonAPI/model/features/extrusion_boolean.py b/src/PythonAPI/model/features/extrusion_boolean.py
new file mode 100644 (file)
index 0000000..61f40a7
--- /dev/null
@@ -0,0 +1,85 @@
+"""ExtrusionCut and ExtrusionFuse  Interfaces
+Author: Sergey Pokhodenko
+Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+"""
+
+from .roots import CompositeBoolean
+
+
+def addExtrusionCut(part, *args):
+    """Add an ExtrusionCut feature to the Part and return ExtrusionBoolean.
+
+    Pass all args to Extrusion __init__ function.
+    """
+    assert(args)
+    feature = part.addFeature("ExtrusionCut")
+    return ExtrusionBoolean(feature, *args)
+
+def addExtrusionFuse(part, *args):
+    """Add an ExtrusionFuse feature to the Part and return ExtrusionBoolean.
+
+    Pass all args to Extrusion __init__ function.
+    """
+    assert(args)
+    feature = part.addFeature("ExtrusionFuse")
+    return ExtrusionBoolean(feature, *args)
+
+
+class ExtrusionBoolean(CompositeBoolean):
+
+    def __init__(self, feature, *args):
+        CompositeBoolean.__init__(self, feature, *args)
+
+        self._CreationMethod = self._feature.string("CreationMethod")
+        self._to_size = self._feature.data().real("to_size")
+        self._from_size = self._feature.data().real("from_size")
+        self._to_object = self._feature.data().selection("to_object")
+        self._to_offset = self._feature.data().real("to_offset")
+        self._from_object = self._feature.data().selection("from_object")
+        self._from_offset = self._feature.data().real("from_offset")
+
+        if not args:
+            return
+
+        assert(len(args) == 4 or len(args) == 2)
+        if len(args) == 4:
+            self.setPlanesAndOffsets(*args)
+        elif len(args) == 2:
+            self.setSizes(*args)
+        pass
+
+    def __clear(self):
+        self._CreationMethod.setValue("BySizes")
+        self._fill_attribute(self._to_size, 0)
+        self._fill_attribute(self._from_size, 0)
+        self._fill_attribute(self._to_object, None)
+        self._fill_attribute(self._to_offset, 0)
+        self._fill_attribute(self._from_object, None)
+        self._fill_attribute(self._from_offset, 0)
+        pass
+
+    def setSizes(self, to_size, from_size):
+        """Modify the to_size, from_size attributes of the feature.
+
+        See __init__.
+        """
+        self.__clear()
+        self._CreationMethod.setValue("BySizes")
+        self._fill_attribute(self._to_size, to_size)
+        self._fill_attribute(self._from_size, from_size)
+        pass
+
+    def setPlanesAndOffsets(self, to_object, to_offset,
+                            from_object, from_offset):
+        """Modify planes and offsets attributes of the feature.
+
+        See __init__.
+        """
+        self.__clear()
+        self._CreationMethod.setValue("ByPlanesAndOffsets")
+        self._fill_attribute(self._to_object, to_object)
+        self._fill_attribute(self._to_offset, to_offset)
+        self._fill_attribute(self._from_object, from_object)
+        self._fill_attribute(self._from_offset, from_offset)
+        pass
+
diff --git a/src/PythonAPI/model/features/extrusion_sketch.py b/src/PythonAPI/model/features/extrusion_sketch.py
new file mode 100644 (file)
index 0000000..fea6ff9
--- /dev/null
@@ -0,0 +1,76 @@
+"""ExtrusionSketch  Interfaces
+Author: Sergey Pokhodenko
+Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+"""
+
+from .roots import CompositeSketch
+
+
+def addExtrusionSketch(part, *args):
+    """Add an ExtrusionSketch feature to the Part and return ExtrusionSketch.
+
+    Pass all args to ExtrusionSketch __init__ function.
+    """
+    assert(args)
+    feature = part.addFeature("ExtrusionSketch")
+    return ExtrusionSketch(feature, *args)
+
+
+class ExtrusionSketch(CompositeSketch):
+
+    def __init__(self, feature, *args):
+        CompositeSketch.__init__(self, feature, *args)
+
+        self._CreationMethod = self._feature.string("CreationMethod")
+        self._to_size = self._feature.data().real("to_size")
+        self._from_size = self._feature.data().real("from_size")
+        self._to_object = self._feature.data().selection("to_object")
+        self._to_offset = self._feature.data().real("to_offset")
+        self._from_object = self._feature.data().selection("from_object")
+        self._from_offset = self._feature.data().real("from_offset")
+
+        if not args:
+            return
+
+        assert(len(args) == 4 or len(args) == 2)
+        if len(args) == 4:
+            self.setPlanesAndOffsets(*args)
+        elif len(args) == 2:
+            self.setSizes(*args)
+        pass
+
+    def __clear(self):
+        self._CreationMethod.setValue("BySizes")
+        self._fill_attribute(self._to_size, 0)
+        self._fill_attribute(self._from_size, 0)
+        self._fill_attribute(self._to_object, None)
+        self._fill_attribute(self._to_offset, 0)
+        self._fill_attribute(self._from_object, None)
+        self._fill_attribute(self._from_offset, 0)
+        pass
+
+    def setSizes(self, to_size, from_size):
+        """Modify the to_size, from_size attributes of the feature.
+
+        See __init__.
+        """
+        self.__clear()
+        self._CreationMethod.setValue("BySizes")
+        self._fill_attribute(self._to_size, to_size)
+        self._fill_attribute(self._from_size, from_size)
+        pass
+
+    def setPlanesAndOffsets(self, to_object, to_offset,
+                            from_object, from_offset):
+        """Modify planes and offsets attributes of the feature.
+
+        See __init__.
+        """
+        self.__clear()
+        self._CreationMethod.setValue("ByPlanesAndOffsets")
+        self._fill_attribute(self._to_object, to_object)
+        self._fill_attribute(self._to_offset, to_offset)
+        self._fill_attribute(self._from_object, from_object)
+        self._fill_attribute(self._from_offset, from_offset)
+        pass
+
diff --git a/src/PythonAPI/model/features/revolution_boolean.py b/src/PythonAPI/model/features/revolution_boolean.py
new file mode 100644 (file)
index 0000000..4f50c49
--- /dev/null
@@ -0,0 +1,95 @@
+"""RevolutionCut and RevolutionFuse Interface
+Author: Sergey Pokhodenko
+Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+"""
+
+from .roots import CompositeBoolean
+
+
+def addRevolutionCut(part, *args):
+    """Add an RevolutionCut feature to the Part and return RevolutionBoolean.
+
+    Pass all args to RevolutionCut __init__ function.
+    """
+    assert(args)
+    feature = part.addFeature("RevolutionCut")
+    return RevolutionBoolean(feature, *args)
+
+def addRevolutionFuse(part, *args):
+    """Add an RevolutionFuse feature to the Part and return RevolutionBoolean.
+
+    Pass all args to RevolutionFuse __init__ function.
+    """
+    assert(args)
+    feature = part.addFeature("RevolutionFuse")
+    return RevolutionBoolean(feature, *args)
+
+
+class RevolutionBoolean(CompositeBoolean):
+
+    def __init__(self, feature, *args):
+        CompositeBoolean.__init__(self, feature, *args)
+
+        self._axis_object = self._feature.data().selection("axis_object")
+        self._CreationMethod = self._feature.string("CreationMethod")
+        self._to_angle = self._feature.data().real("to_angle")
+        self._from_angle = self._feature.data().real("from_angle")
+        self._to_object = self._feature.data().selection("to_object")
+        self._to_offset = self._feature.data().real("to_offset")
+        self._from_object = self._feature.data().selection("from_object")
+        self._from_offset = self._feature.data().real("from_offset")
+
+        if not args:
+            return
+
+        self.setAxisObject(args[0])
+
+        if len(args) == 4:
+            self.setPlanesAndOffsets(*args[1:])
+        elif len(args) == 2:
+            self.setAngles(*args[1:])
+        pass
+
+    def __clear(self):
+        self._CreationMethod.setValue("ByAngles")
+        self._fill_attribute(self._to_angle, 0)
+        self._fill_attribute(self._from_angle, 0)
+        self._fill_attribute(self._to_object, None)
+        self._fill_attribute(self._to_offset, 0)
+        self._fill_attribute(self._from_object, None)
+        self._fill_attribute(self._from_offset, 0)
+        pass
+
+    def setAxisObject(self, axis_object):
+        """Modify axis_object attribute of the feature.
+
+        See __init__.
+        """
+        self._fill_attribute(self._axis_object, axis_object)
+        pass
+
+    def setAngles(self, to_angle, from_angle):
+        """Modify the to_angle, from_angle attributes of the feature.
+
+        See __init__.
+        """
+        self.__clear()
+        self._CreationMethod.setValue("ByAngles")
+        self._fill_attribute(self._to_angle, to_angle)
+        self._fill_attribute(self._from_angle, from_angle)
+        pass
+
+    def setPlanesAndOffsets(self, to_object, to_offset,
+                            from_object, from_offset):
+        """Modify planes and offsets attributes of the feature.
+
+        See __init__.
+        """
+        self.__clear()
+        self._CreationMethod.setValue("ByPlanesAndOffsets")
+        self._fill_attribute(self._to_object, to_object)
+        self._fill_attribute(self._to_offset, to_offset)
+        self._fill_attribute(self._from_object, from_object)
+        self._fill_attribute(self._from_offset, from_offset)
+        pass
+
diff --git a/src/PythonAPI/model/features/revolution_sketch.py b/src/PythonAPI/model/features/revolution_sketch.py
new file mode 100644 (file)
index 0000000..5f27690
--- /dev/null
@@ -0,0 +1,86 @@
+"""RevolutionSketch Interface
+Author: Sergey Pokhodenko
+Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+"""
+
+from .roots import CompositeSketch
+
+
+def addRevolutionSketch(part, *args):
+    """Add an RevolutionSketch feature to the Part and return RevolutionSketch.
+
+    Pass all args to RevolutionSketch __init__ function.
+    """
+    assert(args)
+    feature = part.addFeature("RevolutionSketch")
+    return RevolutionSketch(feature, *args)
+
+
+class RevolutionSketch(CompositeSketch):
+
+    def __init__(self, feature, *args):
+        CompositeSketch.__init__(self, feature, *args)
+
+        self._axis_object = self._feature.data().selection("axis_object")
+        self._CreationMethod = self._feature.string("CreationMethod")
+        self._to_angle = self._feature.data().real("to_angle")
+        self._from_angle = self._feature.data().real("from_angle")
+        self._to_object = self._feature.data().selection("to_object")
+        self._to_offset = self._feature.data().real("to_offset")
+        self._from_object = self._feature.data().selection("from_object")
+        self._from_offset = self._feature.data().real("from_offset")
+
+        if not args:
+            return
+
+        self.setAxisObject(args[0])
+
+        if len(args) == 4:
+            self.setPlanesAndOffsets(*args[1:])
+        elif len(args) == 2:
+            self.setAngles(*args[1:])
+        pass
+
+    def __clear(self):
+        self._CreationMethod.setValue("ByAngles")
+        self._fill_attribute(self._to_angle, 0)
+        self._fill_attribute(self._from_angle, 0)
+        self._fill_attribute(self._to_object, None)
+        self._fill_attribute(self._to_offset, 0)
+        self._fill_attribute(self._from_object, None)
+        self._fill_attribute(self._from_offset, 0)
+        pass
+
+    def setAxisObject(self, axis_object):
+        """Modify axis_object attribute of the feature.
+
+        See __init__.
+        """
+        self._fill_attribute(self._axis_object, axis_object)
+        pass
+
+    def setAngles(self, to_angle, from_angle):
+        """Modify the to_angle, from_angle attributes of the feature.
+
+        See __init__.
+        """
+        self.__clear()
+        self._CreationMethod.setValue("ByAngles")
+        self._fill_attribute(self._to_angle, to_angle)
+        self._fill_attribute(self._from_angle, from_angle)
+        pass
+
+    def setPlanesAndOffsets(self, to_object, to_offset,
+                            from_object, from_offset):
+        """Modify planes and offsets attributes of the feature.
+
+        See __init__.
+        """
+        self.__clear()
+        self._CreationMethod.setValue("ByPlanesAndOffsets")
+        self._fill_attribute(self._to_object, to_object)
+        self._fill_attribute(self._to_offset, to_offset)
+        self._fill_attribute(self._from_object, from_object)
+        self._fill_attribute(self._from_offset, from_offset)
+        pass
+
diff --git a/src/PythonAPI/model/features/roots.py b/src/PythonAPI/model/features/roots.py
new file mode 100644 (file)
index 0000000..ab7ac3e
--- /dev/null
@@ -0,0 +1,27 @@
+
+
+from model.roots import Interface
+
+
+class CompositeBoolean(Interface):
+
+    def __init__(self, feature, *args):
+        Interface.__init__(self, feature)
+
+        self._sketch = self._feature.reference("sketch")
+        self._sketch_selection = self._feature.selection("sketch_selection")
+        self._boolean_objects = self._feature.selectionList("boolean_objects")
+
+        if not args:
+            return
+
+class CompositeSketch(Interface):
+
+    def __init__(self, feature, *args):
+        Interface.__init__(self, feature)
+
+        self._sketch = self._feature.reference("sketch")
+        self._sketch_selection = self._feature.selection("sketch_selection")
+
+        if not args:
+            return