Salome HOME
Merge from V6_main 01/04/2013
[tools/medcoupling.git] / doc / MEDMEM / MEDMEM_InvokingDriverByAttachingItToAnObject.cxx
index b8c110ad29a2a85f9d136436b0451164cea55f9e..9293b2309a322ad9b6d232ff92f2e2315a762f2d 100644 (file)
@@ -1,16 +1,41 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
 #include "MEDMEM_Exception.hxx"
 #include "MEDMEM_define.hxx"
 
 #include "MEDMEM_Field.hxx"
 #include "MEDMEM_Mesh.hxx"
-#include "MEDMEM_Med.hxx"
+#include "MEDMEM_MedMeshDriver.hxx"
+
+using namespace MEDMEM ;
+using namespace MED_EN ;
 
 main () {
   
   const char * fileName   = "pointe.med";
   const char * fileName2  = "Field&MeshGeneratedPointe.med";
   const char * fileName3  = "MedGeneratedPointe.med";
-  const char * fieldName  = "fieldcelldouble";
+  const char * fieldName  = "fieldcelldoublescalar";
   const char * meshName   = "maa1";
 
   try {
@@ -20,14 +45,12 @@ main () {
       MED_FIELD_RDONLY_DRIVER<double> myRdOnlyDriver(fileName,myField);
       myRdOnlyDriver.setFieldName(fieldName);
       myRdOnlyDriver.open(); 
-      //This test failed due to inadequate Support implementation   
-      // myRdOnlyDriver.read();
+      myRdOnlyDriver.read();
       // try  { myRdOnlyDriver.write(); } catch  (MEDEXCEPTION& ex) 
       //   { MESSAGE(ex.what()); }
       MED_FIELD_WRONLY_DRIVER<double> myWrOnlyDriver(fileName2,myField);
       myWrOnlyDriver.open(); 
-      //This test failed due to inadequate Support implementation   
-      // myWrOnlyDriver.write(); 
+      myWrOnlyDriver.write(); 
       // try  myWrOnlyDriver.read(); catch  (MEDEXCEPTION& ex) 
       //   { MESSAGE(ex.what()); }
       myRdOnlyDriver.close();
@@ -50,32 +73,14 @@ main () {
       myWrOnlyDriver.write(); 
       // try  myWrOnlyDriver.read(); catch  (MEDEXCEPTION& ex)
       //   { MESSAGE(ex.what()); }
-      // myRdOnlyDriver.close(); 
-      //While we use H5close() in the MESH/FIELD drivers, the next
-      //line will fail, because all files are previously closed !
+      myRdOnlyDriver.close(); 
       myWrOnlyDriver.close();
       delete myMesh;
     }
 
-    {
-      MED * myMed = new MED();
-      MED_MED_RDONLY_DRIVER myRdOnlyDriver(fileName,myMed);
-      myRdOnlyDriver.open(); 
-      myRdOnlyDriver.readFileStruct();
-      myRdOnlyDriver.close(); 
-      myMed->updateSupport(); // DOIT ETRE SUPPRIMEE
-      //      myRdOnlyDriver.read();
-      // try { myRdOnlyDriver.write(); } catch  (MEDEXCEPTION& ex) 
-      //   { MESSAGE(ex.what()); }
-      //MED_MED_WRONLY_DRIVER myWrOnlyDriver(fileName3,myMed);
-      //myWrOnlyDriver.open(); 
-      //myWrOnlyDriver.write(); // Not implemented yet.
-      //myWrOnlyDriver.close();
-      delete myMed;
-    }
 
   } catch (MEDEXCEPTION& ex){
     cout << "MAIN BLOCK EXCEPTION" << endl;
-    MESSAGE(ex.what()) ;
+    MESSAGE_MED(ex.what()) ;
   }
 }