1 """Boolean operations Interface
2 Author: Daniel Brunier-Coulin
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
7 from GeomAlgoAPI import *
10 from model.roots import Interface
13 def addAddition(part, object, tool):
14 """Inserts an addition to the given Part and executes the operation.
15 This operation adds tool to the given object.
17 feature = part.addFeature("Boolean")
18 return Boolean(feature, object, tool, GeomAlgoAPI_Boolean.BOOL_FUSE)
21 def addSubtraction(part, object, tool):
22 """Inserts a subtraction to the given Part and executes the operation.
23 This operation subtracts tool to the given object.
25 feature = part.addFeature("Boolean")
26 return Boolean(feature, object, tool, GeomAlgoAPI_Boolean.BOOL_CUT)
29 def addIntersection(part, object, tool):
30 """Inserts an intersection to the given Part and executes the operation.
31 This operation intersects tool to the given object.
33 feature = part.addFeature("Boolean")
34 return Boolean(feature, object, tool, GeomAlgoAPI_Boolean.BOOL_COMMON)
37 class Boolean(Interface):
38 """Abstract root class of Boolean Features."""
39 def __init__(self, feature, main_objects, tool_objects, bool_type):
40 Interface.__init__(self, feature)
41 assert(self._feature.getKind() == "Boolean")
43 self._main_objects = self._feature.selectionList("main_objects")
44 self._tool_objects = self._feature.selectionList("tool_objects")
45 self._bool_type = self._feature.integer("bool_type")
47 assert(self._main_objects)
48 assert(self._tool_objects)
49 assert(self._bool_type)
51 self.setMainObjects(main_objects)
52 self.setToolObjects(tool_objects)
53 self.setBoolType(bool_type)
56 def setMainObjects(self, main_objects):
57 self._fill_attribute(self._main_objects, main_objects)
60 def setToolObjects(self, tool_objects):
61 self._fill_attribute(self._tool_objects, tool_objects)
64 def setBoolType(self, bool_type):
65 self._fill_attribute(self._bool_type, bool_type)