Salome HOME
Merge remote-tracking branch 'origin/master'
authorPaul RASCLE <paul.rascle@edf.fr>
Thu, 19 Jul 2018 07:14:10 +0000 (09:14 +0200)
committerPaul RASCLE <paul.rascle@edf.fr>
Thu, 19 Jul 2018 07:14:10 +0000 (09:14 +0200)
1  2 
src/SMESHGUI/SMESH_msg_en.ts
src/SMESH_I/SMESH_Gen_i.cxx
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_Mesh_i.hxx

index af398866079d0f9516b20c2147b2920856c3a481,f8c8ba3d2a74824c27896d8baaf8eea76e46806e..7a5649fe08900d74b5b7a93a4a8a5b6d623bb7a5
          <source>TEXT_FILES_FILTER</source>
          <translation>TXT files</translation>
      </message>
 +    <message>
 +        <source>MED_VX_FILES_FILTER</source>
 +        <translation>MED %1 files</translation>
 +    </message>
      <message>
          <source>STL_FILES_FILTER</source>
          <translation>STL files</translation>
@@@ -4325,7 -4321,7 +4325,7 @@@ Use Display Entity menu command to sho
      </message>
      <message>
          <source>MEN_FILE_INFO</source>
-         <translation>MED File Information</translation>
+         <translation>File Information</translation>
      </message>
      <message>
          <source>SMESH_WRN_NO_APPROPRIATE_SELECTION</source>
