Salome HOME
Merge with Dev_1.5.0
[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 class for Partition feature.
21
22     Partition(feature) -> feature interface without initialization
23     Partition(feature, main_objects, tool_objects, partition_combine) ->
24         feature interface initialized from arguments:
25         - main_objects -- list of solids
26         - tool_objects -- list of solids
27         - partition_combine -- boolean value
28     """
29
30     def __init__(self, feature, *args):
31         """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
32         Interface.__init__(self, feature)
33         assert(self._feature.getKind() == "Partition")
34
35         self._main_objects = self._feature.data().selectionList("main_objects")
36         self._tool_objects = self._feature.data().selectionList("tool_objects")
37         self._partition_combine = self._feature.data().boolean("partition_combine")
38
39         assert(self._main_objects)
40         assert(self._tool_objects)
41         assert(self._partition_combine)
42
43         if not args:
44             return
45
46         assert(len(args) == 3)
47         main_objects, tool_objects, partition_combine = args
48
49         self.setMainObjects(main_objects)
50         self.setToolObjects(tool_objects)
51         self.setPartitionCombine(partition_combine)
52
53         self.execute()
54         pass
55
56     def setMainObjects(self, main_objects):
57         """Modify base attribute of the feature.
58
59         See __init__.
60         """
61         self._fillAttribute(self._main_objects, main_objects)
62         pass
63
64     def setToolObjects(self, tool_objects):
65         """Modify the to_size, from_size attributes of the feature.
66
67         See __init__.
68         """
69         self._fillAttribute(self._tool_objects, tool_objects)
70         pass
71
72     def setPartitionCombine(self, partition_combine):
73         """Modify planes and offsets attributes of the feature.
74
75         See __init__.
76         """
77         self._fillAttribute(self._partition_combine, partition_combine)
78         pass