]> SALOME platform Git repositories - modules/shaper.git/blob - src/PythonAPI/model/features/revolution_boolean.py
Salome HOME
d93b9f034f66c05b5fe3240eaa99b711b310186f
[modules/shaper.git] / src / PythonAPI / model / features / revolution_boolean.py
1 """RevolutionCut and RevolutionFuse Interface
2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 """
5
6 from .roots import CompositeBoolean
7
8
9 def addRevolutionCut(part, *args):
10     """Add an RevolutionCut feature to the Part and return RevolutionBoolean.
11
12     Pass all args to RevolutionCut __init__ function.
13     """
14     assert(args)
15     feature = part.addFeature("RevolutionCut")
16     return RevolutionBoolean(feature, *args)
17
18 def addRevolutionFuse(part, *args):
19     """Add an RevolutionFuse feature to the Part and return RevolutionBoolean.
20
21     Pass all args to RevolutionFuse __init__ function.
22     """
23     assert(args)
24     feature = part.addFeature("RevolutionFuse")
25     return RevolutionBoolean(feature, *args)
26
27
28 class RevolutionBoolean(CompositeBoolean):
29
30     def __init__(self, feature, *args):
31         CompositeBoolean.__init__(self, feature, *args[:3])
32         args = args[3:]
33
34         self._axis_object = self._feature.data().selection("axis_object")
35         self._CreationMethod = self._feature.string("CreationMethod")
36         self._to_angle = self._feature.data().real("to_angle")
37         self._from_angle = self._feature.data().real("from_angle")
38         self._to_object = self._feature.data().selection("to_object")
39         self._to_offset = self._feature.data().real("to_offset")
40         self._from_object = self._feature.data().selection("from_object")
41         self._from_offset = self._feature.data().real("from_offset")
42
43         assert(self._axis_object)
44         assert(self._CreationMethod)
45         assert(self._to_angle)
46         assert(self._from_angle)
47         assert(self._to_object)
48         assert(self._to_offset)
49         assert(self._from_object)
50         assert(self._from_offset)
51
52         if not args:
53             return
54
55         assert(len(args) in (3, 5))
56         axis_object = args[0]
57         args = args[1:]
58
59         self.setAxisObject(axis_object)
60
61         if len(args) == 4:
62             self.setPlanesAndOffsets(*args)
63         elif len(args) == 2:
64             self.setAngles(*args)
65
66         self._execute()
67         pass
68
69     def __clear(self):
70         self._CreationMethod.setValue("ByAngles")
71         self._fill_attribute(self._to_angle, 0)
72         self._fill_attribute(self._from_angle, 0)
73         self._fill_attribute(self._to_object, None)
74         self._fill_attribute(self._to_offset, 0)
75         self._fill_attribute(self._from_object, None)
76         self._fill_attribute(self._from_offset, 0)
77         pass
78
79     def setAxisObject(self, axis_object):
80         """Modify axis_object attribute of the feature.
81
82         See __init__.
83         """
84         self._fill_attribute(self._axis_object, axis_object)
85         pass
86
87     def setAngles(self, to_angle, from_angle):
88         """Modify the to_angle, from_angle attributes of the feature.
89
90         See __init__.
91         """
92         self.__clear()
93         self._CreationMethod.setValue("ByAngles")
94         self._fill_attribute(self._to_angle, to_angle)
95         self._fill_attribute(self._from_angle, from_angle)
96         pass
97
98     def setPlanesAndOffsets(self, to_object, to_offset,
99                             from_object, from_offset):
100         """Modify planes and offsets attributes of the feature.
101
102         See __init__.
103         """
104         self.__clear()
105         self._CreationMethod.setValue("ByPlanesAndOffsets")
106         self._fill_attribute(self._to_object, to_object)
107         self._fill_attribute(self._to_offset, to_offset)
108         self._fill_attribute(self._from_object, from_object)
109         self._fill_attribute(self._from_offset, from_offset)
110         pass
111