From: spo Date: Tue, 27 Oct 2015 07:33:58 +0000 (+0300) Subject: Move boolean to model.features X-Git-Tag: V_2.1.0~206^2~64 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8e1179ce7d661828d9ce7886c978831e1bdca89e;p=modules%2Fshaper.git Move boolean to model.features --- diff --git a/src/PythonAPI/model/__init__.py b/src/PythonAPI/model/__init__.py index 35eeabb27..f4fafd41b 100644 --- a/src/PythonAPI/model/__init__.py +++ b/src/PythonAPI/model/__init__.py @@ -11,9 +11,6 @@ from roots import * from part import Part as addPart from sketcher.sketch import addSketch from features import * -from boolean import Addition as addAddition -from boolean import Subtraction as addSubtraction -from boolean import Intersection as addIntersection # Custom exceptions diff --git a/src/PythonAPI/model/boolean.py b/src/PythonAPI/model/boolean.py deleted file mode 100644 index adc8d6613..000000000 --- a/src/PythonAPI/model/boolean.py +++ /dev/null @@ -1,48 +0,0 @@ -"""Boolean operations Interface -Author: Daniel Brunier-Coulin -Copyright (C) 2014-20xx CEA/DEN, EDF R&D -""" - -from ModelAPI import * -from GeomAlgoAPI import * - - -class Boolean(): - """Abstract root class of Boolean Features.""" - def __init__(self, part, object, tool, type): - self.my = part.addFeature("Boolean") - self.my.data().reference("main_object").setValue(object) - self.my.data().reference("tool_object").setValue(tool) - self.my.data().integer("bool_type").setValue(type) - - if ModelAPI_Session.get().validators().validate(self.my): - self.my.execute() - else: - raise Exception("cannot make the Boolean") - - -class Addition(Boolean): - - def __init__(self, part, object, tool): - """Inserts an addition to the given Part and executes the operation. - This operation adds tool to the given object. - """ - Boolean.__init__(self, part, object, tool, GeomAlgoAPI_Boolean.BOOL_FUSE) - - -class Subtraction(Boolean): - - def __init__(self, part, object, tool): - """Inserts a subtraction to the given Part and executes the operation. - This operation subtracts tool to the given object. - """ - Boolean.__init__(self, part, object, tool, GeomAlgoAPI_Boolean.BOOL_CUT) - - -class Intersection(Boolean): - - def __init__(self, part, object, tool): - """Inserts an intersection to the given Part and executes the operation. - This operation intersects tool to the given object. - """ - Boolean.__init__(self, part, object, tool, GeomAlgoAPI_Boolean.BOOL_COMMON) \ No newline at end of file diff --git a/src/PythonAPI/model/features/__init__.py b/src/PythonAPI/model/features/__init__.py index ffbd5955d..cbc6d4fa2 100644 --- a/src/PythonAPI/model/features/__init__.py +++ b/src/PythonAPI/model/features/__init__.py @@ -1,5 +1,9 @@ """Package for Features plugin for the Parametric Geometry API of the Modeler. """ +from boolean import Addition as addAddition +from boolean import Subtraction as addSubtraction +from boolean import Intersection as addIntersection + from extrusion import addExtrusion from revolution import addRevolution \ No newline at end of file diff --git a/src/PythonAPI/model/features/boolean.py b/src/PythonAPI/model/features/boolean.py new file mode 100644 index 000000000..adc8d6613 --- /dev/null +++ b/src/PythonAPI/model/features/boolean.py @@ -0,0 +1,48 @@ +"""Boolean operations Interface +Author: Daniel Brunier-Coulin +Copyright (C) 2014-20xx CEA/DEN, EDF R&D +""" + +from ModelAPI import * +from GeomAlgoAPI import * + + +class Boolean(): + """Abstract root class of Boolean Features.""" + def __init__(self, part, object, tool, type): + self.my = part.addFeature("Boolean") + self.my.data().reference("main_object").setValue(object) + self.my.data().reference("tool_object").setValue(tool) + self.my.data().integer("bool_type").setValue(type) + + if ModelAPI_Session.get().validators().validate(self.my): + self.my.execute() + else: + raise Exception("cannot make the Boolean") + + +class Addition(Boolean): + + def __init__(self, part, object, tool): + """Inserts an addition to the given Part and executes the operation. + This operation adds tool to the given object. + """ + Boolean.__init__(self, part, object, tool, GeomAlgoAPI_Boolean.BOOL_FUSE) + + +class Subtraction(Boolean): + + def __init__(self, part, object, tool): + """Inserts a subtraction to the given Part and executes the operation. + This operation subtracts tool to the given object. + """ + Boolean.__init__(self, part, object, tool, GeomAlgoAPI_Boolean.BOOL_CUT) + + +class Intersection(Boolean): + + def __init__(self, part, object, tool): + """Inserts an intersection to the given Part and executes the operation. + This operation intersects tool to the given object. + """ + Boolean.__init__(self, part, object, tool, GeomAlgoAPI_Boolean.BOOL_COMMON) \ No newline at end of file