Salome HOME
0021803: EDF 2351 : Available versions of MED in TUI function ExportMED aren't consis...
authorvsr <vsr@opencascade.com>
Wed, 15 Feb 2017 07:53:39 +0000 (10:53 +0300)
committervsr <vsr@opencascade.com>
Wed, 15 Feb 2017 07:53:39 +0000 (10:53 +0300)
Step 3: Redesign IDL / Python API
* IDL
  - Remove deprecated methods ExportToMED and ExportMED
  - Rename ExportToMEDX to ExportMED
* Python API
  - Keep backward compatibility: add former (deprecated) IDL's methods; dispatch parameters of remaining methods

idl/SMESH_Mesh.idl
src/SMESHGUI/SMESHGUI.cxx
src/SMESH_I/SMESH_2smeshpy.cxx
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_Mesh_i.hxx
src/SMESH_SWIG/smeshBuilder.py
src/Tools/ZCracksPlug/ellipse.py
src/Tools/ZCracksPlug/rectangle.py
src/Tools/ZCracksPlug/sphere.py
src/Tools/padder/spadderpy/gui/plugindialog.py

index 51ba75dd6da7df6a37ee30eab1eb76e427527f54..aa09fc31ae75a8c04d0e8f7e281a34957b1a2e0c 100644 (file)
@@ -619,9 +619,9 @@ module SMESH
     boolean HasDuplicatedGroupNamesMED();
 
     /*!
-     * Export Mesh to a MED Format file
+     * Export a Mesh to MED file.
      * @params
-     * - file : name of the MED file
+     * - fileName : name of the MED file
      * - 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.
@@ -632,16 +632,16 @@ module SMESH
      *         - 3D in the rest cases.
      *         If @a autoDimension is @c false, the space dimension is always 3.
      */
-    void ExportToMEDX( in string      file, 
-                       in boolean     auto_groups, 
-                       in boolean     overwrite,
-                       in boolean     autoDimension) raises (SALOME::SALOME_Exception);
+    void ExportMED( in string      fileName, 
+                   in boolean     auto_groups, 
+                   in boolean     overwrite,
+                   in boolean     autoDimension) raises (SALOME::SALOME_Exception);
 
     /*!
      * Export a [part of] Mesh into a MED file
      * @params
      * - meshPart : a part of mesh to store
-     * - file : name of the MED file
+     * - fileName : name of the MED file
      * - overwrite : boolean parameter for overwriting/not overwriting the file, if it exists
      * - autoDimension : if @c True, a space dimension for export is defined by mesh 
      *                 configuration; for example a planar mesh lying on XOY plane
@@ -656,29 +656,13 @@ module SMESH
      *         - 's' stands for _solids_ field.
      */
     void ExportPartToMED( in SMESH_IDSource     meshPart,
-                          in string             file,
+                          in string             fileName,
                           in boolean            auto_groups,
                           in boolean            overwrite,
                           in boolean            autoDimension,
                           in GEOM::ListOfFields fields,
                           in string             geomAssocFields ) raises (SALOME::SALOME_Exception);
 
-    /*!
-     * Export Mesh to a MED file
-     * Works, just the same as ExportToMEDX, with overwrite parameter equal to true.
-     * The method is kept in order to support old functionality
-     */
-    void ExportToMED( in string file, in boolean auto_groups )
-      raises (SALOME::SALOME_Exception);
-
-    /*!
-     * Export Mesh to MED file.
-     * This method is deprecated; it is kept only to support old functionality.
-     * Works exactly as ExportToMED method.
-     */
-    void ExportMED( in string file, in boolean auto_groups )
-      raises (SALOME::SALOME_Exception);
-
     /*!
      * Export Mesh to SAUV formatted file
      * Write a temporary med file and use med2sauv
index 0b0679335ef210851f5f1992456984d73d7938f8..d7dd07bcb9e4a4f70baf5f61fc895249457243f9 100644 (file)
@@ -855,8 +855,8 @@ namespace
             const QString&            geoAssFields = aFieldList[ aMeshIndex ].second;
             const bool                   hasFields = ( fields.length() || !geoAssFields.isEmpty() );
             if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
-              aMeshItem->ExportToMEDX( aFilename.toUtf8().data(), toCreateGroups,
-                                       toOverwrite && aMeshIndex == 0, toFindOutDim );
+              aMeshItem->ExportMED( aFilename.toUtf8().data(), toCreateGroups,
+                                    toOverwrite && aMeshIndex == 0, toFindOutDim );
             else
               aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
                                           toOverwrite && aMeshIndex == 0, toFindOutDim,
index ba4b90f06192dd5b23d899447d11fa70af979062..7dd8e6a375fbeb26fb60c679ea2bb760ad6f1152 100644 (file)
@@ -1986,8 +1986,9 @@ void _pyMesh::Process( const Handle(_pyCommand)& theCommand )
   // ----------------------------------------------------------------------
   else if ( theCommand->MethodStartsFrom( "Export" ))
   {
-    if ( method == "ExportToMED" ||  // ExportToMED()  --> ExportMED()
-         method == "ExportToMEDX" )  // ExportToMEDX() --> ExportMED()
+    if ( method == "ExportToMED"  || // ExportToMED()  --> ExportMED()
+         method == "ExportToMEDX" || // ExportToMEDX() --> ExportMED()
+         method == "ExportMED" )
     {
       theCommand->SetMethod( "ExportMED" );
       // filter out deprecated version parameter
index 38f9afd2760815384a19d70ba599883c95377f9f..63a1307b6df69c34a8945ff29cb0dec9708ba3bd 100644 (file)
@@ -2992,14 +2992,14 @@ string SMESH_Mesh_i::prepareMeshNameAndGroups(const char*    file,
 
 //================================================================================
 /*!
- * \brief Export to med file
+ * \brief Export to MED file
  */
 //================================================================================
 
