Salome HOME
fix script SALOME_TESTS/Grids/smesh/bugs_00/A3
[modules/smesh.git] / src / SMESH_SWIG / smeshBuilder.py
index 841dacbdbcb34855381dbc8aa0a4befdbac8e414..f64b1e5334c451e187531975a2d8460111d1de57 100644 (file)
@@ -611,33 +611,35 @@ class smeshBuilder( SMESH._objref_SMESH_Gen, object ):
         return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
 
     def UpdateStudy( self, geompyD = None  ):
         return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
 
     def UpdateStudy( self, geompyD = None  ):
-       """
-        Update the current study. Calling UpdateStudy() allows to 
-       update meshes at switching GEOM->SMESH
-       """
+        """
+        Update the current study. Calling UpdateStudy() allows to
+        update meshes at switching GEOM->SMESH
+        """
         #self.UpdateStudy()
         #self.UpdateStudy()
-       if not geompyD:
+        if not geompyD:
             from salome.geom import geomBuilder
             geompyD = geomBuilder.geom
             from salome.geom import geomBuilder
             geompyD = geomBuilder.geom
+            if not geompyD:
+                geompyD = geomBuilder.New()
             pass
             pass
-       self.geompyD=geompyD
-       self.SetGeomEngine(geompyD)
-       SMESH._objref_SMESH_Gen.UpdateStudy(self)
-       sb = salome.myStudy.NewBuilder()
-       sc = salome.myStudy.FindComponent("SMESH")
-       if sc:
+        self.geompyD=geompyD
+        self.SetGeomEngine(geompyD)
+        SMESH._objref_SMESH_Gen.UpdateStudy(self)
+        sb = salome.myStudy.NewBuilder()
+        sc = salome.myStudy.FindComponent("SMESH")
+        if sc:
             sb.LoadWith(sc, self)
             sb.LoadWith(sc, self)
-       pass
+        pass
     
     def SetEnablePublish( self, theIsEnablePublish ):
     
     def SetEnablePublish( self, theIsEnablePublish ):
-       """
-        Sets enable publishing in the study. Calling SetEnablePublish( false ) allows to
-       switch OFF publishing in the Study of mesh objects.
-       """
-        #self.SetEnablePublish(theIsEnablePublish)
-       SMESH._objref_SMESH_Gen.SetEnablePublish(self,theIsEnablePublish)
-       global notebook
-       notebook = salome_notebook.NoteBook( theIsEnablePublish )
+        """
+        Set enable publishing in the study. Calling SetEnablePublish( False ) allows to
+        switch **off** publishing in the Study of mesh objects.
+        """
+       #self.SetEnablePublish(theIsEnablePublish)
+        SMESH._objref_SMESH_Gen.SetEnablePublish(self,theIsEnablePublish)
+        global notebook
+        notebook = salome_notebook.NoteBook( theIsEnablePublish )
 
 
     def CreateMeshesFromUNV( self,theFileName ):
 
 
     def CreateMeshesFromUNV( self,theFileName ):
@@ -1406,7 +1408,7 @@ def New( instance=None, instanceGeom=None):
     Create a new smeshBuilder instance. The smeshBuilder class provides the Python
     interface to create or load meshes.
 
     Create a new smeshBuilder instance. The smeshBuilder class provides the Python
     interface to create or load meshes.
 
-    Typical use is:
+    Typical use is::
 
         import salome
         salome.salome_init()
 
         import salome
         salome.salome_init()
@@ -1414,14 +1416,18 @@ def New( instance=None, instanceGeom=None):
         smesh = smeshBuilder.New()
 
     Parameters:
         smesh = smeshBuilder.New()
 
     Parameters:
-        isPublished If False, the notebool will not be used.
-        instance  CORBA proxy of SMESH Engine. If None, the default Engine is used.
+        instance:      CORBA proxy of SMESH Engine. If None, the default Engine is used.
+        instanceGeom:  CORBA proxy of GEOM  Engine. If None, the default Engine is used.
     Returns:
         :class:`smeshBuilder` instance
     """
     global engine
     global smeshInst
     global doLcc
     Returns:
         :class:`smeshBuilder` instance
     """
     global engine
     global smeshInst
     global doLcc