index 8258f4ceaafb05e4733b18bd27fac91e0ed5dd7c,f3d2d43249feb392a522e13f3c8aaa5096bbb78a..5724095a89cc6d565c0e9a3823c29d723704b488
@@@ -2959,7 -2959,7 +2959,7 @@@ char* SMESH_Gen_i::GetMEDVersion(const 
  /*!
   *  SMESH_Gen_i::CheckCompatibility
   *
 - *  Check compatibility of file with MED format being used.
 + *  Check compatibility of file with MED format being used, read only.
   */
  //================================================================================
  CORBA::Boolean SMESH_Gen_i::CheckCompatibility(const char* theFileName)
    return MED::CheckCompatibility( theFileName );
  }
  
 +//================================================================================
 +/*!
 + *  SMESH_Gen_i::CheckWriteCompatibility
 + *
 + *  Check compatibility of file with MED format being used, for append on write.
 + */
 +//================================================================================
 +CORBA::Boolean SMESH_Gen_i::CheckWriteCompatibility(const char* theFileName)
 +{
 +  return MED::CheckCompatibility( theFileName, true );
 +}
 +
  //================================================================================
  /*!
   *  SMESH_Gen_i::GetMeshNames
  //================================================================================
  SMESH::string_array* SMESH_Gen_i::GetMeshNames(const char* theFileName)
  {
 +  //MESSAGE("GetMeshNames " << theFileName);
    SMESH::string_array_var aResult = new SMESH::string_array();
    MED::PWrapper aMed = MED::CrWrapperR( theFileName );
    MED::TErr anErr;
    MED::TInt aNbMeshes = aMed->GetNbMeshes( &anErr );
 +  //MESSAGE("---" << aNbMeshes);
    if( anErr >= 0 ) {
      aResult->length( aNbMeshes );
      for( MED::TInt i = 0; i < aNbMeshes; i++ ) {
@@@ -3089,7 -3075,6 +3089,6 @@@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( S
              myMesh->Load(); // load from study file if not yet done
              TPythonDump pd; // not to dump GetGroups()
              SMESH::ListOfGroups_var groups = myMesh->GetGroups();
-             pd << ""; // to avoid optimizing pd out
              for ( CORBA::ULong i = 0; i < groups->length(); ++i )
              {
                SMESH_GroupBase_i* grImpl = SMESH::DownCast<SMESH_GroupBase_i*>( groups[i]);
                }
              }
  
+             // Store file info
+             std::string info = myImpl->FileInfoToString();
+             if ( !info.empty() )
+             {
+               aSize[ 0 ] = info.size();
+               aDataset = new HDFdataset( "file info", aTopGroup, HDF_STRING, aSize, 1 );
+               aDataset->CreateOnDisk();
+               aDataset->WriteOnDisk( (char*) info.data() );
+               aDataset->CloseOnDisk();
+             }
              // write applied hypotheses if exist
              SALOMEDS::SObject_wrap myHypBranch;
              found = gotBranch->FindSubObject( GetRefOnAppliedHypothesisTag(), myHypBranch.inout() );
@@@ -4367,6 -4363,18 +4377,18 @@@ bool SMESH_Gen_i::Load( SALOMEDS::SComp
              myNewMeshImpl->GetImpl().GetMeshDS()->SetPersistentId( *meshPersistentId );
              delete [] meshPersistentId;
            }
+           // Restore file info
+           if ( aTopGroup->ExistInternalObject( "file info" ))
+           {
+             aDataset = new HDFdataset( "file info", aTopGroup );
+             aDataset->OpenOnDisk();
+             size = aDataset->GetSize();
+             std::string info( size, ' ');
+             aDataset->ReadFromDisk( (char*) info.data() );
+             aDataset->CloseOnDisk();
+             myNewMeshImpl->FileInfoFromString( info );
+           }
          }
        }
      } // reading MESHes
index 10bfa8d8ed6ad68ca63e07a7f6d44d7a0c9d69ea,94b83e290b83d275e25de16ba38177bdc80ca867..74815a4ffb6da1be32aa5bdcee92258d80ab0ac6
@@@ -445,22 -445,16 +445,29 @@@ SMESH::DriverMED_ReadStatus SMESH_Mesh_
  
    CreateGroupServants();
  
+   _medFileInfo           = new SMESH::MedFileInfo();
+   _medFileInfo->fileName = theFileName;
+   _medFileInfo->major    = 0;
+   _medFileInfo->minor    = 0;
+   _medFileInfo->release  = 0;
+   _medFileInfo->fileSize = SMESH_File( theFileName ).size();
    return ConvertDriverMEDReadStatus(status);
  }
  
 +//================================================================================
 +/*!
 + * \brief Return string representation of a MED file version comprising nbDigits
 + */
 +//================================================================================
 +
 +char* SMESH_Mesh_i::GetVersionString(CORBA::Long minor, CORBA::Short nbDigits)
 +{
 +  string ver = DriverMED_W_SMESHDS_Mesh::GetVersionString(minor,
 +                                                          nbDigits);
 +  return CORBA::string_dup( ver.c_str() );
 +}
 +
  //=============================================================================
  /*!
   *  ImportUNVFile
@@@ -479,6 -473,13 +486,13 @@@ int SMESH_Mesh_i::ImportUNVFile( const 
  
    CreateGroupServants();
  
+   _medFileInfo           = new SMESH::MedFileInfo();
+   _medFileInfo->fileName = theFileName;
+   _medFileInfo->major    = 0;
+   _medFileInfo->minor    = 0;
+   _medFileInfo->release  = 0;
+   _medFileInfo->fileSize = SMESH_File( theFileName ).size();
    SMESH_CATCH( SMESH::throwCorbaException );
  
    return 1;
@@@ -503,6 -504,12 +517,12 @@@ int SMESH_Mesh_i::ImportSTLFile( const 
      SALOMEDS::SObject_wrap meshSO = _gen_i->ObjectToSObject( _this() );
      _gen_i->SetName( meshSO, name.c_str() );
    }
+   _medFileInfo           = new SMESH::MedFileInfo();
+   _medFileInfo->fileName = theFileName;
+   _medFileInfo->major    = 0;
+   _medFileInfo->minor    = 0;
+   _medFileInfo->release  = 0;
+   _medFileInfo->fileSize = SMESH_File( theFileName ).size();
  
    SMESH_CATCH( SMESH::throwCorbaException );
  
@@@ -541,6 -548,13 +561,13 @@@ SMESH::ComputeError* SMESH_Mesh_i::Impo
  
    error = _impl->GMFToMesh( theFileName, theMakeRequiredGroups );
  
+   _medFileInfo           = new SMESH::MedFileInfo();
+   _medFileInfo->fileName = theFileName;
+   _medFileInfo->major    = 0;
+   _medFileInfo->minor    = 0;
+   _medFileInfo->release  = 0;
+   _medFileInfo->fileSize = SMESH_File( theFileName ).size();
    SMESH_CATCH( exceptionToComputeError );
  #undef SMESH_CAUGHT
  #define SMESH_CAUGHT
@@@ -3000,26 -3014,22 +3027,26 @@@ string SMESH_Mesh_i::prepareMeshNameAnd
  
  void SMESH_Mesh_i::ExportMED(const char*        file,
                               CORBA::Boolean     auto_groups,
 +                             CORBA::Long        minor,
                               CORBA::Boolean     overwrite,
                               CORBA::Boolean     autoDimension)
    throw(SALOME::SALOME_Exception)
  {
 -  //MESSAGE("SMESH::MED_VERSION:"<< theVersion);
 +  //MESSAGE("MED minor version: "<< minor);
    SMESH_TRY;
    if ( _preMeshInfo )
      _preMeshInfo->FullLoadFromFile();
  
    string aMeshName = prepareMeshNameAndGroups(file, overwrite);
 -  _impl->ExportMED( file, aMeshName.c_str(), auto_groups, 0, autoDimension );
 +  _impl->ExportMED( file, aMeshName.c_str(), auto_groups, minor, 0, autoDimension );
  
    TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportMED( r'"
 -                << file << "', " << auto_groups << ", "
 -                << overwrite << ", "
 -                << autoDimension << " )";
 +                << file << "', "
 +                << "auto_groups=" <<auto_groups << ", "
 +                << "minor=" << minor <<  ", "
 +                << "overwrite=" << overwrite << ", "
 +                << "meshPart=None, "
 +                << "autoDimension=" << autoDimension << " )";
  
    SMESH_CATCH( SMESH::throwCorbaException );
  }
@@@ -3129,14 -3139,12 +3156,14 @@@ void SMESH_Mesh_i::ExportSTL (const cha
  void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
                                     const char*               file,
                                     CORBA::Boolean            auto_groups,
 +                                   CORBA::Long               minor,
                                     CORBA::Boolean            overwrite,
                                     CORBA::Boolean            autoDimension,
                                     const GEOM::ListOfFields& fields,
                                     const char*               geomAssocFields)
    throw (SALOME::SALOME_Exception)
  {
 +  //MESSAGE("MED minor version: "<< minor);
    SMESH_TRY;
    if ( _preMeshInfo )
      _preMeshInfo->FullLoadFromFile();
         SMESH::DownCast< SMESH_Mesh_i* >( meshPart ))
    {
      aMeshName = prepareMeshNameAndGroups(file, overwrite);
 -    _impl->ExportMED( file, aMeshName.c_str(), auto_groups,
 +    _impl->ExportMED( file, aMeshName.c_str(), auto_groups, minor,
                        0, autoDimension, /*addODOnVertices=*/have0dField);
      meshDS = _impl->GetMeshDS();
    }
      }
  
      SMESH_MeshPartDS* partDS = new SMESH_MeshPartDS( meshPart );
 -    _impl->ExportMED( file, aMeshName.c_str(), auto_groups,
 +    _impl->ExportMED( file, aMeshName.c_str(), auto_groups, minor,
                        partDS, autoDimension, /*addODOnVertices=*/have0dField);
      meshDS = tmpDSDeleter._obj = partDS;
    }
      GEOM::GEOM_BaseObject_var gbo = GEOM::GEOM_BaseObject::_narrow( fields[i] );
      goList[i] = gbo;
    }
 -  TPythonDump() << _this() << ".ExportPartToMED( "
 -                << meshPart << ", r'" << file << "', "
 -                << auto_groups << ", " << overwrite << ", "
 -                << autoDimension << ", " << goList
 -                << ", '" << ( geomAssocFields ? geomAssocFields : "" ) << "'" << " )";
 +  TPythonDump() << _this() << ".ExportPartToMED( r'"
 +                << file << "', "
 +                << "auto_groups=" << auto_groups << ", "
 +                << "minor=" << minor <<  ", "
 +                << "overwrite=" << overwrite << ", "
 +                << "meshPart=" << meshPart << ", "
 +                << "autoDimension=" << autoDimension << ", "
 +                << "fields=" << goList << ", geomAssocFields='"
 +                << ( geomAssocFields ? geomAssocFields : "" ) << "'" << " )";
  
    SMESH_CATCH( SMESH::throwCorbaException );
  }