-void SMESH_Mesh_i::ExportToMEDX (const char*        file,
-                                 CORBA::Boolean     auto_groups,
-                                 CORBA::Boolean     overwrite,
-                                 CORBA::Boolean     autoDimension)
+void SMESH_Mesh_i::ExportMED(const char*        file,
+                             CORBA::Boolean     auto_groups,
+                             CORBA::Boolean     overwrite,
+                             CORBA::Boolean     autoDimension)
   throw(SALOME::SALOME_Exception)
 {
   SMESH_TRY;
@@ -3009,7 +3009,7 @@ void SMESH_Mesh_i::ExportToMEDX (const char*        file,
   string aMeshName = prepareMeshNameAndGroups(file, overwrite);
   _impl->ExportMED( file, aMeshName.c_str(), auto_groups, 0, autoDimension );
 
-  TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportToMEDX( r'"
+  TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportMED( r'"
                 << file << "', " << auto_groups << ", "
                 << overwrite << ", "
                 << autoDimension << " )";
@@ -3017,32 +3017,6 @@ void SMESH_Mesh_i::ExportToMEDX (const char*        file,
   SMESH_CATCH( SMESH::throwCorbaException );
 }
 
-//================================================================================
-/*!
- * \brief Export a mesh to a med file
- */
-//================================================================================
-
-void SMESH_Mesh_i::ExportToMED (const char*        file,
-                                CORBA::Boolean     auto_groups)
-  throw(SALOME::SALOME_Exception)
-{
-  ExportToMEDX(file, auto_groups, true);
-}
-
-//================================================================================
-/*!
- * \brief Export a mesh to a med file
- */
-//================================================================================
-
-void SMESH_Mesh_i::ExportMED (const char* file,
-                              CORBA::Boolean auto_groups)
-  throw(SALOME::SALOME_Exception)
-{
-  ExportToMEDX(file, auto_groups, true);
-}
-
 //================================================================================
 /*!
  * \brief Export a mesh to a SAUV file
index 47230bd9b1ff0daaa83e183a899791489a78ecc7..74b5d124e69e2858a0f3bf35539e7cf036ab8b07 100644 (file)
@@ -229,14 +229,10 @@ public:
    */
   CORBA::Boolean HasDuplicatedGroupNamesMED();
 
-  void ExportToMEDX( const char*        file,
-                     CORBA::Boolean     auto_groups,
-                     CORBA::Boolean     overwrite,
-                     CORBA::Boolean     autoDimension=true) throw (SALOME::SALOME_Exception);
-  void ExportToMED ( const char*        file,
-                     CORBA::Boolean     auto_groups ) throw (SALOME::SALOME_Exception);
-  void ExportMED   ( const char*        file,
-                     CORBA::Boolean     auto_groups ) throw (SALOME::SALOME_Exception);
+  void ExportMED( const char*        file,
+                  CORBA::Boolean     auto_groups,
+                  CORBA::Boolean     overwrite,
+                  CORBA::Boolean     autoDimension = true) throw (SALOME::SALOME_Exception);
 
   void ExportSAUV( const char* file, CORBA::Boolean auto_groups ) throw (SALOME::SALOME_Exception);
 
@@ -312,7 +308,7 @@ public:
   CORBA::Long NbPolygons()
     throw (SALOME::SALOME_Exception);
 
-  CORBA::Long NbPolygonsOfOrder(SMESH::ElementOrder order=SMESH::ORDER_ANY)
+  CORBA::Long NbPolygonsOfOrder(SMESH::ElementOrder order = SMESH::ORDER_ANY)
     throw (SALOME::SALOME_Exception);
 
   CORBA::Long NbVolumes()
index f9f4fda87f62cfbd258ea97b84299ec4b258969f..f9068ae8c6540a83d6430cede5d586f851a11a7b 100644 (file)
@@ -1816,8 +1816,8 @@ class Mesh:
         # process positional arguments
         args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
         fileName        = args[0]
-        auto_groups     = args[1] if len(args) > 1 else 0
-        overwrite       = args[2] if len(args) > 2 else 1
+        auto_groups     = args[1] if len(args) > 1 else False
+        overwrite       = args[2] if len(args) > 2 else True
         meshPart        = args[3] if len(args) > 3 else None
         autoDimension   = args[4] if len(args) > 4 else True
         fields          = args[5] if len(args) > 5 else []
@@ -1838,7 +1838,7 @@ class Mesh:
             self.mesh.ExportPartToMED( meshPart, fileName, auto_groups, overwrite, autoDimension,
                                        fields, geomAssocFields)
         else:
-            self.mesh.ExportToMEDX(fileName, auto_groups, overwrite, autoDimension)
+            self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
 
     ## Export the mesh in a file in SAUV format
     #  @param f is the file name
@@ -1939,18 +1939,48 @@ class Mesh:
     #         If @a autoDimension is @c False, the space dimension is always 3.
     #  @ingroup l2_impexp
     def ExportToMED(self, *args, **kwargs):
+        print "WARNING: ExportToMED() is deprecated, use ExportMED() instead"
         # process positional arguments
         args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
         fileName      = args[0]
-        opt           = args[1] if len(args) > 1 else 0
-        overwrite     = args[2] if len(args) > 2 else 1
+        auto_groups   = args[1] if len(args) > 1 else False
+        overwrite     = args[2] if len(args) > 2 else True
         autoDimension = args[3] if len(args) > 3 else True
         # process keywords arguments
-        opt           = kwargs.get("opt", opt)
+        auto_groups   = kwargs.get("opt", auto_groups)         # old keyword name
+        auto_groups   = kwargs.get("auto_groups", auto_groups) # new keyword name
         overwrite     = kwargs.get("overwrite", overwrite)
         autoDimension = kwargs.get("autoDimension", autoDimension)
         # invoke engine's function
-        self.mesh.ExportToMEDX(fileName, opt, overwrite, autoDimension)
+        self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
+
+    ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
+    #  Export the mesh in a file in MED format
+    #  allowing to overwrite the file if it exists or add the exported data to its contents
+    #  @param fileName the file name
+    #  @param opt boolean parameter for creating/not creating
+    #         the groups Group_On_All_Nodes, Group_On_All_Faces, ...
+    #  @param overwrite boolean parameter for overwriting/not overwriting the file
+    #  @param 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.<br>
+    #         If @a autoDimension is @c False, the space dimension is always 3.
+    #  @ingroup l2_impexp
+    def ExportToMEDX(self, *args, **kwargs):
+        print "WARNING: ExportToMEDX() is deprecated, use ExportMED() instead"
+        # process positional arguments
+        args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
+        fileName      = args[0]
+        auto_groups   = args[1] if len(args) > 1 else False
+        overwrite     = args[2] if len(args) > 2 else True
+        autoDimension = args[3] if len(args) > 3 else True
+        # process keywords arguments
+        auto_groups   = kwargs.get("auto_groups", auto_groups)
+        overwrite     = kwargs.get("overwrite", overwrite)
+        autoDimension = kwargs.get("autoDimension", autoDimension)
+        # invoke engine's function
+        self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
 
     # Operations with groups:
     # ----------------------
index 7130d093113591aa8a2a9ebbb5f455129c2a413d..d586aad782a1a557fbfc6e1c989574d89c256260 100644 (file)
@@ -192,7 +192,7 @@ def generate(data_demi_grand_axe, data_centre, data_normale,
     Maillage.ExportMED(outFile)
     smesh.SetName(Maillage.GetMesh(), 'MAILLAGE_FISSURE')
   except:
-    print 'ExportToMEDX() failed. Invalid file name?'
+    print 'ExportMED() failed. Invalid file name?'
 
 
   ## Set names of Mesh objects
index 155e2531e16ffb18c01993420db7dbdd0a530c69..2400b6a88ed57a427846dc22606da906c290825c 100644 (file)
@@ -219,7 +219,7 @@ def generate(data_longueur,data_largeur,data_centre,
     Maillage.ExportMED(outFile)
     smesh.SetName(Maillage.GetMesh(), 'MAILLAGE_FISSURE')
   except:
-    print 'ExportToMEDX() failed. Invalid file name?'
+    print 'ExportMED() failed. Invalid file name?'
 
 
   if salome.sg.hasDesktop():
index 7b8bbf954048e685898bc211671d3b8ec2d0cdad..16f11926ecf999597c6feee15552da58e740c22b 100644 (file)
@@ -60,7 +60,7 @@ def generate(data_rayon,data_centre,outFile):
     Maillage.ExportMED(outFile)
     smesh.SetName(Maillage.GetMesh(), 'MAILLAGE_FISSURE')
   except:
-    print 'ExportToMEDX() failed. Invalid file name?'
+    print 'ExportMED() failed. Invalid file name?'
 
 
   ## Set names of Mesh objects
index 46c804aa5360af46d6e044d9b466345e9b7dc415..b2cef3cd8850816a86aa284184c2bfe795458418 100644 (file)
@@ -210,7 +210,7 @@ class PluginDialog(QDialog):
         name. This returns the filename.
         '''
         filename=str("/tmp/padder_inputfile_"+meshName+".med")
-        meshObject.ExportToMEDX( filename, 0, 1, 1 )
+        meshObject.ExportMED(filename, False, True, True)
         return filename
 
     def clear(self):