+    if instance and isinstance( instance, SALOMEDS._objref_Study ):
+        import sys
+        sys.stderr.write("Warning: 'study' argument is no more needed in smeshBuilder.New(). Consider updating your script!!!\n\n")
+        instance = None
     engine = instance
     if engine is None:
         doLcc = True
     engine = instance
     if engine is None:
         doLcc = True
@@ -1817,9 +1823,6 @@ class Mesh(metaclass = MeshMeta):
             pass
         if salome.sg.hasDesktop():
             if not isinstance( refresh, list): # not a call from subMesh.Compute()
             pass
         if salome.sg.hasDesktop():
             if not isinstance( refresh, list): # not a call from subMesh.Compute()
-                smeshgui = salome.ImportComponentGUI("SMESH")
-                smeshgui.Init()
-                smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
                 if refresh: salome.sg.updateObjBrowser()
 
         return ok
                 if refresh: salome.sg.updateObjBrowser()
 
         return ok
@@ -1875,6 +1878,7 @@ class Mesh(metaclass = MeshMeta):
                         continue
                     if ids == subShapeID:
                         shapeText = '"%s"' % subSO.GetName()
                         continue
                     if ids == subShapeID:
                         shapeText = '"%s"' % subSO.GetName()
+                        break
             if not shapeText:
                 shape = self.geompyD.GetSubShape( self.GetShape(), [subShapeID])
                 if shape:
             if not shapeText:
                 shape = self.geompyD.GetSubShape( self.GetShape(), [subShapeID])
                 if shape:
@@ -1964,9 +1968,6 @@ class Mesh(metaclass = MeshMeta):
 
         self.mesh.Clear()
         if ( salome.sg.hasDesktop() ):
 
         self.mesh.Clear()
         if ( salome.sg.hasDesktop() ):
-            smeshgui = salome.ImportComponentGUI("SMESH")
-            smeshgui.Init()
-            smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
             if refresh: salome.sg.updateObjBrowser()
 
     def ClearSubMesh(self, geomId, refresh=False):
             if refresh: salome.sg.updateObjBrowser()
 
     def ClearSubMesh(self, geomId, refresh=False):
@@ -1980,9 +1981,6 @@ class Mesh(metaclass = MeshMeta):
 
         self.mesh.ClearSubMesh(geomId)
         if salome.sg.hasDesktop():
 
         self.mesh.ClearSubMesh(geomId)
         if salome.sg.hasDesktop():
-            smeshgui = salome.ImportComponentGUI("SMESH")
-            smeshgui.Init()
-            smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
             if refresh: salome.sg.updateObjBrowser()
 
     def AutomaticTetrahedralization(self, fineness=0):
             if refresh: salome.sg.updateObjBrowser()
 
     def AutomaticTetrahedralization(self, fineness=0):
@@ -2157,14 +2155,16 @@ class Mesh(metaclass = MeshMeta):
         Parameters:
                 fileName: is the file name
                 auto_groups (boolean): parameter for creating/not creating
         Parameters:
                 fileName: is the file name
                 auto_groups (boolean): parameter for creating/not creating
-                       the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
-                       the typical use is auto_groups=False.
+                        the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
+                        the typical use is auto_groups=False.
                 overwrite (boolean): parameter for overwriting/not overwriting the file
                 overwrite (boolean): parameter for overwriting/not overwriting the file
-                meshPart: a part of mesh (group, sub-mesh) to export instead of the mesh
-                autoDimension if @c True (default), a space dimension of a MED mesh can be either
-                       - 1D if all mesh nodes lie on OX coordinate axis, or
-                       - 2D if all mesh nodes lie on XOY coordinate plane, or
-                       - 3D in the rest cases.
+                meshPart: a part of mesh (:class:`sub-mesh, group or filter <SMESH.SMESH_IDSource>`) to export instead of the mesh
+                autoDimension: if *True* (default), a space dimension of a MED mesh can be either
+
+                        - 1D if all mesh nodes lie on OX coordinate axis, or
+                        - 2D if all mesh nodes lie on XOY coordinate plane, or
+                        - 3D in the rest cases.
+
                         If *autoDimension* is *False*, the space dimension is always 3.
                 fields: list of GEOM fields defined on the shape to mesh.
                 geomAssocFields: each character of this string means a need to export a 
                         If *autoDimension* is *False*, the space dimension is always 3.
                 fields: list of GEOM fields defined on the shape to mesh.
                 geomAssocFields: each character of this string means a need to export a 