@@@ -5073,6 -5077,48 +5100,48 @@@ SMESH::MedFileInfo* SMESH_Mesh_i::GetME
    return res._retn();
  }
  
+ //=======================================================================
+ //function : FileInfoToString
+ //purpose  : Persistence of file info
+ //=======================================================================
+ std::string SMESH_Mesh_i::FileInfoToString()
+ {
+   std::string s;
+   if ( &_medFileInfo.in() && _medFileInfo->fileName[0] )
+   {
+     s = SMESH_Comment( _medFileInfo->fileSize )
+       << " " << _medFileInfo->major
+       << " " << _medFileInfo->minor
+       << " " << _medFileInfo->release
+       << " " << _medFileInfo->fileName;
+   }
+   return s;
+ }
+ //=======================================================================
+ //function : FileInfoFromString
+ //purpose  : Persistence of file info
+ //=======================================================================
+ void SMESH_Mesh_i::FileInfoFromString(const std::string& info)
+ {
+   std::string size, major, minor, release, fileName;
+   std::istringstream is(info);
+   is >> size >> major >> minor >> release;
+   fileName = info.data() + ( size.size()   + 1 +
+                              major.size()  + 1 +
+                              minor.size()  + 1 +
+                              release.size()+ 1 );
+   _medFileInfo           = new SMESH::MedFileInfo();
+   _medFileInfo->fileName = fileName.c_str();
+   _medFileInfo->fileSize = atoi( size.c_str() );
+   _medFileInfo->major    = atoi( major.c_str() );
+   _medFileInfo->minor    = atoi( minor.c_str() );
+   _medFileInfo->release  = atoi( release.c_str() );
+ }
  //=============================================================================
  /*!
   * \brief Pass names of mesh groups from study to mesh DS
index ece281760cff7e7e4916eaea2b9bee73066108d5,3ce8ae71183df78b897ed8b0b55ff6ea5c798ab9..867949a9d1df28f1f6741a16d6a9e75a96d83ab9
@@@ -225,14 -225,9 +225,14 @@@ public
     *  Consider maximum group name length stored in MED file.
     */
    CORBA::Boolean HasDuplicatedGroupNamesMED();
 +  /*!
 +   * Return string representation of a MED file version comprising nbDigits
 +   */
 +  char* GetVersionString(CORBA::Long minor, CORBA::Short nbDigits);
  
    void ExportMED( const char*        file,
                    CORBA::Boolean     auto_groups,
 +                  CORBA::Long        minor,
                    CORBA::Boolean     overwrite,
                    CORBA::Boolean     autoDimension = true) throw (SALOME::SALOME_Exception);
  
    void ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
                         const char*               file,
                         CORBA::Boolean            auto_groups,
 +                       CORBA::Long               minor,
                         CORBA::Boolean            overwrite,
                         CORBA::Boolean            autoDim,
                         const GEOM::ListOfFields& fields,
     */
    virtual SMESH::MedFileInfo* GetMEDFileInfo();
  
+   /*!
+    * Persistence of file info
+    */
+   std::string FileInfoToString();
+   void FileInfoFromString(const std::string& info);
    /*!
     * Sets list of notebook variables used for Mesh operations separated by ":" symbol
     */