Salome HOME
Improve style and structure of many features.
[modules/shaper.git] / src / PythonAPI / model / features / partition.py
1 """Partition Interface
2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 """
5
6 from model.roots import Interface
7
8
9 def addPartition(part, *args):
10     """Add an Partition feature to the Part and return Partition.
11
12     Pass all args to Partition __init__ function.
13     """
14     assert(len(args) > 0 and args[0] is not None)
15     feature = part.addFeature("Partition")
16     return Partition(feature, *args)
17
18
19 class Partition(Interface):
20     """Interface on an Partition feature."""
21
22     def __init__(self, feature, *args):
23         """Initialize an Partition feature with given parameters.
24
25         Expected arguments:
26         feature -- an Partition feature
27
28         Expected arguments for initializing the feature:
29         main_objects -- list of solids.
30         tool_objects -- list of solids.
31         partition_combine -- boolean value.
32         """
33         Interface.__init__(self, feature)
34         assert(self._feature.getKind() == "Partition")
35
36         self._main_objects = self._feature.data().selectionList("main_objects")
37         self._tool_objects = self._feature.data().selectionList("tool_objects")
38         self._partition_combine = self._feature.data().boolean("partition_combine")
39
40         assert(self._main_objects)
41         assert(self._tool_objects)
42         assert(self._partition_combine)
43
44         if not args:
45             return
46
47         assert(len(args) == 3)
48         main_objects, tool_objects, partition_combine = args
49
50         self.setMainObjects(main_objects)
51         self.setToolObjects(tool_objects)
52         self.setPartitionCombine(partition_combine)
53
54         self._execute()
55         pass
56
57     def setMainObjects(self, main_objects):
58         """Modify base attribute of the feature.
59
60         See __init__.
61         """
62         self._fill_attribute(self._main_objects, main_objects)
63         pass
64
65     def setToolObjects(self, tool_objects):
66         """Modify the to_size, from_size attributes of the feature.
67
68         See __init__.
69         """
70         self._fill_attribute(self._tool_objects, tool_objects)
71         pass
72
73     def setPartitionCombine(self, partition_combine):
74         """Modify planes and offsets attributes of the feature.
75
76         See __init__.
77         """
78         self._fill_attribute(self._partition_combine, partition_combine)
79         pass