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, *args):
14 """Inserts an addition to the given Part and executes the operation.
15 This operation adds tool to the given object.
19 feature = part.addFeature("Boolean")
20 return Boolean(feature, object, tool, GeomAlgoAPI_Boolean.BOOL_FUSE)
23 def addSubtraction(part, *args):
24 """Inserts a subtraction to the given Part and executes the operation.
25 This operation subtracts tool to the given object.
29 feature = part.addFeature("Boolean")
30 return Boolean(feature, object, tool, GeomAlgoAPI_Boolean.BOOL_CUT)
33 def addIntersection(part, *args):
34 """Inserts an intersection to the given Part and executes the operation.
35 This operation intersects tool to the given object.
39 feature = part.addFeature("Boolean")
40 return Boolean(feature, object, tool, GeomAlgoAPI_Boolean.BOOL_COMMON)
43 class Boolean(Interface):
44 """Interface class for Boolean features.
46 Boolean(feature) -> feature interface without initialization
47 Boolean(feature, main_objects, tool_objects, bool_type) ->
48 feature interface initialized from arguments
51 def __init__(self, feature, *args):
52 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
53 Interface.__init__(self, feature)
54 assert(self._feature.getKind() == "Boolean")
56 self._main_objects = self._feature.selectionList("main_objects")
57 self._tool_objects = self._feature.selectionList("tool_objects")
58 self._bool_type = self._feature.integer("bool_type")
60 assert(self._main_objects)
61 assert(self._tool_objects)
62 assert(self._bool_type)
67 assert(len(args) == 3)
68 main_objects, tool_objects, bool_type = args
70 self.setMainObjects(main_objects)
71 self.setToolObjects(tool_objects)
72 self.setBoolType(bool_type)
77 def setMainObjects(self, main_objects):
78 """F.setMainObjects(iterable) -- modify main_objects attribute"""
79 self._fillAttribute(self._main_objects, main_objects)
82 def setToolObjects(self, tool_objects):
83 """F.setToolObjects(iterable) -- modify tool_objects attribute"""
84 self._fillAttribute(self._tool_objects, tool_objects)
87 def setBoolType(self, bool_type):
88 """F.setBoolType(integer) -- modify bool_type attribute.
91 - GeomAlgoAPI_Boolean.BOOL_FUSE
92 - GeomAlgoAPI_Boolean.BOOL_CUT
93 - GeomAlgoAPI_Boolean.BOOL_COMMON
95 self._fillAttribute(self._bool_type, bool_type)