Back to index

salome-med  6.5.0
Functions
duplicateMED.cxx File Reference
#include <string>
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_Mesh.hxx"
#include "MEDMEM_Grid.hxx"
#include "MEDMEM_Field.hxx"
#include "MEDMEM_MedFileBrowser.hxx"

Go to the source code of this file.

Functions

static void usage (char *name)
int main (int argc, char **argv)

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 40 of file duplicateMED.cxx.

                                  {
  if (argc != 3) usage(argv[0]);
  
  string filenameIN = argv[1] ;
  string filenameOUT = argv[2] ;
  
  try {

    MEDFILEBROWSER myMed(filenameIN) ;

    std::vector< std::string > meshNames = myMed.getMeshNames ();
    for ( unsigned i = 0; i < meshNames.size(); ++i )
    {
      GMESH* mesh = myMed.isStructuredMesh( meshNames[i] ) ? (GMESH*) new GRID : (GMESH*) new MESH;
      int drv = mesh->addDriver(MED_DRIVER, filenameIN, meshNames[i] );
      mesh->read(drv);
      drv = mesh->addDriver(MED_DRIVER, filenameOUT, meshNames[i] );
      mesh->write(drv);
      mesh->removeReference();
    }
    
    vector<string> FieldName = myMed.getFieldNames() ;
    for (unsigned i=0; i<FieldName.size(); i++)
    {
      vector<DT_IT_> FieldIteration = myMed.getFieldIteration(FieldName[i]) ;
      for (unsigned j=0; j<FieldIteration.size(); j++)
      {
        FIELD_ * myField = 0;
        switch( myMed.getFieldType( FieldName[i] ))
        {
        case MED_REEL64: myField = new FIELD<double>; break;
        case MED_INT32:  
        case MED_INT64:  myField = new FIELD<int>; break;
        default:
          continue;
        }
        myField->setIterationNumber( FieldIteration[j].dt );
        myField->setOrderNumber    ( FieldIteration[j].it );
        int drv = myField->addDriver( MED_DRIVER, filenameIN, FieldName[i]);
        myField->read( drv ) ;
        drv = myField->addDriver( MED_DRIVER, filenameOUT, FieldName[i]);
        myField->write( drv );
        myField->removeReference();
      }
    }
  } catch (MEDEXCEPTION& ex) {
    MESSAGE_MED(ex.what()) ;
  }

}

Here is the call graph for this function:

static void usage ( char *  name) [static]

Definition at line 33 of file duplicateMED.cxx.

{
  cout << "  " << name << " <input med file> <output med file> " <<endl ;
  cout << "    " << "(the two file name are mandatory)" << endl ;
  exit(-1);
}

Here is the caller graph for this function: