Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 """
00022 This module provides a new class :class:`SMeshStudyTools` to facilitate the
00023 use of mesh objects in Salome study.
00024 """
00025
00026 import salome
00027 SMESH = None
00028
00029 from salome.kernel.studyedit import getStudyEditor
00030
00031 class SMeshStudyTools:
00032 """
00033 This class provides several methods to manipulate mesh objects in Salome
00034 study. The parameter `studyEditor` defines a
00035 :class:`~salome.kernel.studyedit.StudyEditor` object used to access the study. If
00036 :const:`None`, the method returns a :class:`~salome.kernel.studyedit.StudyEditor`
00037 object on the current study.
00038
00039 .. attribute:: editor
00040
00041 This instance attribute contains the underlying
00042 :class:`~salome.kernel.studyedit.StudyEditor` object. It can be used to access
00043 the study but the attribute itself should not be modified.
00044
00045 """
00046
00047 def __init__(self, studyEditor = None):
00048 global SMESH
00049 if SMESH is None:
00050 SMESH = __import__("SMESH")
00051 if studyEditor is None:
00052 studyEditor = getStudyEditor()
00053 self.editor = studyEditor
00054
00055 def getMeshFromGroup(self, meshGroupItem):
00056 """
00057 Get the mesh item owning the mesh group `meshGroupItem`.
00058
00059 :type meshGroupItem: SObject
00060 :param meshGroupItem: Mesh group belonging to the searched mesh.
00061
00062 :return: The SObject corresponding to the mesh, or None if it was not
00063 found.
00064 """
00065 meshItem = None
00066 obj = self.editor.getOrLoadObject(meshGroupItem)
00067 group = obj._narrow(SMESH.SMESH_GroupBase)
00068 if group is not None:
00069 meshObj = group.GetMesh()
00070 meshItem = salome.ObjectToSObject(meshObj)
00071 return meshItem