1 """Boolean operations Interface
2 Author: Daniel Brunier-Coulin with contribution by Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
6 from GeomAlgoAPI import GeomAlgoAPI_Boolean
8 from model.roots import Interface
11 def addAddition(part, *args):
12 """Perform addition in the Part.
14 .. function:: addAddition(part, main_objects, tool_objects)
16 This operation adds tools to the given objects.
19 part (ModelAPI_Document): part document
20 main_objects (list of :class:`model.Selection`): main objects
21 tool_objects (list of :class:`model.Selection`): tool_objects objects
24 Boolean: boolean object
27 main_objects, tool_objects = args
28 feature = part.addFeature("Boolean")
30 feature, main_objects, tool_objects, GeomAlgoAPI_Boolean.BOOL_FUSE)
33 def addSubtraction(part, *args):
34 """Perform subtraction in the Part.
36 .. function:: addSubtraction(part, main_objects, tool_objects)
38 This operation subtracts tools from the given objects.
41 part (ModelAPI_Document): part document
42 main_objects (list of :class:`model.Selection`): main objects
43 tool_objects (list of :class:`model.Selection`): tool_objects objects
46 Boolean: boolean object
49 main_objects, tool_objects = args
50 feature = part.addFeature("Boolean")
52 feature, main_objects, tool_objects, GeomAlgoAPI_Boolean.BOOL_CUT)
55 def addIntersection(part, *args):
56 """Perform intersection in the Part.
58 .. function:: addIntersection(part, main_objects, tool_objects)
60 This operation intersects tools with the given objects.
63 part (ModelAPI_Document): part document
64 main_objects (list of :class:`model.Selection`): main objects
65 tool_objects (list of :class:`model.Selection`): tool_objects objects
68 Boolean: boolean object
71 main_objects, tool_objects = args
72 feature = part.addFeature("Boolean")
74 feature, main_objects, tool_objects, GeomAlgoAPI_Boolean.BOOL_COMMON)
77 class Boolean(Interface):
78 """Interface class for Boolean features.
80 .. function:: Boolean(feature)
82 Create interface for the feature without initialization.
84 .. function:: Boolean(feature, main_objects, tool_objects, bool_type)
86 Create interface for the feature and initialize the feature with arguments.
89 def __init__(self, feature, *args):
90 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
91 Interface.__init__(self, feature)
92 assert(self._feature.getKind() == "Boolean")
94 self._main_objects = self._feature.selectionList("main_objects")
95 self._tool_objects = self._feature.selectionList("tool_objects")
96 self._bool_type = self._feature.integer("bool_type")
98 assert(self._main_objects)
99 assert(self._tool_objects)
100 assert(self._bool_type)
105 assert(len(args) == 3)
106 main_objects, tool_objects, bool_type = args
108 self.setMainObjects(main_objects)
109 self.setToolObjects(tool_objects)
110 self.setBoolType(bool_type)
115 def setMainObjects(self, main_objects):
116 """Modify main_objects attribute of the feature.
119 main_objects (list of :class:`model.Selection`): main objects
121 self._fillAttribute(self._main_objects, main_objects)
124 def setToolObjects(self, tool_objects):
125 """Modify tool_objects attribute of the feature.
128 tool_objects (list of :class:`model.Selection`): tool objects
130 self._fillAttribute(self._tool_objects, tool_objects)
133 def setBoolType(self, bool_type):
134 """Modify bool_type attribute of the feature.
137 bool_type (integer): type of operation
141 * GeomAlgoAPI_Boolean.BOOL_FUSE
142 * GeomAlgoAPI_Boolean.BOOL_CUT
143 * GeomAlgoAPI_Boolean.BOOL_COMMON
145 self._fillAttribute(self._bool_type, bool_type)