Salome HOME
22513: [CEA 1084] _objref_SMESH_Mesh instance has no attribute 'GetMEDMesh'
[modules/smesh.git] / src / SMESH_SWIG / smeshBuilder.py
index 98b192177bc72f44baa5b317df4e1c8ab36ca251..ce0a35594f1a35befb4d9109ad41333536073ffd 100644 (file)
@@ -384,9 +384,12 @@ class smeshBuilder(object, SMESH._objref_SMESH_Gen):
         #print "init_smesh"
         self.SetCurrentStudy(theStudy,geompyD)
 
-    ## Creates an empty Mesh. This mesh can have an underlying geometry.
-    #  @param obj the Geometrical object on which the mesh is built. If not defined,
-    #             the mesh will have no underlying geometry.
+    ## Creates a mesh. This can be either an empty mesh, possibly having an underlying geometry,
+    #  or a mesh wrapping a CORBA mesh given as a parameter.
+    #  @param obj either (1) a CORBA mesh (SMESH._objref_SMESH_Mesh) got e.g. by calling
+    #         salome.myStudy.FindObjectID("0:1:2:3").GetObject() or
+    #         (2) a Geometrical object for meshing or
+    #         (3) none.
     #  @param name the name for the new mesh.
     #  @return an instance of Mesh class.
     #  @ingroup l2_construct
@@ -1563,23 +1566,26 @@ class Mesh:
             if not geom:
                 geom = self.mesh.GetShapeToMesh()
             pass
-        hyp_name = hyp.GetName()
-        lib_name = hyp.GetLibName()
-        geom_name = ""
-        if geom:
-            geom_name = geom.GetName()
         isApplicable = True
-        isAlgo = hyp._narrow( SMESH_Algo )
         if self.mesh.HasShapeToMesh():
-            isApplicable = self.smeshpyD.IsApplicable(hyp_name, lib_name, geom, not geom.IsSame( self.mesh.GetShapeToMesh() ) )
+            hyp_type     = hyp.GetName()
+            lib_name     = hyp.GetLibName()
+            checkAll    = ( not geom.IsSame( self.mesh.GetShapeToMesh() ))
+            if checkAll and geom:
+                checkAll = geom.GetType() == 37
+            isApplicable = self.smeshpyD.IsApplicable(hyp_type, lib_name, geom, checkAll)
         if isApplicable:
             AssureGeomPublished( self, geom, "shape for %s" % hyp.GetName())
             status = self.mesh.AddHypothesis(geom, hyp)
-            TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
-            return status
         else:
-            TreatHypoStatus( HYP_BAD_GEOMETRY, hyp_name, geom_name, isAlgo )
-            return HYP_BAD_GEOMETRY
+            status = HYP_BAD_GEOMETRY
+        hyp_name = GetName( hyp )
+        geom_name = ""
+        if geom:
+            geom_name = geom.GetName()
+        isAlgo = hyp._narrow( SMESH_Algo )
+        TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
+        return status
 
     ## Return True if an algorithm of hypothesis is assigned to a given shape
     #  @param hyp a hypothesis to check
@@ -1649,17 +1655,24 @@ class Mesh:
     #         - 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 @a autoDimension is @c False, the space dimension is always 3.
+    #  @param fields : list of GEOM fields defined on the shape to mesh.
+    #  @param geomAssocFields : each character of this string means a need to export a 
+    #         corresponding field; correspondence between fields and characters is following:
+    #         - 'v' stands for _vertices_ field;
+    #         - 'e' stands for _edges_ field;
+    #         - 'f' stands for _faces_ field;
+    #         - 's' stands for _solids_ field.
     #  @ingroup l2_impexp
     def ExportMED(self, f, auto_groups=0, version=MED_V2_2,
-                  overwrite=1, meshPart=None, autoDimension=True):
-        if meshPart:
+                  overwrite=1, meshPart=None, autoDimension=True, fields=[], geomAssocFields=''):
+        if meshPart or fields or geomAssocFields:
             unRegister = genObjUnRegister()
             if isinstance( meshPart, list ):
                 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
                 unRegister.set( meshPart )
-            self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite, autoDimension)
+            self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite, autoDimension,
+                                       fields, geomAssocFields)
         else:
             self.mesh.ExportToMEDX(f, auto_groups, version, overwrite, autoDimension)
 
@@ -4493,9 +4506,11 @@ class Mesh:
     # Triangles are transformed in prisms, and quadrangles in hexahedrons.
     # @param theDomains - list of groups of volumes
     # @param createJointElems - if TRUE, create the elements
+    # @param onAllBoundaries - if TRUE, the nodes and elements are also created on
+    #        the boundary between \a theDomains and the rest mesh
     # @return TRUE if operation has been completed successfully, FALSE otherwise
-    def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
-       return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
+    def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems, onAllBoundaries=False ):
+       return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems, onAllBoundaries )
 
     ## Double nodes on some external faces and create flat elements.
     # Flat elements are mainly used by some types of mechanic calculations.