From f379b041c69771e3f803d20ffe8711183fa91d60 Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 15 Feb 2017 10:53:39 +0300 Subject: [PATCH] 0021803: EDF 2351 : Available versions of MED in TUI function ExportMED aren't consistent with GUI behavior 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 | 32 ++++---------- src/SMESHGUI/SMESHGUI.cxx | 4 +- src/SMESH_I/SMESH_2smeshpy.cxx | 5 ++- src/SMESH_I/SMESH_Mesh_i.cxx | 38 +++------------- src/SMESH_I/SMESH_Mesh_i.hxx | 14 +++--- src/SMESH_SWIG/smeshBuilder.py | 44 ++++++++++++++++--- src/Tools/ZCracksPlug/ellipse.py | 2 +- src/Tools/ZCracksPlug/rectangle.py | 2 +- src/Tools/ZCracksPlug/sphere.py | 2 +- .../padder/spadderpy/gui/plugindialog.py | 2 +- 10 files changed, 65 insertions(+), 80 deletions(-) diff --git a/idl/SMESH_Mesh.idl b/idl/SMESH_Mesh.idl index 51ba75dd6..aa09fc31a 100644 --- a/idl/SMESH_Mesh.idl +++ b/idl/SMESH_Mesh.idl @@ -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 diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 0b0679335..d7dd07bcb 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -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, diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index ba4b90f06..7dd8e6a37 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -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 diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 38f9afd27..63a1307b6 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -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 diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index 47230bd9b..74b5d124e 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -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() diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index f9f4fda87..f9068ae8c 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -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.
+ # 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: # ---------------------- diff --git a/src/Tools/ZCracksPlug/ellipse.py b/src/Tools/ZCracksPlug/ellipse.py index 7130d0931..d586aad78 100644 --- a/src/Tools/ZCracksPlug/ellipse.py +++ b/src/Tools/ZCracksPlug/ellipse.py @@ -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 diff --git a/src/Tools/ZCracksPlug/rectangle.py b/src/Tools/ZCracksPlug/rectangle.py index 155e2531e..2400b6a88 100644 --- a/src/Tools/ZCracksPlug/rectangle.py +++ b/src/Tools/ZCracksPlug/rectangle.py @@ -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(): diff --git a/src/Tools/ZCracksPlug/sphere.py b/src/Tools/ZCracksPlug/sphere.py index 7b8bbf954..16f11926e 100644 --- a/src/Tools/ZCracksPlug/sphere.py +++ b/src/Tools/ZCracksPlug/sphere.py @@ -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 diff --git a/src/Tools/padder/spadderpy/gui/plugindialog.py b/src/Tools/padder/spadderpy/gui/plugindialog.py index 46c804aa5..b2cef3cd8 100644 --- a/src/Tools/padder/spadderpy/gui/plugindialog.py +++ b/src/Tools/padder/spadderpy/gui/plugindialog.py @@ -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): -- 2.39.2