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 """Interface class for Boolean features.
40 Boolean(feature) -> feature interface without initialization
41 Boolean(feature, main_objects, tool_objects, bool_type) ->
42 feature interface initialized from arguments
45 def __init__(self, feature, *args):
46 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
47 Interface.__init__(self, feature)
48 assert(self._feature.getKind() == "Boolean")
50 self._main_objects = self._feature.selectionList("main_objects")
51 self._tool_objects = self._feature.selectionList("tool_objects")
52 self._bool_type = self._feature.integer("bool_type")
54 assert(self._main_objects)
55 assert(self._tool_objects)
56 assert(self._bool_type)
61 assert(len(args) == 3)
62 main_objects, tool_objects, bool_type = args
64 self.setMainObjects(main_objects)
65 self.setToolObjects(tool_objects)
66 self.setBoolType(bool_type)
71 def setMainObjects(self, main_objects):
72 """F.setMainObjects(iterable) -- modify main_objects attribute"""
73 self._fill_attribute(self._main_objects, main_objects)
76 def setToolObjects(self, tool_objects):
77 """F.setToolObjects(iterable) -- modify tool_objects attribute"""
78 self._fill_attribute(self._tool_objects, tool_objects)
81 def setBoolType(self, bool_type):
82 """F.setBoolType(integer) -- modify bool_type attribute.
85 - GeomAlgoAPI_Boolean.BOOL_FUSE
86 - GeomAlgoAPI_Boolean.BOOL_CUT
87 - GeomAlgoAPI_Boolean.BOOL_COMMON
89 self._fill_attribute(self._bool_type, bool_type)