1 """Boolean operations Interface
2 Author: Daniel Brunier-Coulin
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
6 from model.roots import Interface
8 def addAddition(part, *args):
9 """Inserts an addition to the given Part and executes the operation.
10 This operation adds tool to the given object.
14 feature = part.addFeature("Boolean")
15 return Boolean(feature, object, tool, GeomAlgoAPI_Boolean.BOOL_FUSE)
18 def addSubtraction(part, *args):
19 """Inserts a subtraction to the given Part and executes the operation.
20 This operation subtracts tool to the given object.
24 feature = part.addFeature("Boolean")
25 return Boolean(feature, object, tool, GeomAlgoAPI_Boolean.BOOL_CUT)
28 def addIntersection(part, *args):
29 """Inserts an intersection to the given Part and executes the operation.
30 This operation intersects tool to the given object.
34 feature = part.addFeature("Boolean")
35 return Boolean(feature, object, tool, GeomAlgoAPI_Boolean.BOOL_COMMON)
38 class Boolean(Interface):
39 """Interface class for Boolean features.
41 Boolean(feature) -> feature interface without initialization
42 Boolean(feature, main_objects, tool_objects, bool_type) ->
43 feature interface initialized from arguments
46 def __init__(self, feature, *args):
47 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
48 Interface.__init__(self, feature)
49 assert(self._feature.getKind() == "Boolean")
51 self._main_objects = self._feature.selectionList("main_objects")
52 self._tool_objects = self._feature.selectionList("tool_objects")
53 self._bool_type = self._feature.integer("bool_type")
55 assert(self._main_objects)
56 assert(self._tool_objects)
57 assert(self._bool_type)
62 assert(len(args) == 3)
63 main_objects, tool_objects, bool_type = args
65 self.setMainObjects(main_objects)
66 self.setToolObjects(tool_objects)
67 self.setBoolType(bool_type)
72 def setMainObjects(self, main_objects):
73 """F.setMainObjects(iterable) -- modify main_objects attribute"""
74 self._fillAttribute(self._main_objects, main_objects)
77 def setToolObjects(self, tool_objects):
78 """F.setToolObjects(iterable) -- modify tool_objects attribute"""
79 self._fillAttribute(self._tool_objects, tool_objects)
82 def setBoolType(self, bool_type):
83 """F.setBoolType(integer) -- modify bool_type attribute.
86 - GeomAlgoAPI_Boolean.BOOL_FUSE
87 - GeomAlgoAPI_Boolean.BOOL_CUT
88 - GeomAlgoAPI_Boolean.BOOL_COMMON
90 self._fillAttribute(self._bool_type, bool_type)