@@ -2366,7 +2366,7 @@ class Mesh(metaclass = MeshMeta):
                         - 3D in the rest cases.
 
                         If **autoDimension** is *False*, the space dimension is always 3.
                         - 3D in the rest cases.
 
                         If **autoDimension** is *False*, the space dimension is always 3.
-               """
+                """
 
         print("WARNING: ExportToMEDX() is deprecated, use ExportMED() instead")
         # process positional arguments
 
         print("WARNING: ExportToMEDX() is deprecated, use ExportMED() instead")
         # process positional arguments
@@ -4167,7 +4167,7 @@ class Mesh(metaclass = MeshMeta):
     def GetPointState(self, x, y, z):
         """
         Return point state in a closed 2D mesh in terms of TopAbs_State enumeration:
     def GetPointState(self, x, y, z):
         """
         Return point state in a closed 2D mesh in terms of TopAbs_State enumeration:
-        0-IN, 1-OUT, 2-ON, 3-UNKNOWN.
+        smesh.TopAbs_IN, smesh.TopAbs_OUT, smesh.TopAbs_ON and smesh.TopAbs_UNKNOWN.
         UNKNOWN state means that either mesh is wrong or the analysis fails.
         """
 
         UNKNOWN state means that either mesh is wrong or the analysis fails.
         """
 
@@ -5608,7 +5608,7 @@ class Mesh(metaclass = MeshMeta):
         Parameters:
             IDsOfElements: list of elements ids
             Mirror: is :class:`SMESH.AxisStruct` or geom object (point, line, plane)
         Parameters:
             IDsOfElements: list of elements ids
             Mirror: is :class:`SMESH.AxisStruct` or geom object (point, line, plane)
-            theMirrorType: smeshBuilder.POINT, smeshBuilder.AXIS or smeshBuilder.PLANE.
+            theMirrorType: smesh.POINT, smesh.AXIS or smesh.PLANE.
                 If the *Mirror* is a geom object this parameter is unnecessary
             Copy: allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
             MakeGroups: forces the generation of new groups from existing ones (if Copy)
                 If the *Mirror* is a geom object this parameter is unnecessary
             Copy: allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
             MakeGroups: forces the generation of new groups from existing ones (if Copy)
@@ -5636,7 +5636,7 @@ class Mesh(metaclass = MeshMeta):
         Parameters:
             IDsOfElements: the list of elements ids
             Mirror: is :class:`SMESH.AxisStruct` or geom object (point, line, plane)
         Parameters:
             IDsOfElements: the list of elements ids
             Mirror: is :class:`SMESH.AxisStruct` or geom object (point, line, plane)
-            theMirrorType: smeshBuilder.POINT, smeshBuilder.AXIS or smeshBuilder.PLANE.
+            theMirrorType: smesh.POINT, smesh.AXIS or smesh.PLANE.
                 If the *Mirror* is a geom object this parameter is unnecessary
             MakeGroups: to generate new groups from existing ones
             NewMeshName: a name of the new mesh to create
                 If the *Mirror* is a geom object this parameter is unnecessary
             MakeGroups: to generate new groups from existing ones
             NewMeshName: a name of the new mesh to create
@@ -5663,7 +5663,7 @@ class Mesh(metaclass = MeshMeta):
         Parameters:
             theObject: :class:`mesh, sub-mesh, group or filter <SMESH.SMESH_IDSource>`
             Mirror: :class:`SMESH.AxisStruct` or geom object (point, line, plane)
         Parameters:
             theObject: :class:`mesh, sub-mesh, group or filter <SMESH.SMESH_IDSource>`
             Mirror: :class:`SMESH.AxisStruct` or geom object (point, line, plane)
