Back to index

salome-smesh  6.5.0
Public Member Functions | Public Attributes
SMESH_PY.smeshstudytools.SMeshStudyTools Class Reference

List of all members.

Public Member Functions

def __init__
def updateStudy
def getMeshFromGroup
def getMeshObjectSelected
def getMeshObjectFromEntry
def getMeshObjectFromSObject
def displayMeshObjectFromEntry

Public Attributes

 editor
 smeshGui

Detailed Description

This class provides several methods to manipulate mesh objects in Salome
study. The parameter `studyEditor` defines a
:class:`~salome.kernel.studyedit.StudyEditor` object used to access the study. If
:const:`None`, the method returns a :class:`~salome.kernel.studyedit.StudyEditor`
object on the current study.

.. attribute:: editor

   This instance attribute contains the underlying
   :class:`~salome.kernel.studyedit.StudyEditor` object. It can be used to access
   the study but the attribute itself should not be modified.

Definition at line 35 of file smeshstudytools.py.


Constructor & Destructor Documentation

def SMESH_PY.smeshstudytools.SMeshStudyTools.__init__ (   self,
  studyEditor = None 
)

Definition at line 51 of file smeshstudytools.py.

00051 
00052     def __init__(self, studyEditor = None):
00053         global SMESH
00054         if SMESH is None:
00055             SMESH = __import__("SMESH")
00056         if studyEditor is None:
00057             studyEditor = getStudyEditor()
00058         self.editor = studyEditor
00059         self.smeshGui = None


Member Function Documentation

Display the SMESH object associated to the specified entry
(the entry is the identifier of an item in the objects browser).    

Definition at line 118 of file smeshstudytools.py.

00118 
00119     def displayMeshObjectFromEntry(self,entry):
00120         '''
00121         Display the SMESH object associated to the specified entry
00122         (the entry is the identifier of an item in the objects browser).    
00123         '''
00124         if self.smeshGui is None:
00125             self.smeshGui = salome.ImportComponentGUI("SMESH")
00126 
00127         if not helper.SalomeGUI.hasDesktop():
00128             print "displayMeshObject: no desktop available"
00129             return
00130         self.smeshGui.CreateAndDisplayActor(entry)
00131 
00132 #
00133 # ==================================================================
00134 # Use cases and demo functions
00135 # ==================================================================
00136 #
00137 
00138 # CAUTION: Before running this test functions, you first have to
00139 # create (or import) an smesh object and select this object in the
00140 # objects browser. You can run the box mesh creation procedure below
00141 # instead.
00142 
00143 # How to test?
00144 # 1. Run a SALOME application including GEOM and SMESH, and create a new study
00145 # 2. In the console, enter:
00146 #    >>> from salome.smesh import smeshstudytools
00147 #    >>> smeshstudytools.TEST_createBoxMesh()
00148 # 3. Select the object named "boxmesh" in the browser
00149 # 4. In the console, enter:
00150 #    >>> smeshstudytools.TEST_selectAndExport_01()
00151 #    >>> smeshstudytools.TEST_selectAndExport_02()
00152 #    >>> smeshstudytools.TEST_display()
00153 

def SMESH_PY.smeshstudytools.SMeshStudyTools.getMeshFromGroup (   self,
  meshGroupItem 
)
Get the mesh item owning the mesh group `meshGroupItem`.

:type   meshGroupItem: SObject
:param  meshGroupItem: Mesh group belonging to the searched mesh.

:return: The SObject corresponding to the mesh, or None if it was not
 found.

Definition at line 67 of file smeshstudytools.py.

00067 
00068     def getMeshFromGroup(self, meshGroupItem):
00069         """
00070         Get the mesh item owning the mesh group `meshGroupItem`.
00071 
00072         :type   meshGroupItem: SObject
00073         :param  meshGroupItem: Mesh group belonging to the searched mesh.
00074         
00075         :return: The SObject corresponding to the mesh, or None if it was not
00076                  found.
00077         """
00078         meshItem = None
00079         obj = self.editor.getOrLoadObject(meshGroupItem)
00080         group = obj._narrow(SMESH.SMESH_GroupBase)
00081         if group is not None: # The type of the object is ok
00082             meshObj = group.GetMesh()
00083             meshItem = salome.ObjectToSObject(meshObj)
00084         return meshItem
00085 

Returns the MESH object associated to the specified entry,
(the entry is the identifier of an item in the objects browser).

Definition at line 94 of file smeshstudytools.py.

00094 
00095     def getMeshObjectFromEntry(self, entry):
00096         '''
00097         Returns the MESH object associated to the specified entry,
00098         (the entry is the identifier of an item in the objects browser).
00099         '''
00100         if entry is None:
00101             return None
00102         import smesh
00103         smesh.SetCurrentStudy(self.editor.study)
00104         meshObject=smesh.IDToObject(entry)
00105         return meshObject

Here is the caller graph for this function:

Returns the SMESH object associated to the specified SObject,
(the SObject is an item in the objects browser).

Definition at line 106 of file smeshstudytools.py.

00106 
00107     def getMeshObjectFromSObject(self, sobject):
00108         '''
00109         Returns the SMESH object associated to the specified SObject,
00110         (the SObject is an item in the objects browser).
00111         '''
00112         if sobject is None:
00113             return None
00114         
00115         obj = self.editor.getOrLoadObject(sobject)
00116         meshObject = obj._narrow(SMESH.SMESH_Mesh)
00117         return meshObject

Returns the MESH object currently selected in the active study.

Definition at line 86 of file smeshstudytools.py.

00086 
00087     def getMeshObjectSelected(self):
00088         '''
00089         Returns the MESH object currently selected in the active study.
00090         '''
00091         sobject, entry = helper.getSObjectSelected()
00092         meshObject = self.getMeshObjectFromEntry(entry)
00093         return meshObject

Here is the call graph for this function:

def SMESH_PY.smeshstudytools.SMeshStudyTools.updateStudy (   self,
  studyId = None 
)
This function updates the tools so that it works on the
specified study.

Definition at line 60 of file smeshstudytools.py.

00060 
00061     def updateStudy(self, studyId=None):
00062         """
00063         This function updates the tools so that it works on the
00064         specified study.
00065         """
00066         self.editor = getStudyEditor(studyId)
        

Member Data Documentation

Definition at line 57 of file smeshstudytools.py.

Definition at line 58 of file smeshstudytools.py.


The documentation for this class was generated from the following file: