From: spo Date: Tue, 27 Oct 2015 12:25:48 +0000 (+0300) Subject: Add partition feature without tests. X-Git-Tag: V_2.1.0~206^2~56 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=512554fdf44edb7fbf6e711b221d9844d975ef36;p=modules%2Fshaper.git Add partition feature without tests. --- diff --git a/src/PythonAPI/model/features/__init__.py b/src/PythonAPI/model/features/__init__.py index cbc6d4fa2..763938ccc 100644 --- a/src/PythonAPI/model/features/__init__.py +++ b/src/PythonAPI/model/features/__init__.py @@ -6,4 +6,5 @@ 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 +from revolution import addRevolution +from partition import addPartition diff --git a/src/PythonAPI/model/features/partition.py b/src/PythonAPI/model/features/partition.py new file mode 100644 index 000000000..d7226537a --- /dev/null +++ b/src/PythonAPI/model/features/partition.py @@ -0,0 +1,83 @@ +"""Partition Interface +Author: Sergey Pokhodenko +Copyright (C) 2014-20xx CEA/DEN, EDF R&D +""" + +from model.roots import Interface + + +def addPartition(part, *args): + """Add an Partition feature to the Part and return Partition. + + Pass all args to Partition __init__ function. + """ + assert(len(args) > 0 and args[0] is not None) + feature = part.addFeature("Partition") + return Partition(feature, *args) + + +class Partition(Interface): + """Interface on an Partition feature.""" + + def __init__(self, feature, main_objects=None, + tool_objects=None, partition_combine=None): + """Initialize an Partition feature with given parameters. + + Expected arguments: + feature -- an Partition feature + + Expected arguments for initializing the feature: + main_objects -- list of solids. + tool_objects -- list of solids. + partition_combine -- boolean value. + """ + Interface.__init__(self, feature) + assert(self._feature.getKind() == "Partition") + + self._main_objects = self._feature.data().selectionList("main_objects") + self._tool_objects = self._feature.data().selectionList("tool_objects") + self._partition_combine = self._feature.data().boolean("partition_combine") + + if main_objects is None: + return + + self._fill_attribute(self._main_objects, main_objects) + self._fill_attribute(self._tool_objects, tool_objects) + self._fill_attribute(self._partition_combine, partition_combine) + + self.__execute() + pass + + def __execute(self): + if self.areInputValid(): + self.execute() + else: + raise Exception("Cannot execute Partition: %s" % + self._feature.error()) + + def setMainObjects(self, main_objects): + """Modify base attribute of the feature. + + See __init__. + """ + self._fill_attribute(self._main_objects, main_objects) + self.__execute() + pass + + def setToolObjects(self, tool_objects): + """Modify the to_size, from_size attributes of the feature. + + See __init__. + """ + self._fill_attribute(self._tool_objects, tool_objects) + self.__execute() + pass + + def setPartitionCombine(self, partition_combine): + """Modify planes and offsets attributes of the feature. + + See __init__. + """ + self._fill_attribute(self._partition_combine, partition_combine) + self.__execute() + pass