-            theMirrorType: smeshBuilder.POINT, smeshBuilder.AXIS or smeshBuilder.PLANE.
+            theMirrorType: smesh.POINT, smesh.AXIS or smesh.PLANE.
                 If the *Mirror* is a geom object this parameter is unnecessary
             Copy: allows copying the element (Copy==True) or replacing it with its mirror (Copy==False)
             MakeGroups: forces the generation of new groups from existing ones (if Copy)
                 If the *Mirror* is a geom object this parameter is unnecessary
             Copy: allows copying the element (Copy==True) or replacing it with its mirror (Copy==False)
             MakeGroups: forces the generation of new groups from existing ones (if Copy)
@@ -5691,7 +5691,7 @@ class Mesh(metaclass = MeshMeta):
         Parameters:
             theObject: :class:`mesh, sub-mesh, group or filter <SMESH.SMESH_IDSource>`
             Mirror: :class:`SMESH.AxisStruct` or geom object (point, line, plane)
         Parameters:
             theObject: :class:`mesh, sub-mesh, group or filter <SMESH.SMESH_IDSource>`
             Mirror: :class:`SMESH.AxisStruct` or geom object (point, line, plane)
-            theMirrorType: smeshBuilder.POINT, smeshBuilder.AXIS or smeshBuilder.PLANE.
+            theMirrorType: smesh.POINT, smesh.AXIS or smesh.PLANE.
                 If the *Mirror* is a geom object this parameter is unnecessary
             MakeGroups: forces the generation of new groups from existing ones
             NewMeshName: the name of the new mesh to create
                 If the *Mirror* is a geom object this parameter is unnecessary
             MakeGroups: forces the generation of new groups from existing ones
             NewMeshName: the name of the new mesh to create
@@ -6034,7 +6034,7 @@ class Mesh(metaclass = MeshMeta):
     def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance,
                                    exceptNodes=[], SeparateCornerAndMediumNodes=False):
         """
     def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance,
                                    exceptNodes=[], SeparateCornerAndMediumNodes=False):
         """
-        Find groups of ajacent nodes within Tolerance.
+        Find groups of adjacent nodes within Tolerance.
 
         Parameters:
             Tolerance: the value of tolerance
 
         Parameters:
             Tolerance: the value of tolerance
@@ -6311,7 +6311,7 @@ class Mesh(metaclass = MeshMeta):
                 a :class:`Mesh`, elements of highest dimension are duplicated
             theGroupName: a name of group to contain the generated elements.
                 If a group with such a name already exists, the new elements
                 a :class:`Mesh`, elements of highest dimension are duplicated
             theGroupName: a name of group to contain the generated elements.
                 If a group with such a name already exists, the new elements
-                are added to the existng group, else a new group is created.
+                are added to the existing group, else a new group is created.
                 If *theGroupName* is empty, new elements are not added
                 in any group.
 
                 If *theGroupName* is empty, new elements are not added
                 in any group.
 
@@ -6894,9 +6894,6 @@ class submeshProxy(SMESH._objref_SMESH_subMesh):
         ok = self.mesh.Compute( self.GetSubShape(),refresh=[] )
 
         if salome.sg.hasDesktop():
         ok = self.mesh.Compute( self.GetSubShape(),refresh=[] )
 
         if salome.sg.hasDesktop():
-            smeshgui = salome.ImportComponentGUI("SMESH")
-            smeshgui.Init()
-            smeshgui.SetMeshIcon( salome.ObjectToID( self ), ok, (self.GetNumberOfElements()==0) )
             if refresh: salome.sg.updateObjBrowser()
             pass
 
             if refresh: salome.sg.updateObjBrowser()
             pass
 
@@ -7053,7 +7050,6 @@ class algoCreator:
             algoType = sorted( self.algoTypeToClass.keys() )[0]
         if algoType in self.algoTypeToClass:
             #print("Create algo",algoType)
             algoType = sorted( self.algoTypeToClass.keys() )[0]
         if algoType in self.algoTypeToClass:
             #print("Create algo",algoType)
-
             return self.algoTypeToClass[ algoType ]( self.mesh, shape )
         raise RuntimeError( "No class found for algo type %s" % algoType)
         return None
             return self.algoTypeToClass[ algoType ]( self.mesh, shape )
         raise RuntimeError( "No class found for algo type %s" % algoType)
         return None