Salome HOME
update from the MedMemory V1.0.1
authornadir <nadir>
Fri, 29 Aug 2003 12:26:15 +0000 (12:26 +0000)
committernadir <nadir>
Fri, 29 Aug 2003 12:26:15 +0000 (12:26 +0000)
127 files changed:
src/MEDMEM/MEDMEM_Array.hxx
src/MEDMEM/MEDMEM_CellModel.cxx
src/MEDMEM/MEDMEM_CellModel.hxx
src/MEDMEM/MEDMEM_Connectivity.cxx
src/MEDMEM/MEDMEM_Connectivity.hxx
src/MEDMEM/MEDMEM_Coordinate.cxx
src/MEDMEM/MEDMEM_Coordinate.hxx
src/MEDMEM/MEDMEM_DriverTools.cxx [new file with mode: 0644]
src/MEDMEM/MEDMEM_DriverTools.hxx [new file with mode: 0644]
src/MEDMEM/MEDMEM_DriversDef.cxx
src/MEDMEM/MEDMEM_DriversDef.hxx
src/MEDMEM/MEDMEM_Exception.cxx
src/MEDMEM/MEDMEM_Exception.hxx
src/MEDMEM/MEDMEM_Family.cxx
src/MEDMEM/MEDMEM_Family.hxx
src/MEDMEM/MEDMEM_Field.cxx
src/MEDMEM/MEDMEM_Field.hxx
src/MEDMEM/MEDMEM_GenDriver.cxx
src/MEDMEM/MEDMEM_GenDriver.hxx
src/MEDMEM/MEDMEM_GibiMeshDriver.cxx
src/MEDMEM/MEDMEM_GibiMeshDriver.hxx
src/MEDMEM/MEDMEM_Grid.cxx
src/MEDMEM/MEDMEM_Grid.hxx
src/MEDMEM/MEDMEM_Group.cxx
src/MEDMEM/MEDMEM_Group.hxx
src/MEDMEM/MEDMEM_InterpolationWrappers.hxx [new file with mode: 0644]
src/MEDMEM/MEDMEM_Med.cxx
src/MEDMEM/MEDMEM_Med.hxx
src/MEDMEM/MEDMEM_MedFieldDriver.hxx
src/MEDMEM/MEDMEM_MedMedDriver.cxx
src/MEDMEM/MEDMEM_MedMedDriver.hxx
src/MEDMEM/MEDMEM_MedMeshDriver.cxx
src/MEDMEM/MEDMEM_MedMeshDriver.hxx
src/MEDMEM/MEDMEM_Mesh.cxx
src/MEDMEM/MEDMEM_Mesh.hxx
src/MEDMEM/MEDMEM_Meshing.cxx
src/MEDMEM/MEDMEM_Meshing.hxx
src/MEDMEM/MEDMEM_ModulusArray.hxx
src/MEDMEM/MEDMEM_PointerOf.hxx
src/MEDMEM/MEDMEM_STRING.hxx
src/MEDMEM/MEDMEM_SkyLineArray.cxx
src/MEDMEM/MEDMEM_SkyLineArray.hxx
src/MEDMEM/MEDMEM_Support.cxx
src/MEDMEM/MEDMEM_Support.hxx
src/MEDMEM/MEDMEM_TypeMeshDriver.cxx
src/MEDMEM/MEDMEM_TypeMeshDriver.hxx
src/MEDMEM/MEDMEM_Unit.cxx
src/MEDMEM/MEDMEM_Unit.hxx
src/MEDMEM/MEDMEM_Utilities.hxx [new file with mode: 0644]
src/MEDMEM/MEDMEM_VtkFieldDriver.hxx [new file with mode: 0644]
src/MEDMEM/MEDMEM_VtkMedDriver.cxx
src/MEDMEM/MEDMEM_VtkMedDriver.hxx
src/MEDMEM/MEDMEM_VtkMeshDriver.cxx [new file with mode: 0644]
src/MEDMEM/MEDMEM_VtkMeshDriver.hxx [new file with mode: 0644]
src/MEDMEM/MEDMEM_define.hxx
src/MEDMEM/Makefile.in
src/MEDMEM/create_mesh.c
src/MEDMEM/create_mesh_c2q4.c [new file with mode: 0644]
src/MEDMEM/create_mesh_c2q4s2.c
src/MEDMEM/create_mesh_c2q4s2_wrong.c
src/MEDMEM/create_mesh_c3h8.c [new file with mode: 0644]
src/MEDMEM/create_mesh_c3h8q4.c
src/MEDMEM/create_mesh_c3h8q4_wrong.c
src/MEDMEM/duplicateMED.cxx
src/MEDMEM/duplicateMEDMESH.cxx
src/MEDMEM/med2vtk.cxx
src/MEDMEM/med_test.cxx
src/MEDMEM/test_MEDMEM_Array.cxx
src/MEDMEM/test_MEDMEM_CellModel.cxx
src/MEDMEM/test_MEDMEM_Meshing.cxx
src/MEDMEM/test_MEDMEM_ModulusArray.cxx
src/MEDMEM/test_MEDMEM_SkyLineArray.cxx
src/MEDMEM/test_affect_medarray.cxx
src/MEDMEM/test_copie_connectivity.cxx
src/MEDMEM/test_copie_coordinate.cxx
src/MEDMEM/test_copie_family.cxx
src/MEDMEM/test_copie_fieldT.cxx
src/MEDMEM/test_copie_field_.cxx
src/MEDMEM/test_copie_group.cxx
src/MEDMEM/test_copie_medarray.cxx
src/MEDMEM/test_copie_mesh.cxx
src/MEDMEM/test_copie_support.cxx
src/MEDMEM/test_gibi_driver.cxx [new file with mode: 0644]
src/MEDMEM/test_operation_fielddouble.cxx [new file with mode: 0644]
src/MEDMEM/test_operation_fieldint.cxx [new file with mode: 0644]
src/MEDMEM/tests/readEntete.cxx
src/MEDMEM/tests/testUCoordinate.cxx
src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.cxx
src/MEDMEM_SWIG/MEDMEM_SWIG_FieldDouble.hxx
src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.cxx
src/MEDMEM_SWIG/MEDMEM_SWIG_FieldInt.hxx
src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.cxx
src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldDoubleDriver.hxx
src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.cxx
src/MEDMEM_SWIG/MEDMEM_SWIG_MedFieldIntDriver.hxx
src/MEDMEM_SWIG/libMEDMEM_Swig.i
src/MEDMEM_SWIG/medMeshing_test.py
src/MEDMEM_SWIG/med_field_anal.py [new file with mode: 0755]
src/MEDMEM_SWIG/med_opfield_test.py [new file with mode: 0755]
src/MEDMEM_SWIG/med_opsupp_test.py [new file with mode: 0755]
src/MEDMEM_SWIG/med_test1.py
src/MEDMEM_SWIG/med_test2.py
src/MEDMEM_SWIG/med_test3.py
src/MEDMEM_SWIG/med_test_grid.py
src/MEDMEM_SWIG/med_test_skin.py
src/MEDMEM_SWIG/my_typemap.i
src/MedCorba_Swig/Makefile.in
src/MedCorba_Swig/libMedCorba_Swig.i
src/MedMem/Family_i.cxx
src/MedMem/Family_i.hxx
src/MedMem/FieldDouble_i.cxx
src/MedMem/FieldDouble_i.hxx
src/MedMem/FieldInt_i.cxx
src/MedMem/FieldInt_i.hxx
src/MedMem/FieldOf_i.hxx
src/MedMem/Field_i.cxx
src/MedMem/Field_i.hxx
src/MedMem/Group_i.cxx
src/MedMem/Group_i.hxx
src/MedMem/Med_i.cxx
src/MedMem/Med_i.hxx
src/MedMem/Mesh_i.cxx
src/MedMem/Mesh_i.hxx
src/MedMem/Support_i.cxx
src/MedMem/Support_i.hxx
src/MedMem/convert.cxx
src/MedMem/convert.hxx

index 6d74be7dbdde4adb2dee99cb63f6b7b335e25d83..e0d049821d04bff1957771e7453b3085a4740f60 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Array.hxx
-//  Module : MED
-
 #ifndef __MEDARRAY_H__
 #define __MEDARRAY_H__
 
@@ -119,6 +93,8 @@ public :
   void setIJ (const med_int i, const med_int j, const T  value);
 
   void calculateOther();
+  bool isOtherCalculated() const {return (const T*)_valuesOther != NULL;}
+  void clearOtherMode();
 };
 
 //-------------------------------------------------//
@@ -273,9 +249,9 @@ template <class T> MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & p,bool copyOther ):
                                        _ldValues(p._ldValues),
                                        _lengthValues(p._lengthValues),
                                        _mode(p._mode),
-                                       _valuesDefault(),
-                                       _valuesNo(),
                                        _valuesFull(),
+                                       _valuesNo(),
+                                       _valuesDefault(),
                                        _valuesOther()
 {
   BEGIN_OF("Constructeur deepCopy MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & m,bool copyOther");
@@ -318,7 +294,7 @@ template <class T> MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & p,bool copyOther ):
 //                                 It DOES NOT copy of the memory.
 //                                 The two objects will share data./n */
 
-template <class T> MEDARRAY<T> & MEDARRAY<T>::MEDARRAY::operator = (const MEDARRAY & m)
+template <class T> MEDARRAY<T> & MEDARRAY<T>::operator = (const MEDARRAY & m)
 {
 
   BEGIN_OF("Operator = MEDARRAY<T>");
@@ -584,9 +560,24 @@ template <class T> void MEDARRAY<T>::set(const medModeSwitch mode, const T* valu
     }
   _valuesOther.set(0);
 
-   END_OF("MEDARRAY<T>::set(mode,i,value)");
+  END_OF("MEDARRAY<T>::set(mode,i,value)");
 }
 
+/*! This function clears the other mode of representation if it exists
+ *  It is usefull for people who needs for optimisation reasons to work directly
+ *  on the inside array without using set-functions 
+ */
+template <class T> void MEDARRAY<T>::clearOtherMode()
+{
+    if(isOtherCalculated())
+    {
+       if ( _mode == MED_FULL_INTERLACE)
+           _valuesNo.set(0);
+       else
+           _valuesFull.set(0);
+       _valuesOther.set(0);
+    }
+}
 
 
 //                             ------------------
index 9ea2b3aecf3966d670e7cc9fafaf34f95b8d5dad..e45ed624bfe548212bdab3bb66c7c397af3a0667 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_CellModel.cxx
-//  Module : MED
-
 using namespace std;
 /*
  File MEDMEM_CellModel.cxx
index d09bd4fada0d7783566d5e35107f2e3a1833ac2d..068d7b4431151f7dd27ead17456932cc9ab8e956 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_CellModel.hxx
-//  Module : MED
-
 /*
  File MEDMEM_CellModel.hxx
  $Header$
index 72ac52e670256ccbfeeacf61de6b7dcb0fe5349b..b785bdf50fe6ff0ffaeeaf2e003fbfb92c964055 100644 (file)
@@ -1,38 +1,14 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Connectivity.cxx
-//  Module : MED
-
 using namespace std;
 #include "MEDMEM_Connectivity.hxx"
 #include "MEDMEM_Family.hxx"
+#include "MEDMEM_Group.hxx"
 #include "MEDMEM_CellModel.hxx"
 
 #include "MEDMEM_SkyLineArray.hxx"
 #include "MEDMEM_ModulusArray.hxx"
 
 #include "MEDMEM_STRING.hxx"
+#include <iomanip>
 
 /*!
    Default Constructor. /n
@@ -162,7 +138,7 @@ CONNECTIVITY::~CONNECTIVITY()
   if (_type != NULL)
      delete [] _type;
   if (_count != NULL)
-     delete[] _count;
+     delete [] _count;
   if (_nodal != NULL)
      delete _nodal;
   if (_descending != NULL)
@@ -242,7 +218,7 @@ void CONNECTIVITY::setCount(const int * Count, const medEntityMesh Entity)
     if (_nodal != NULL) delete _nodal;
     _nodal = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,index[_count[_numberOfTypes]-1]-1);
     _nodal->setIndex(index);
-    delete[] index;
+    delete [] index;
   }
   else
   {
@@ -302,7 +278,8 @@ void CONNECTIVITY::calculateConnectivity(medConnectivity ConnectivityType, medEn
        throw MEDEXCEPTION("CONNECTIVITY::calculateConnectivity : Could not build DESCENDING !");
   if (Entity!=_entity) {
     calculateDescendingConnectivity();
-    _constituent->calculateConnectivity(ConnectivityType,Entity);
+    if (_entityDimension == 2 || _entityDimension == 3)
+      _constituent->calculateConnectivity(ConnectivityType,Entity);
   }
 }
 
@@ -357,7 +334,7 @@ void CONNECTIVITY::updateFamily(vector<FAMILY*> myFamilies)
 
     calculateDescendingConnectivity();
 
-    int newNumberOfFace = _constituent->_nodal->getNumberOf();
+    //    int newNumberOfFace = _constituent->_nodal->getNumberOf();
     const int * newConstituentValue = _constituent->_nodal->getValue();
     const int * newConstituentIndex = _constituent->_nodal->getIndex();
     
@@ -365,7 +342,7 @@ void CONNECTIVITY::updateFamily(vector<FAMILY*> myFamilies)
       _reverseDescendingConnectivity->getIndex();
     
     const int * newDescendingIndex = _descending->getIndex();
-    const int * newDescendingValue = _descending->getValue();
+    //    const int * newDescendingValue = _descending->getValue();
 
     // loop on all family,
     //   for all constituent in family, we get it's old connectivity 
@@ -526,19 +503,19 @@ void CONNECTIVITY::updateFamily(vector<FAMILY*> myFamilies)
                  // else nothing to do
 
                } else {// else we are on border and we do nothing !!!!!!!!
-                 INFOS("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING");
-                 INFOS(LOC<<" Boudary FACE "<<iOldFace+1<<" are wrong oriented !");
-                 INFOS("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING");
+                 MESSAGE("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING");
+                 MESSAGE(LOC<<" Boudary FACE "<<iOldFace+1<<" are wrong oriented !");
+                 MESSAGE("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING");
                }
              }
        
            if(index == 0)
              {
-               INFOS(LOC<<"Renumbering problem with the Face connectivity given by the User and the new Connectivity computed");
+               MESSAGE(LOC<<"Renumbering problem with the Face connectivity given by the User and the new Connectivity computed");
                throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have a Face connectivity problem"));
              }
          }
-       delete[] FacesList;
+       delete [] FacesList;
       }
     
     MESSAGE(LOC<<"The Renumbering is finished and the status is");
@@ -569,6 +546,264 @@ void CONNECTIVITY::updateFamily(vector<FAMILY*> myFamilies)
   return;
 }
 
+// meme methode que updateFamily, mais avec des groupes. Il n'est pas possible d'utiliser
+// l'heritage car les pointeurs sont dans un conteneur.
+void CONNECTIVITY::updateGroup(vector<GROUP*> myFamilies)
+//------------------------------------------------------------//
+{
+  const char * LOC = "CONNECTIVITY::updateFamily(vector<GROUP*>) ";
+  BEGIN_OF(LOC);
+
+  int numberOfFamilies = myFamilies.size();
+  if (numberOfFamilies == 0 ) {
+    MESSAGE(LOC<<"No family");
+    return;
+  }
+  // does we do an update ?
+  if ((_constituent != NULL)&(_descending != NULL)) {
+    MESSAGE(LOC<<"Constituent is already defined");
+    return;
+  }
+
+  if ((_constituent != NULL)&(_descending == NULL)) {
+    if (myFamilies[0]->getEntity() != _constituent->getEntity()) {
+      MESSAGE(LOC<<"Family and constituent entity are different. We do nothing");
+      return;
+    }
+
+    // well we could go !
+    CONNECTIVITY * oldConstituent = _constituent;
+
+//      for(int i=0; i<numberOfFamilies; i++) {
+//        FAMILY * myFamily = myFamilies[i];
+//        MESSAGE(LOC<<"updating the family (BEGIN) : " << *myFamily);
+//      }
+
+    _constituent = (CONNECTIVITY *)NULL;
+    // for instance we must have nodal connectivity in constituent :
+    if (oldConstituent->_nodal == NULL)
+      {
+       MESSAGE(LOC<<"We have no nodal connectivity of sub cell");
+       throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have no nodal connectivity of sub cell"));
+      }
+    int oldNumberOfFace = oldConstituent->_nodal->getNumberOf();
+    const int * oldConstituentValue = oldConstituent->_nodal->getValue();
+    const int * oldConstituentIndex = oldConstituent->_nodal->getIndex();
+
+    calculateDescendingConnectivity();
+
+    //    int newNumberOfFace = _constituent->_nodal->getNumberOf();
+    const int * newConstituentValue = _constituent->_nodal->getValue();
+    const int * newConstituentIndex = _constituent->_nodal->getIndex();
+    
+    const int * newReverseDescendingIndex =
+      _reverseDescendingConnectivity->getIndex();
+    
+    const int * newDescendingIndex = _descending->getIndex();
+    //    const int * newDescendingValue = _descending->getValue();
+
+    // loop on all family,
+    //   for all constituent in family, we get it's old connectivity 
+    //   (with oldCconstituentValue and oldConstituentIndex)
+    //   and search the constituent in newConstituentValue with class 
+    //   ModulusArry
+    //
+    //   when a new face is found, replace old constituent 
+    //   number in family with new one
+    //   If face is not rigth oriented, we must change _descending attribute 
+    //   and _reverseDescendingConnectivity (see calculateDescendingConnectivity()).
+
+    // Voila a toi de jouer Nadir :-)
+
+    // First we get the renumbering from the oldCconstituentValue and
+    // oldConstituentIndex in the the new one, newConstituentValue and
+    // newConstituentIndex with a negative sign if the face is not
+    // right orented
+
+    int * renumberingFromOldToNew = new int [oldNumberOfFace];
+    int index1 = 0;
+    int indexm1 = 0;
+
+    _constituent->calculateReverseNodalConnectivity();
+    
+    for (int iOldFace=0;iOldFace<oldNumberOfFace;iOldFace++)
+      {
+       int index = 0;
+
+       renumberingFromOldToNew[iOldFace] = iOldFace+1;
+       //        renumberingFromOldToNew[iOldFace] = 999999;
+       
+       int face_it_beginOld = oldConstituentIndex[iOldFace];
+       int face_it_endOld = oldConstituentIndex[iOldFace+1];
+       int face_size_itOld = face_it_endOld - face_it_beginOld;
+
+       const int* NodesLists = oldConstituentValue + (face_it_beginOld-1);
+       int face_size_itNew;
+       
+       const int * reverseFaceNodal = _constituent->getReverseNodalConnectivity();
+       const int * reverseFaceNodalIndex = _constituent->getReverseNodalConnectivityIndex();
+
+       // set an array wich contains faces numbers arround first node 
+       int BeginIndexFaceArrayFirstNode=reverseFaceNodalIndex[NodesLists[0]-1];
+       int EndIndexFaceArrayFirstNode=reverseFaceNodalIndex[NodesLists[0]];
+       int NumberOfFacesInList=EndIndexFaceArrayFirstNode-BeginIndexFaceArrayFirstNode;
+
+       int * FacesList = new int[NumberOfFacesInList];
+
+       for (int l=BeginIndexFaceArrayFirstNode; l<EndIndexFaceArrayFirstNode; l++){
+         FacesList[l-BeginIndexFaceArrayFirstNode]=reverseFaceNodal[l-1];
+       }
+       // foreach node in sub cell, we search elements which are in common
+       // at the end, we must have only one !
+
+       for (int nodeFaceOld=1; nodeFaceOld<face_size_itOld; nodeFaceOld++)
+         {
+           int NewNumberOfFacesInList = 0;
+           int * NewFacesList = new int[NumberOfFacesInList];
+
+           for (int l1=0; l1<NumberOfFacesInList; l1++) {
+             for (int l2=reverseFaceNodalIndex[NodesLists[nodeFaceOld]-1]; l2<reverseFaceNodalIndex[NodesLists[nodeFaceOld]]; l2++) {
+               if (FacesList[l1]<reverseFaceNodal[l2-1])
+                 // increasing order : FacesList[l1] are not in elements list of node l
+                 break;
+               if (FacesList[l1]==reverseFaceNodal[l2-1]) {
+                 // we have found one
+                 NewFacesList[NewNumberOfFacesInList]=FacesList[l1];
+                 NewNumberOfFacesInList++;
+                 break;
+               }
+             }
+           }
+           NumberOfFacesInList = NewNumberOfFacesInList;
+           delete [] FacesList;
+           FacesList = NewFacesList;
+         }
+
+       if (!NumberOfFacesInList==0)
+         {
+           if (NumberOfFacesInList>1)
+             throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one face found ("<<NumberOfFacesInList<<") ! " <<FacesList[0]<<" "<<FacesList[1] ));
+       
+           MEDMODULUSARRAY modulusArrayOld(face_size_itOld,NodesLists);
+
+           int face_it_beginNew = newConstituentIndex[FacesList[0]-1];
+           int face_it_endNew = newConstituentIndex[FacesList[0]];
+           face_size_itNew = face_it_endNew - face_it_beginNew;
+
+           const int * newNodesLists = newConstituentValue+newConstituentIndex[FacesList[0]-1]-1;
+           MEDMODULUSARRAY modulusArrayNew(face_size_itNew,newNodesLists);
+       
+           int retCompareNewOld = modulusArrayNew.compare(modulusArrayOld);
+
+           //SCRUTE(retCompareNewOld);
+
+           // Real new face found
+       
+           if(retCompareNewOld == 1)
+             {
+               renumberingFromOldToNew[iOldFace] = FacesList[0];
+               index = 1;
+               index1++;
+             }
+       
+           // Reverse new face found
+       
+           if(retCompareNewOld == -1)
+             {
+               renumberingFromOldToNew[iOldFace] = FacesList[0];
+               index = 1;
+               indexm1++;
+           
+               int face_it_begin = newReverseDescendingIndex[FacesList[0]-1];
+               int face_it_end = newReverseDescendingIndex[FacesList[0]];
+               int face_size_it = face_it_end - face_it_begin;
+
+               if (face_size_it == 1)
+                 throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This is a boundary face/edge, it should not be renumbered and it is wrongly oriented."));
+           
+               if (face_size_it > 2)
+                 throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This face/edge should not be a (d-1) cell because it has "<<face_size_it<<" neighbouring"));
+           
+               // we have always 2 neighbourings
+               int cell1 = _reverseDescendingConnectivity->getIJ(FacesList[0],1);
+               int cell2 = _reverseDescendingConnectivity->getIJ(FacesList[0],2);
+               // PROVISOIRE : en attendant que le SKYLINEARRAY de ReverseDescending soit correct (sans le zero)
+               //                  if (cell2 == 0)
+               //                    throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This is a boundary face/edge, it should not be renumbered and it is wrongly oriented."));
+       
+               if (cell2 != 0) { // we are not on border !!!!
+             
+                 _reverseDescendingConnectivity->setIJ(FacesList[0],1,cell2);
+                 // Updating _constituent->_nodal because of reversity
+                 const int * oldArray = oldConstituentValue+face_it_beginOld-1;
+                 for(int iarray=1;iarray<=face_size_itNew;iarray++){
+                   _constituent->_nodal->setIJ(FacesList[0],iarray,oldArray[iarray-1]);
+                 }
+             
+                 // Updating _reverseDescendingConnectivity
+             
+             
+                 _reverseDescendingConnectivity->setIJ(FacesList[0],2,cell1);
+             
+                 // Updating _descending for cell1 and cell2
+                 for(int iface=newDescendingIndex[cell1-1];iface<=newDescendingIndex[cell1];iface++)
+                   if (_descending->getIndexValue(iface)==FacesList[0])
+                     _descending->setIndexValue(iface,-FacesList[0]);
+                   else if (_descending->getIndexValue(iface)==-FacesList[0])
+                     _descending->setIndexValue(iface,FacesList[0]);
+                 // else nothing to do
+             
+                 for(int iface=newDescendingIndex[cell2-1];iface<newDescendingIndex[cell2];iface++)
+                   if (_descending->getIndexValue(iface)==FacesList[0])
+                     _descending->setIndexValue(iface,-FacesList[0]);
+                   else if (_descending->getIndexValue(iface)==-FacesList[0])
+                     _descending->setIndexValue(iface,FacesList[0]);
+                 // else nothing to do
+
+               } else {// else we are on border and we do nothing !!!!!!!!
+                 MESSAGE("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING");
+                 MESSAGE(LOC<<" Boudary FACE "<<iOldFace+1<<" are wrong oriented !");
+                 MESSAGE("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING");
+               }
+             }
+       
+           if(index == 0)
+             {
+               MESSAGE(LOC<<"Renumbering problem with the Face connectivity given by the User and the new Connectivity computed");
+               throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have a Face connectivity problem"));
+             }
+         }
+       delete [] FacesList;
+      }
+    
+    MESSAGE(LOC<<"The Renumbering is finished and the status is");
+
+    // Updating the Family
+    
+    for(int i=0; i<numberOfFamilies; i++) {
+      GROUP * myFamily = myFamilies[i];
+      
+      MEDSKYLINEARRAY * number = myFamily->getnumber();
+      int numberOfLines_skyline = number->getNumberOf();
+      const int * index_skyline = number->getIndex();
+      
+      for (int i=0;i<numberOfLines_skyline;i++) {
+       for (int j=index_skyline[i]; j<index_skyline[i+1];j++) {
+         number->setIndexValue(j,renumberingFromOldToNew[number->getIndexValue(j)-1]);
+       }
+      }
+      MESSAGE(LOC<<"updating the family (END) : " << *myFamily);
+    }
+
+    delete oldConstituent ;
+    delete [] renumberingFromOldToNew;
+  }
+  
+
+  END_OF(LOC);
+  return;
+}
+
 //------------------------------------------------------------------------------------------------------------------//
 const med_int * CONNECTIVITY::getConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type) 
 //------------------------------------------------------------------------------------------------------------------//
@@ -619,7 +854,7 @@ const med_int * CONNECTIVITY::getConnectivity(medConnectivity ConnectivityType,
       - In fortran mode : Connectivity[ConnectivityIndex[i]+j] */
 //-----------------------------------------------------------------------------------------------//
 const med_int * CONNECTIVITY::getConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity) 
-//------------------------------------------------------------------------------------------------//
+//----0000000--------------------------------------------------------------------------------------------//
 {
   const char * LOC = "CONNECTIVITY::getConnectivityIndex";
   BEGIN_OF(LOC);
@@ -901,8 +1136,8 @@ void CONNECTIVITY::calculateReverseNodalConnectivity()
     _reverseNodalConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity,
                                                    reverse_nodal_connectivity_index,
                                                    reverse_nodal_connectivity);
-    delete[] reverse_nodal_connectivity_index;
-    delete[] reverse_nodal_connectivity;
+    delete [] reverse_nodal_connectivity_index;
+    delete [] reverse_nodal_connectivity;
  }
 }
 
@@ -914,314 +1149,316 @@ void CONNECTIVITY::calculateDescendingConnectivity()
   const char * LOC = "CONNECTIVITY::calculateDescendingConnectivity() : ";
   BEGIN_OF(LOC);
   
-  if (_descending==NULL) {
-    if (_nodal==NULL) {
-      MESSAGE(LOC<<"No connectivity found !");
-      throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity found !"));
-    }
-    // calcul _descending from _nodal
-    // we need CONNECTIVITY for constituent
-
-    if (_constituent != NULL) 
-    //      throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"ERROR : No descending connectivity defined, but constituent exist !"));
-      MESSAGE(LOC<<": No descending connectivity defined, but constituent exist !");
-
-    if (_entityDimension == 3)
-      _constituent = new CONNECTIVITY(MED_FACE);
-    else if (_entityDimension == 2)
-      _constituent = new CONNECTIVITY(MED_EDGE);
-    else {
-      MESSAGE(LOC<<"We are in 1D");
-      return;
-    }
-    _constituent->_typeConnectivity = MED_NODAL;
-    _constituent->_numberOfNodes = _numberOfNodes;
-    // foreach cells, we built array of constituent
-    int DescendingSize = 0;
-    for(int i=0; i<_numberOfTypes; i++) 
-      DescendingSize+=(_count[i+1]-_count[i])*_type[i].getNumberOfConstituents(1);
-    //_descending = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,DescendingSize);
-    //const int * descend_connectivity = _descending->getValue();
-    int * descend_connectivity = new int[DescendingSize];
-    for (int i=0; i<DescendingSize; i++)
-      descend_connectivity[i]=0;
-    //const int * descend_connectivity_index = _descending->getIndex();
-    int * descend_connectivity_index = new int[_count[_numberOfTypes]];
-    descend_connectivity_index[0]=1;
-    medGeometryElement* ConstituentsTypes = new medGeometryElement[2];
-    ConstituentsTypes[0]=MED_NONE;
-    ConstituentsTypes[1]=MED_NONE;
-    int * NumberOfConstituentsForeachType = new int[2];
-    NumberOfConstituentsForeachType[0]=0;
-    NumberOfConstituentsForeachType[1]=0;
-    for(int i=0; i<_numberOfTypes; i++) {
-      // initialize descend_connectivity_index array :
-      int NumberOfConstituents = _type[i].getNumberOfConstituents(1);
-      for (int j=_count[i];j<_count[i+1];j++){
-       descend_connectivity_index[j]=descend_connectivity_index[j-1]+NumberOfConstituents;
-       // compute number of constituent of all cell for each type
-       for(int k=1;k<NumberOfConstituents+1;k++) {
-         medGeometryElement MEDType = _type[i].getConstituentType(1,k);
-         if (ConstituentsTypes[0]==MED_NONE) {
-           ConstituentsTypes[0]=MEDType;
-           NumberOfConstituentsForeachType[0]++;
-         } else if (ConstituentsTypes[0]==MEDType)
-           NumberOfConstituentsForeachType[0]++;
-         else if (ConstituentsTypes[1]==MED_NONE) {
-           ConstituentsTypes[1]=MEDType;
-           NumberOfConstituentsForeachType[1]++;
-         } else if (ConstituentsTypes[1]==MEDType)
-           NumberOfConstituentsForeachType[1]++;
-         else
-           throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<MEDType<<" is different of "<<ConstituentsTypes[0]<<" and "<<ConstituentsTypes[1]));
-       }
+  if (_descending==NULL)
+    {
+      if (_nodal==NULL) {
+       MESSAGE(LOC<<"No connectivity found !");
+       throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity found !"));
+      }
+      // calcul _descending from _nodal
+      // we need CONNECTIVITY for constituent
+      
+      if (_constituent != NULL) 
+       //      throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"ERROR : No descending connectivity defined, but constituent exist !"));
+       MESSAGE(LOC<<": No descending connectivity defined, but constituent exist !");
+
+      if (_entityDimension == 3)
+       _constituent = new CONNECTIVITY(MED_FACE);
+      else if (_entityDimension == 2)
+       _constituent = new CONNECTIVITY(MED_EDGE);
+      else {
+       MESSAGE(LOC<<"We are in 1D");
+       return;
       }
-    }
-
-    // we could built _constituent !
-    int TotalNumberOfConstituents = NumberOfConstituentsForeachType[0]+NumberOfConstituentsForeachType[1];
-    int TotalNumberOfNodes = NumberOfConstituentsForeachType[0]*(ConstituentsTypes[0]%100)+NumberOfConstituentsForeachType[1]*(ConstituentsTypes[1]%100);
-
-    //_constituent->_nodal = new MEDSKYLINEARRAY(TotalNumberOfConstituents,TotalNumberOfNodes);
 
-    // we use _constituent->_nodal 
-    //const int * ConstituentNodalConnectivity = _constituent->_nodal->getValue();
-    //const int * ConstituentNodalConnectivityIndex = _constituent->_nodal->getIndex();
-    int * ConstituentNodalConnectivity = new int[TotalNumberOfNodes];
-    int * ConstituentNodalConnectivityIndex = new int[TotalNumberOfConstituents+1];
-    ConstituentNodalConnectivityIndex[0]=1;
+      _constituent->_typeConnectivity = MED_NODAL;
+      _constituent->_numberOfNodes = _numberOfNodes;
+      // foreach cells, we built array of constituent
+      int DescendingSize = 0;
+      for(int i=0; i<_numberOfTypes; i++) 
+       DescendingSize+=(_count[i+1]-_count[i])*_type[i].getNumberOfConstituents(1);
+      //_descending = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,DescendingSize);
+      //const int * descend_connectivity = _descending->getValue();
+      int * descend_connectivity = new int[DescendingSize];
+      for (int i=0; i<DescendingSize; i++)
+       descend_connectivity[i]=0;
+      //const int * descend_connectivity_index = _descending->getIndex();
+      int * descend_connectivity_index = new int[_count[_numberOfTypes]];
+      descend_connectivity_index[0]=1;
+      medGeometryElement* ConstituentsTypes = new medGeometryElement[2];
+      ConstituentsTypes[0]=MED_NONE;
+      ConstituentsTypes[1]=MED_NONE;
+      int * NumberOfConstituentsForeachType = new int[2];
+      NumberOfConstituentsForeachType[0]=0;
+      NumberOfConstituentsForeachType[1]=0;
+      for(int i=0; i<_numberOfTypes; i++) {
+       // initialize descend_connectivity_index array :
+       int NumberOfConstituents = _type[i].getNumberOfConstituents(1);
+       for (int j=_count[i];j<_count[i+1];j++){
+         descend_connectivity_index[j]=descend_connectivity_index[j-1]+NumberOfConstituents;
+         // compute number of constituent of all cell for each type
+         for(int k=1;k<NumberOfConstituents+1;k++) {
+           medGeometryElement MEDType = _type[i].getConstituentType(1,k);
+           if (ConstituentsTypes[0]==MED_NONE) {
+             ConstituentsTypes[0]=MEDType;
+             NumberOfConstituentsForeachType[0]++;
+           } else if (ConstituentsTypes[0]==MEDType)
+             NumberOfConstituentsForeachType[0]++;
+           else if (ConstituentsTypes[1]==MED_NONE) {
+             ConstituentsTypes[1]=MEDType;
+             NumberOfConstituentsForeachType[1]++;
+           } else if (ConstituentsTypes[1]==MEDType)
+             NumberOfConstituentsForeachType[1]++;
+           else
+             throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<MEDType<<" is different of "<<ConstituentsTypes[0]<<" and "<<ConstituentsTypes[1]));
+         }
+       }
+      }
 
-    _constituent->_entityDimension=ConstituentsTypes[0]/100;
-    if (ConstituentsTypes[1]==MED_NONE)
-      _constituent->_numberOfTypes = 1;
-    else
-      _constituent->_numberOfTypes = 2;
-    _constituent->_geometricTypes = new medGeometryElement[_constituent->_numberOfTypes];
-    _constituent->_type = new CELLMODEL[_constituent->_numberOfTypes];
-    _constituent->_count = new med_int[_constituent->_numberOfTypes+1];
-    _constituent->_count[0]=1;
-    int* tmp_NumberOfConstituentsForeachType = new med_int[_constituent->_numberOfTypes+1];
-    tmp_NumberOfConstituentsForeachType[0]=0; // to count constituent of each type
-    for (int i=0; i<_constituent->_numberOfTypes;i++) {
-      _constituent->_geometricTypes[i]=ConstituentsTypes[i];
-      _constituent->_count[i+1]=_constituent->_count[i]+NumberOfConstituentsForeachType[i];
-      CELLMODEL Type(ConstituentsTypes[i]);
-      _constituent->_type[i]=Type;
-      tmp_NumberOfConstituentsForeachType[i+1]=NumberOfConstituentsForeachType[i];
-      for (int j=tmp_NumberOfConstituentsForeachType[i]; j<tmp_NumberOfConstituentsForeachType[i+1]+tmp_NumberOfConstituentsForeachType[i]; j++)
-       ConstituentNodalConnectivityIndex[j+1]=ConstituentNodalConnectivityIndex[j]+(ConstituentsTypes[i]%100);
-    }
-    delete[] ConstituentsTypes;
-    delete[] NumberOfConstituentsForeachType;
+      // we could built _constituent !
+      int TotalNumberOfConstituents = NumberOfConstituentsForeachType[0]+NumberOfConstituentsForeachType[1];
+      int TotalNumberOfNodes = NumberOfConstituentsForeachType[0]*(ConstituentsTypes[0]%100)+NumberOfConstituentsForeachType[1]*(ConstituentsTypes[1]%100);
+      
+      //_constituent->_nodal = new MEDSKYLINEARRAY(TotalNumberOfConstituents,TotalNumberOfNodes);
+
+      // we use _constituent->_nodal 
+      //const int * ConstituentNodalConnectivity = _constituent->_nodal->getValue();
+      //const int * ConstituentNodalConnectivityIndex = _constituent->_nodal->getIndex();
+      int * ConstituentNodalConnectivity = new int[TotalNumberOfNodes];
+      int * ConstituentNodalConnectivityIndex = new int[TotalNumberOfConstituents+1];
+      ConstituentNodalConnectivityIndex[0]=1;
+
+      _constituent->_entityDimension=ConstituentsTypes[0]/100;
+      if (ConstituentsTypes[1]==MED_NONE)
+       _constituent->_numberOfTypes = 1;
+      else
+       _constituent->_numberOfTypes = 2;
+      _constituent->_geometricTypes = new medGeometryElement[_constituent->_numberOfTypes];
+      _constituent->_type = new CELLMODEL[_constituent->_numberOfTypes];
+      _constituent->_count = new med_int[_constituent->_numberOfTypes+1];
+      _constituent->_count[0]=1;
+      int* tmp_NumberOfConstituentsForeachType = new med_int[_constituent->_numberOfTypes+1];
+      tmp_NumberOfConstituentsForeachType[0]=0; // to count constituent of each type
+      for (int i=0; i<_constituent->_numberOfTypes;i++) {
+       _constituent->_geometricTypes[i]=ConstituentsTypes[i];
+       _constituent->_count[i+1]=_constituent->_count[i]+NumberOfConstituentsForeachType[i];
+       CELLMODEL Type(ConstituentsTypes[i]);
+       _constituent->_type[i]=Type;
+       tmp_NumberOfConstituentsForeachType[i+1]=NumberOfConstituentsForeachType[i];
+       for (int j=tmp_NumberOfConstituentsForeachType[i]; j<tmp_NumberOfConstituentsForeachType[i+1]+tmp_NumberOfConstituentsForeachType[i]; j++)
+         ConstituentNodalConnectivityIndex[j+1]=ConstituentNodalConnectivityIndex[j]+(ConstituentsTypes[i]%100);
+      }
+      delete [] ConstituentsTypes;
+      delete [] NumberOfConstituentsForeachType;
     
-    // we need reverse nodal connectivity
-    if (! _reverseNodalConnectivity)
-      calculateReverseNodalConnectivity();
-    const int * ReverseNodalConnectivityIndex = _reverseNodalConnectivity->getIndex();
-    const int * ReverseNodalConnectivityValue = _reverseNodalConnectivity->getValue();
-
-    // array to keep reverse descending connectivity
-    int * ReverseDescendingConnectivityValue = new int[TotalNumberOfConstituents*2];
+      // we need reverse nodal connectivity
+      if (! _reverseNodalConnectivity)
+       calculateReverseNodalConnectivity();
+      const int * ReverseNodalConnectivityIndex = _reverseNodalConnectivity->getIndex();
+      const int * ReverseNodalConnectivityValue = _reverseNodalConnectivity->getValue();
+
+      // array to keep reverse descending connectivity
+      int * ReverseDescendingConnectivityValue = new int[TotalNumberOfConstituents*2];
       
-    int TotalNumberOfSubCell = 0;
-    for (int i=0; i<_numberOfTypes; i++) { // loop on all cell type
-      CELLMODEL Type = _type[i];
-      int NumberOfNodesPerCell = Type.getNumberOfNodes();
-      int NumberOfConstituentPerCell = Type.getNumberOfConstituents(1);
-      for (int j=_count[i]; j<_count[i+1]; j++) // we loop on all cell of this type
-       for (int k=1; k<=NumberOfConstituentPerCell; k++) { // we loop on all sub cell of it
-         if (descend_connectivity[descend_connectivity_index[j-1]+k-2]==0) {
-           // it is a new sub cell !
-           //      TotalNumberOfSubCell++;
-           // Which type ?
-           if (Type.getConstituentType(1,k)==_constituent->_geometricTypes[0]){
-             tmp_NumberOfConstituentsForeachType[0]++;
-             TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[0];
-           } else {
-             tmp_NumberOfConstituentsForeachType[1]++;
-             TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[1];
-           }
-           //we have maximum two types
-
-           descend_connectivity[descend_connectivity_index[j-1]+k-2]=TotalNumberOfSubCell;
-           ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2]=j;
-           int NumberOfNodesPerConstituent = Type.getConstituentType(1,k)%100;
+      int TotalNumberOfSubCell = 0;
+      for (int i=0; i<_numberOfTypes; i++) { // loop on all cell type
+       CELLMODEL Type = _type[i];
+       //      int NumberOfNodesPerCell = Type.getNumberOfNodes();
+       int NumberOfConstituentPerCell = Type.getNumberOfConstituents(1);
+       for (int j=_count[i]; j<_count[i+1]; j++) // we loop on all cell of this type
+         for (int k=1; k<=NumberOfConstituentPerCell; k++)
+           { // we loop on all sub cell of it
+             if (descend_connectivity[descend_connectivity_index[j-1]+k-2]==0) {
+               // it is a new sub cell !
+               //          TotalNumberOfSubCell++;
+               // Which type ?
+               if (Type.getConstituentType(1,k)==_constituent->_geometricTypes[0]){
+                 tmp_NumberOfConstituentsForeachType[0]++;
+                 TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[0];
+               } else {
+                 tmp_NumberOfConstituentsForeachType[1]++;
+                 TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[1];
+               }
+             //we have maximum two types
+               
+               descend_connectivity[descend_connectivity_index[j-1]+k-2]=TotalNumberOfSubCell;
+               ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2]=j;
+               int NumberOfNodesPerConstituent = Type.getConstituentType(1,k)%100;
            
-           int * NodesLists = new int[NumberOfNodesPerConstituent];
-           for (int l=0; l<NumberOfNodesPerConstituent; l++) {
-             NodesLists[l]=_nodal->getIJ(j,Type.getNodeConstituent(1,k,l+1));
-             ConstituentNodalConnectivity[ConstituentNodalConnectivityIndex[TotalNumberOfSubCell-1]-1+l]=NodesLists[l];
-           }
-           // we use reverse_nodal_connectivity to find the other element which contain this sub cell
-
-           // all elements which contains first node of sub cell :
-           int ReverseNodalConnectivityIndex_0 = ReverseNodalConnectivityIndex[NodesLists[0]-1];
-           int ReverseNodalConnectivityIndex_1 = ReverseNodalConnectivityIndex[NodesLists[0]];
-           int NumberOfCellsInList = ReverseNodalConnectivityIndex_1-ReverseNodalConnectivityIndex_0;
+               int * NodesLists = new int[NumberOfNodesPerConstituent];
+               for (int l=0; l<NumberOfNodesPerConstituent; l++) {
+                 NodesLists[l]=_nodal->getIJ(j,Type.getNodeConstituent(1,k,l+1));
+                 ConstituentNodalConnectivity[ConstituentNodalConnectivityIndex[TotalNumberOfSubCell-1]-1+l]=NodesLists[l];
+               }
+               // we use reverse_nodal_connectivity to find the other element which contain this sub cell
+
+               // all elements which contains first node of sub cell :
+               int ReverseNodalConnectivityIndex_0 = ReverseNodalConnectivityIndex[NodesLists[0]-1];
+               int ReverseNodalConnectivityIndex_1 = ReverseNodalConnectivityIndex[NodesLists[0]];
+               int NumberOfCellsInList = ReverseNodalConnectivityIndex_1-ReverseNodalConnectivityIndex_0;
+
+               if (NumberOfCellsInList > 0)  { // we could have no element !
+                 int * CellsList = new int[NumberOfCellsInList];
+                 for (int l=ReverseNodalConnectivityIndex_0; l<ReverseNodalConnectivityIndex_1; l++)
+                   CellsList[l-ReverseNodalConnectivityIndex_0]=ReverseNodalConnectivityValue[l-1];
+                 
+                 // foreach node in sub cell, we search elements which are in common
+                 // at the end, we must have only one !
+
+                 for (int l=1; l<NumberOfNodesPerConstituent; l++) {
+                   int NewNumberOfCellsInList = 0;
+                   int * NewCellsList = new int[NumberOfCellsInList];
+                   for (int l1=0; l1<NumberOfCellsInList; l1++)
+                     for (int l2=ReverseNodalConnectivityIndex[NodesLists[l]-1]; l2<ReverseNodalConnectivityIndex[NodesLists[l]]; l2++) {
+                       if (CellsList[l1]<ReverseNodalConnectivityValue[l2-1])
+                         // increasing order : CellsList[l1] are not in elements list of node l
+                         break;
+                       if ((CellsList[l1]==ReverseNodalConnectivityValue[l2-1])&(CellsList[l1]!=j)) {
+                         // we have found one
+                         NewCellsList[NewNumberOfCellsInList]=CellsList[l1];
+                         NewNumberOfCellsInList++;
+                         break;
+                       }
+                     }
+                   NumberOfCellsInList = NewNumberOfCellsInList;
 
-           if (NumberOfCellsInList > 0)  { // we could have no element !
-             int * CellsList = new int[NumberOfCellsInList];
-             for (int l=ReverseNodalConnectivityIndex_0; l<ReverseNodalConnectivityIndex_1; l++)
-               CellsList[l-ReverseNodalConnectivityIndex_0]=ReverseNodalConnectivityValue[l-1];
-           
-             // foreach node in sub cell, we search elements which are in common
-             // at the end, we must have only one !
-
-             for (int l=1; l<NumberOfNodesPerConstituent; l++) {
-               int NewNumberOfCellsInList = 0;
-               int * NewCellsList = new int[NumberOfCellsInList];
-               for (int l1=0; l1<NumberOfCellsInList; l1++)
-                 for (int l2=ReverseNodalConnectivityIndex[NodesLists[l]-1]; l2<ReverseNodalConnectivityIndex[NodesLists[l]]; l2++) {
-                   if (CellsList[l1]<ReverseNodalConnectivityValue[l2-1])
-                     // increasing order : CellsList[l1] are not in elements list of node l
-                     break;
-                   if ((CellsList[l1]==ReverseNodalConnectivityValue[l2-1])&(CellsList[l1]!=j)) {
-                     // we have found one
-                     NewCellsList[NewNumberOfCellsInList]=CellsList[l1];
-                     NewNumberOfCellsInList++;
-                     break;
-                   }
+                   delete [] CellsList;
+                   CellsList = NewCellsList;
                  }
-               NumberOfCellsInList = NewNumberOfCellsInList;
-
-               delete [] CellsList;
-               CellsList = NewCellsList;
-             }
            
-             if (NumberOfCellsInList > 0) { // We have found some elements !
-               int CellNumber = CellsList[0];
-               //delete [] CellsList;
-               if (NumberOfCellsInList>1)
-                 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one other Cell ("<<NumberOfCellsInList<<") !"));
-
-               if (NumberOfCellsInList==1) {
-                 ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=CellNumber;
-
-                 // we search sub cell number in this cell to not calculate it another time
-                 // which type ?
-                 CELLMODEL Type2;
-                 for (int l=0; l<_numberOfTypes; l++)
-                   if (CellNumber < _count[l+1]) {
-                     Type2=_type[l];
-                     break;
-                   }
-                 //int sub_cell_count2 = Type2.get_entities_count(1);
-                 //int nodes_cell_count2 = Type2.get_nodes_count();
-                 bool find2 = false;
-                 for (int l=1; l<=Type2.getNumberOfConstituents(1);l++) { // on all sub cell
-                   int counter = 0;
-                   for (int m=1; m<=Type2.getConstituentType(1,l)%100; m++)
-                     for (int n=1; n<=Type.getConstituentType(1,k)%100; n++) { 
-                       if (_nodal->getIJ(CellNumber,Type2.getNodeConstituent(1,l,m)) == NodesLists[n-1])
-                         counter++;
+                 if (NumberOfCellsInList > 0) { // We have found some elements !
+                   int CellNumber = CellsList[0];
+                   //delete [] CellsList;
+                   if (NumberOfCellsInList>1)
+                     throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one other Cell ("<<NumberOfCellsInList<<") !"));
+
+                   if (NumberOfCellsInList==1) {
+                     ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=CellNumber;
+                     
+                     // we search sub cell number in this cell to not calculate it another time
+                     // which type ?
+                     CELLMODEL Type2;
+                     for (int l=0; l<_numberOfTypes; l++)
+                       if (CellNumber < _count[l+1]) {
+                         Type2=_type[l];
+                         break;
+                       }
+                     //int sub_cell_count2 = Type2.get_entities_count(1);
+                     //int nodes_cell_count2 = Type2.get_nodes_count();
+                     bool find2 = false;
+                     for (int l=1; l<=Type2.getNumberOfConstituents(1);l++) { // on all sub cell
+                       int counter = 0;
+                       for (int m=1; m<=Type2.getConstituentType(1,l)%100; m++)
+                         for (int n=1; n<=Type.getConstituentType(1,k)%100; n++) { 
+                           if (_nodal->getIJ(CellNumber,Type2.getNodeConstituent(1,l,m)) == NodesLists[n-1])
+                             counter++;
+                         }
+                       if (counter==Type.getConstituentType(1,k)%100) {
+                         descend_connectivity[descend_connectivity_index[CellNumber-1]+l-2]=-1*TotalNumberOfSubCell; // because, see it in other side !
+                         find2 = true;
+                       }
+                       if (find2)
+                         break;
                      }
-                   if (counter==Type.getConstituentType(1,k)%100) {
-                     descend_connectivity[descend_connectivity_index[CellNumber-1]+l-2]=-1*TotalNumberOfSubCell; // because, see it in other side !
-                     find2 = true;
-                   }
-                   if (find2)
-                     break;
+                     if (!find2)
+                       MESSAGE(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!"); // exception ?
+                   } 
+                 } else {
+                   ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=0;
                  }
-                 if (!find2)
-                   INFOS(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!"); // exception ?
-               } 
-             } else {
-               ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=0;
+                 delete [] CellsList;
+               }
+
+               delete [] NodesLists;
              }
-             delete[] CellsList;
            }
-
-           delete[] NodesLists;
-         }
-       }
-    }
-    // we adjust _constituent
-    int NumberOfConstituent=0;
-    int SizeOfConstituentNodal=0;
-    for (int i=0;i<_constituent->_numberOfTypes; i++) {
-      NumberOfConstituent += tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1;
-      SizeOfConstituentNodal += (tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1)*_constituent->_type[i].getNumberOfNodes();
-    }
-    // we built new _nodal attribute in _constituent
-    //MEDSKYLINEARRAY *ConstituentNodal = new MEDSKYLINEARRAY(NumberOfConstituent,SizeOfConstituentNodal);
-    //const int *ConstituentNodalValue = ConstituentNodal->getValue();
-    //const int *ConstituentNodalIndex = ConstituentNodal->getIndex();
-    int *ConstituentNodalValue = new int[SizeOfConstituentNodal];
-    int *ConstituentNodalIndex = new int[NumberOfConstituent+1];
-    ConstituentNodalIndex[0]=1;
-    // we build _reverseDescendingConnectivity 
-    //_reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituent,2*NumberOfConstituent);
-    //const int *reverseDescendingConnectivityValue = _reverseDescendingConnectivity->getValue();
-    //const int *reverseDescendingConnectivityIndex = _reverseDescendingConnectivity->getIndex();
-    int *reverseDescendingConnectivityValue = new int[2*NumberOfConstituent];
-    int *reverseDescendingConnectivityIndex = new int[NumberOfConstituent+1];
-    reverseDescendingConnectivityIndex[0]=1;
-
-    // first constituent type
-    for(int j=0; j<tmp_NumberOfConstituentsForeachType[0]; j++) {
-      ConstituentNodalIndex[j+1]=ConstituentNodalConnectivityIndex[j+1];
-      for(int k=ConstituentNodalIndex[j]; k<ConstituentNodalIndex[j+1]; k++){
-       ConstituentNodalValue[k-1]=ConstituentNodalConnectivity[k-1];
       }
-      reverseDescendingConnectivityIndex[j+1]=reverseDescendingConnectivityIndex[j]+2;
-      for(int k=reverseDescendingConnectivityIndex[j]; k<reverseDescendingConnectivityIndex[j+1]; k++){
-       reverseDescendingConnectivityValue[k-1]=ReverseDescendingConnectivityValue[k-1];
+      // we adjust _constituent
+      int NumberOfConstituent=0;
+      int SizeOfConstituentNodal=0;
+      for (int i=0;i<_constituent->_numberOfTypes; i++) {
+       NumberOfConstituent += tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1;
+       SizeOfConstituentNodal += (tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1)*_constituent->_type[i].getNumberOfNodes();
       }
-    }
-    // second type if any
-    if (_constituent->_numberOfTypes==2) {
-      int offset = _constituent->_count[1]-tmp_NumberOfConstituentsForeachType[0]-1;
-      int offset1=offset*_constituent->_type[0].getNumberOfNodes();
-      int offset2=offset*2;
-      int NumberOfNodesPerConstituent = _constituent->_type[1].getNumberOfNodes();
-      for(int j=tmp_NumberOfConstituentsForeachType[0]; j<NumberOfConstituent; j++) {
-       ConstituentNodalIndex[j+1]=ConstituentNodalIndex[j]+NumberOfNodesPerConstituent;
+      // we built new _nodal attribute in _constituent
+      //MEDSKYLINEARRAY *ConstituentNodal = new MEDSKYLINEARRAY(NumberOfConstituent,SizeOfConstituentNodal);
+      //const int *ConstituentNodalValue = ConstituentNodal->getValue();
+      //const int *ConstituentNodalIndex = ConstituentNodal->getIndex();
+      int *ConstituentNodalValue = new int[SizeOfConstituentNodal];
+      int *ConstituentNodalIndex = new int[NumberOfConstituent+1];
+      ConstituentNodalIndex[0]=1;
+      // we build _reverseDescendingConnectivity 
+      //_reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituent,2*NumberOfConstituent);
+      //const int *reverseDescendingConnectivityValue = _reverseDescendingConnectivity->getValue();
+      //const int *reverseDescendingConnectivityIndex = _reverseDescendingConnectivity->getIndex();
+      int *reverseDescendingConnectivityValue = new int[2*NumberOfConstituent];
+      int *reverseDescendingConnectivityIndex = new int[NumberOfConstituent+1];
+      reverseDescendingConnectivityIndex[0]=1;
+
+      // first constituent type
+      for(int j=0; j<tmp_NumberOfConstituentsForeachType[0]; j++) {
+       ConstituentNodalIndex[j+1]=ConstituentNodalConnectivityIndex[j+1];
        for(int k=ConstituentNodalIndex[j]; k<ConstituentNodalIndex[j+1]; k++){
-         ConstituentNodalValue[k-1]=ConstituentNodalConnectivity[offset1+k-1];
+         ConstituentNodalValue[k-1]=ConstituentNodalConnectivity[k-1];
        }
        reverseDescendingConnectivityIndex[j+1]=reverseDescendingConnectivityIndex[j]+2;
        for(int k=reverseDescendingConnectivityIndex[j]; k<reverseDescendingConnectivityIndex[j+1]; k++){
-         reverseDescendingConnectivityValue[k-1]=ReverseDescendingConnectivityValue[offset2+k-1];
+         reverseDescendingConnectivityValue[k-1]=ReverseDescendingConnectivityValue[k-1];
        }
       }
-      _constituent->_count[2]=NumberOfConstituent+1;
-      // we correct _descending to adjust face number
-      for(int j=0;j<DescendingSize;j++)
-       if (descend_connectivity[j]>tmp_NumberOfConstituentsForeachType[0])
-         descend_connectivity[j]-=offset;
-      
-    }
+      // second type if any
+      if (_constituent->_numberOfTypes==2) {
+       int offset = _constituent->_count[1]-tmp_NumberOfConstituentsForeachType[0]-1;
+       int offset1=offset*_constituent->_type[0].getNumberOfNodes();
+       int offset2=offset*2;
+       int NumberOfNodesPerConstituent = _constituent->_type[1].getNumberOfNodes();
+       for(int j=tmp_NumberOfConstituentsForeachType[0]; j<NumberOfConstituent; j++) {
+         ConstituentNodalIndex[j+1]=ConstituentNodalIndex[j]+NumberOfNodesPerConstituent;
+         for(int k=ConstituentNodalIndex[j]; k<ConstituentNodalIndex[j+1]; k++){
+           ConstituentNodalValue[k-1]=ConstituentNodalConnectivity[offset1+k-1];
+         }
+         reverseDescendingConnectivityIndex[j+1]=reverseDescendingConnectivityIndex[j]+2;
+         for(int k=reverseDescendingConnectivityIndex[j]; k<reverseDescendingConnectivityIndex[j+1]; k++){
+           reverseDescendingConnectivityValue[k-1]=ReverseDescendingConnectivityValue[offset2+k-1];
+         }
+       }
+       _constituent->_count[2]=NumberOfConstituent+1;
+       // we correct _descending to adjust face number
+       for(int j=0;j<DescendingSize;j++)
+         if (descend_connectivity[j]>tmp_NumberOfConstituentsForeachType[0])
+           descend_connectivity[j]-=offset;
+      }
 
-    delete[] ConstituentNodalConnectivityIndex;
-    delete[] ConstituentNodalConnectivity;
-
-    _descending = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,
-                                     DescendingSize,
-                                     descend_connectivity_index,
-                                     descend_connectivity);
-    delete[] descend_connectivity_index;
-    delete[] descend_connectivity;
-    _reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituent,
-                                                        2*NumberOfConstituent,
-                                                        reverseDescendingConnectivityIndex,
-                                                        reverseDescendingConnectivityValue);
-    delete[] reverseDescendingConnectivityIndex;
-    delete[] reverseDescendingConnectivityValue;
-
-    _constituent->_count[1]=tmp_NumberOfConstituentsForeachType[0]+1;
-    delete[] tmp_NumberOfConstituentsForeachType;
-
-    //delete _constituent->_nodal;
-    _constituent->_nodal = new MEDSKYLINEARRAY(NumberOfConstituent,
-                                              SizeOfConstituentNodal,
-                                              ConstituentNodalIndex,
-                                              ConstituentNodalValue);
+      delete [] ConstituentNodalConnectivityIndex;
+      delete [] ConstituentNodalConnectivity;
+
+      _descending = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,
+                                       DescendingSize,
+                                       descend_connectivity_index,
+                                       descend_connectivity);
+      delete [] descend_connectivity_index;
+      delete [] descend_connectivity;
+      _reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituent,
+                                                          2*NumberOfConstituent,
+                                                          reverseDescendingConnectivityIndex,
+                                                          reverseDescendingConnectivityValue);
+      delete [] reverseDescendingConnectivityIndex;
+      delete [] reverseDescendingConnectivityValue;
+
+      _constituent->_count[1]=tmp_NumberOfConstituentsForeachType[0]+1;
+      delete [] tmp_NumberOfConstituentsForeachType;
+      
+      //delete _constituent->_nodal;
+      _constituent->_nodal = new MEDSKYLINEARRAY(NumberOfConstituent,
+                                                SizeOfConstituentNodal,
+                                                ConstituentNodalIndex,
+                                                ConstituentNodalValue);
     
-    delete[] ConstituentNodalIndex;
-    delete[] ConstituentNodalValue;
+      delete [] ConstituentNodalIndex;
+      delete [] ConstituentNodalValue;
 
-    delete[] ReverseDescendingConnectivityValue;
-  }
+      delete [] ReverseDescendingConnectivityValue;
+    }
   END_OF(LOC);
 }
 
@@ -1243,29 +1480,126 @@ void CONNECTIVITY::calculateDescendingConnectivity()
 void CONNECTIVITY::calculateNeighbourhood(CONNECTIVITY &myConnectivity)
 //--------------------------------------------------------------------//
 {
+  const char * LOC = "CONNECTIVITY::calculateNeighbourhood(CONNECTIVITY &myConnectivity) : ";
+  BEGIN_OF(LOC);
+
+  MESSAGE(LOC<<"method not yet implemented " << myConnectivity._entity);
   // Mesh dimension !
+
+  END_OF(LOC);
   return;
 }
 
 
 /*! 
-  Give, for one element number of a specified entity the geometric type
-  Of this element.
+  Returns the geometry of an element given by its entity type & its global number.
 
   Example : medGeometryElement myType = myConnectivity.getElementType(MED_CELL,35);
 */
 //--------------------------------------------------------------------//
-medGeometryElement CONNECTIVITY::getElementType(medEntityMesh Entity,int Number) const
+medGeometryElement CONNECTIVITY::getElementType(medEntityMesh Entity,int globalNumber) const
 //--------------------------------------------------------------------//
 {
+  const char * LOC = "medGeometryElement CONNECTIVITY::getElementType(medEntityMesh Entity, int globalNumber) const : ";
+  BEGIN_OF(LOC);
+
+  // The globalNumber must verify  : 1 <=  globalNumber < _count[_numberOfTypes] (== totalNumberOfElement+1)
+  if ( (globalNumber < 1) || (globalNumber >  _count[_numberOfTypes]-1 )  )
+    throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "globalNumber must be between >= |" 
+                                 << 1 <<"| and <= |" << _count[_numberOfTypes]-1 ));
+
   if (_entity==Entity) {
     for(int i=1; i<=_numberOfTypes;i++)
-      if (Number<_count[i])
+      if (globalNumber<_count[i])
        return _geometricTypes[i-1];
   }
   else if (_constituent!=NULL)
-    return _constituent->getElementType(Entity,Number);
+    return _constituent->getElementType(Entity,globalNumber);
   else
     throw MEDEXCEPTION(LOCALIZED("getElementType : Entity not defined !"));
   throw MEDEXCEPTION(LOCALIZED("getElementType : Wrong Number !"));
+
+  END_OF(LOC);
+}
+
+
+ostream & operator<<(ostream &os, CONNECTIVITY &co)
+{
+    os << endl << "------------- Entity = ";
+    switch (co._entity)
+    {
+       case MED_CELL:
+           os << "MED_CELL";
+           break;
+       case MED_FACE:
+           os << "MED_FACE";
+           break;
+       case MED_EDGE:
+           os << "MED_EDGE";
+           break;
+       case MED_NODE:
+           os << "MED_NODE";
+           break;
+       case MED_ALL_ENTITIES:
+           os << "MED_ALL_ENTITIES";
+           break;
+       default:
+           os << "Unknown";
+           break;
+    } 
+    os  << " -------------\n\nMedConnectivity : ";
+    switch (co._typeConnectivity)
+    {
+       case MED_NODAL:
+           os << "MED_NODAL\n";
+           break;
+       case MED_DESCENDING:
+           os << "MED_DESCENDING\n";
+           break;
+       default:
+           break;
+    } 
+    os << "Entity dimension : " << co._entityDimension << endl;
+    os << "Number of nodes : " << co._numberOfNodes << endl;
+    os << "Number of types : " << co._numberOfTypes << endl;
+    for (int i=0; i!=co._numberOfTypes ; ++i)
+       os << "  -> Type " << co._geometricTypes[i] << " (" << co._type[i].getName() << ") : " 
+          << co._count[i+1]-co._count[i] << " elements" << endl;
+
+    if (co._typeConnectivity == MED_NODAL )
+    {
+       for (int i=0; i<co._numberOfTypes; i++) 
+       {
+           os << endl << co._type[i].getName() << " : " << endl;
+           int numberofelements = co._count[i+1]-co._count[i];
+           const med_int * connectivity = co.getConnectivity(co._typeConnectivity, co._entity, co._geometricTypes[i]);
+           int numberofnodespercell = co._geometricTypes[i]%100;
+           for (int j=0;j<numberofelements;j++)
+           {
+               os << setw(6) << j+1 << " : ";
+               for (int k=0;k<numberofnodespercell;k++)
+                   os << connectivity[j*numberofnodespercell+k]<<" ";
+               os << endl;
+           }
+       }
+    }
+    else if (co._typeConnectivity == MED_DESCENDING)
+    {
+       int numberofelements = co.getNumberOf( co._entity , MED_ALL_ELEMENTS);
+       const med_int *connectivity =  co.getConnectivity( co._typeConnectivity, co._entity, MED_ALL_ELEMENTS);
+       const int *connectivity_index =  co.getConnectivityIndex( co._typeConnectivity, co._entity );
+       
+       for ( int j=0; j!=numberofelements; j++ ) 
+       {
+           os << "Element " << j+1 << " : ";
+           for ( int k=connectivity_index[j]; k!=connectivity_index[j+1]; k++ )
+               os << connectivity[k-1] << " ";
+           os << endl;
+       }
+    }
+
+    if (co._constituent)
+       os << endl << *co._constituent << endl;
+
+    return os;
 }
index 9986a2350df4e5a989f39461fd00418d06362321..c0ec8c0984689a836869d8836c13480fc7f0f665 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Connectivity.hxx
-//  Module : MED
-
 #ifndef CONNECTIVITY_HXX
 #define CONNECTIVITY_HXX
 
@@ -38,6 +12,7 @@ using namespace MED_EN;
 class MEDSKYLINEARRAY;
 class CELLMODEL;
 class FAMILY;
+class GROUP;
 
 /*!
        This class deals with all type of connectivity ./n
@@ -142,6 +117,7 @@ public:
 
   friend class MED_MESH_RDONLY_DRIVER;
   friend class MED_MESH_WRONLY_DRIVER;
+  friend ostream & operator<<(ostream &os, CONNECTIVITY &connectivity);
 
   // in order to fill CONNECTIVITY of MESH
   friend class GRID;
@@ -149,7 +125,7 @@ public:
   CONNECTIVITY  (medEntityMesh Entity=MED_CELL);
   CONNECTIVITY  (int numberOfTypes, medEntityMesh Entity=MED_CELL);
   CONNECTIVITY  (const CONNECTIVITY & m);
-  ~CONNECTIVITY ();
+  virtual ~CONNECTIVITY ();
 
   void setConstituent (CONNECTIVITY * Constituent)
                                                throw (MEDEXCEPTION);
@@ -166,11 +142,16 @@ public:
                 const medGeometryElement Type)
                                         throw (MEDEXCEPTION);
 
+  inline void setNumberOfNodes(med_int NumberOfNodes);
+  
+  inline void setEntityDimension(med_int EntityDimension);
+
   inline bool   existConnectivity     (medConnectivity connectivityType, medEntityMesh Entity) const;
 
-  void          calculateConnectivity (medConnectivity connectivityType, medEntityMesh Entity);
+  virtual void          calculateConnectivity (medConnectivity connectivityType, medEntityMesh Entity);
 
-  void          updateFamily (vector<FAMILY*> myFamilies);
+  virtual void          updateFamily (vector<FAMILY*> myFamilies);
+  virtual void          updateGroup (vector<GROUP*> myFamilies);
 
   inline medEntityMesh              getEntity               ()                     const;
   inline med_int                    getNumberOfTypes        (medEntityMesh Entity) const;
@@ -178,13 +159,13 @@ public:
                                                             throw (MEDEXCEPTION);
   medGeometryElement                getElementType          (medEntityMesh Entity,
                                                             int Number)           const;
-  inline const int *                getGlobalNumberingIndex (medEntityMesh Entity) const
+  virtual inline const int *                getGlobalNumberingIndex (medEntityMesh Entity) const
                                                             throw (MEDEXCEPTION);
 
-  const med_int *     getConnectivity      (medConnectivity ConnectivityType, 
+  virtual const med_int *     getConnectivity      (medConnectivity ConnectivityType, 
                                            medEntityMesh Entity,
                                             medGeometryElement Type);
-  const med_int *     getConnectivityIndex (medConnectivity ConnectivityType,
+  virtual const med_int *     getConnectivityIndex (medConnectivity ConnectivityType,
                                            medEntityMesh Entity);
  
   const CELLMODEL &   getType              (medGeometryElement Type) const; 
@@ -193,16 +174,16 @@ public:
  
   med_int       getNumberOfNodesInType     (medGeometryElement Type) const; 
   med_int       getNumberOfSubCellInType   (medGeometryElement Type) const; 
-  med_int      getNumberOf                (medEntityMesh Entity, 
+  virtual med_int      getNumberOf                (medEntityMesh Entity, 
                                            medGeometryElement Type) const;
-  const med_int*      getValue             (medConnectivity TypeConnectivity, 
+  virtual const med_int*      getValue             (medConnectivity TypeConnectivity, 
                                             medGeometryElement Type); 
-  const med_int*      getValueIndex        (medConnectivity TypeConnectivity);
+  virtual const med_int*      getValueIndex        (medConnectivity TypeConnectivity);
 
-  inline const med_int* getReverseConnectivity (medConnectivity ConnectivityType, 
+  virtual inline const med_int* getReverseConnectivity (medConnectivity ConnectivityType, 
                                                 medEntityMesh Entity=MED_CELL)
                                                throw (MEDEXCEPTION);
-  inline const med_int* getReverseConnectivityIndex (medConnectivity ConnectivityType, 
+  virtual inline const med_int* getReverseConnectivityIndex (medConnectivity ConnectivityType, 
                                                     medEntityMesh Entity=MED_CELL)
                                                     throw (MEDEXCEPTION);
 
@@ -233,6 +214,33 @@ inline med_int CONNECTIVITY::getNumberOfTypes(medEntityMesh Entity) const
        return _numberOfTypes; 
   else if (_constituent!=NULL)
        return _constituent->getNumberOfTypes(Entity);
+  else if (_constituent == NULL)
+    {
+      MESSAGE("CONNECTIVITY::getNumberOfTypes : _constituent == NULL");
+      try
+       {
+         (const_cast <CONNECTIVITY *> (this))->calculateDescendingConnectivity();
+       }
+      catch (MEDEXCEPTION & ex)
+       {
+         return 0 ;
+       }
+
+      SCRUTE(_entityDimension);
+
+      if (_entityDimension != 2 && _entityDimension != 3) return 0;
+
+      try
+       {
+         _constituent->calculateConnectivity(MED_NODAL,Entity);
+       }
+      catch (MEDEXCEPTION & ex)
+       {
+         return 0 ;
+       }
+
+      return _constituent->getNumberOfTypes(Entity);
+    }
   else
        return 0; // because it is the right information (no exception needed)!
 }
@@ -251,10 +259,23 @@ inline const medGeometryElement* CONNECTIVITY::getGeometricTypes(medEntityMesh E
   else if (_constituent!=NULL)
        return _constituent->getGeometricTypes(Entity);
   else
-       throw MEDEXCEPTION("Entity not defined !");
+       throw MEDEXCEPTION("CONNECTIVITY::getGeometricTypes : Entity not defined !");
 }
 
-/*! A DOCUMENTER */
+/*!   Returns an array containing the accumulated number of entities sorted by the geometric type./n
+
+      Exemple :/n
+
+      In case of a CONNECTIVITY containing 3*MED_TRIA3 et 2*MED_QUAD4 : /n
+            int * count = getGlobalNumberingIndex(MED_CELL)/n
+      count[0] is always set to 1/n
+      count[1] is set to 1+3=4/n
+      count[2] is set to 4+2=6 = total number of cells + 1/n
+
+      Note : Not implemented for MED_ALL_ENTITIES. /n
+      Note : The geometric type order is given by the typedef enum medGeometryElement.
+                      
+*/
 //----------------------------------------------------------------------------------//
 inline const int * CONNECTIVITY::getGlobalNumberingIndex(medEntityMesh Entity) const 
                                                throw (MEDEXCEPTION)
@@ -265,7 +286,7 @@ inline const int * CONNECTIVITY::getGlobalNumberingIndex(medEntityMesh Entity) c
   else if (_constituent!=NULL)
        return _constituent->getGlobalNumberingIndex(Entity);
   else
-       throw MEDEXCEPTION("Entity not defined !");
+       throw MEDEXCEPTION("CONNECTIVITY::getGlobalNumberingIndex : Entity not defined !");
 }
 
 /*!  Returns true if a connectivity exists on elements of type "Entity" */
@@ -299,8 +320,8 @@ inline const CELLMODEL * CONNECTIVITY::getCellsTypes(medEntityMesh Entity) const
     if (_type!=NULL)
       return _type;
     else
-      throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) :
-                          CELLMODEL array is not defined !");
+      throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) :"
+                        " CELLMODEL array is not defined !");
   else
     if (_constituent != NULL)
       return _constituent->getCellsTypes(Entity);
@@ -350,5 +371,16 @@ inline const med_int* CONNECTIVITY::getReverseConnectivityIndex(medConnectivity
   return _constituent->getReverseConnectivityIndex(ConnectivityType,Entity);
 }
 
+
+inline void CONNECTIVITY::setNumberOfNodes(med_int NumberOfNodes)
+{
+    _numberOfNodes=NumberOfNodes;
+}
+  
+inline void CONNECTIVITY::setEntityDimension(med_int EntityDimension)
+{
+    _entityDimension=EntityDimension;
+}
+
 #endif /* CONNECTIVITY_HXX */
 
index 686c618bc8e0aff3675b59fa36362fea846a7718..caae4090b3f8b99d65c9a16aaf2c5f8438c3d53f 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Coordinate.cxx
-//  Module : MED
-
 using namespace std;
 #include "MEDMEM_Coordinate.hxx"
 #include "MEDMEM_Exception.hxx"
@@ -33,10 +7,10 @@ using namespace std;
 
 /*! Default Constructor : should not be used */
 //----------------------------------------------------------//
-COORDINATE::COORDINATE():_coordinate(MEDARRAY<double>()),
+COORDINATE::COORDINATE():_coordinateSystem(""),
+                        _coordinate(MEDARRAY<double>()),
                         _coordinateName(),
                         _coordinateUnit(),
-                        _coordinateSystem(""),
                         _nodeNumber()
 //----------------------------------------------------------//
 {
@@ -47,11 +21,11 @@ COORDINATE::COORDINATE():_coordinate(MEDARRAY<double>()),
     It will create empty array for optional data (nodeNumber..) */
 //------------------------------------------------------------------------------//
 COORDINATE::COORDINATE(int SpaceDimension, int NumberOfNodes, medModeSwitch Mode):
-                        _nodeNumber(),
-                        _coordinateUnit(SpaceDimension),
-                       _coordinateSystem(""),
-                       _coordinateName(SpaceDimension),
-                       _coordinate(SpaceDimension,NumberOfNodes,Mode)
+  _coordinateSystem(""),
+  _coordinate(SpaceDimension,NumberOfNodes,Mode),
+  _coordinateName(SpaceDimension),
+  _coordinateUnit(SpaceDimension),
+  _nodeNumber()
 
 //------------------------------------------------------------------------------//
 {
@@ -102,8 +76,8 @@ void COORDINATE::setCoordinates(MEDARRAY<double> *Coordinate)
 { 
 
   const medModeSwitch mode = Coordinate->getMode(); 
-  const int  spaceDimension = (int) Coordinate->getLeadingValue();
-  const int  numberOfNodes  = (int) Coordinate->getLengthValue();
+  //  const int  spaceDimension = (int) Coordinate->getLeadingValue();
+  //  const int  numberOfNodes  = (int) Coordinate->getLengthValue();
   if ( Coordinate->get(mode) != NULL)
   {
       MEDARRAY<double> pourAttribut(*Coordinate,false);
@@ -196,12 +170,12 @@ void COORDINATE::setNodesNumbers(const int * NodeNumber)
 
 int COORDINATE::getSpaceDimension() const
 {      
-  _coordinate.getLeadingValue() ; 
+  return _coordinate.getLeadingValue() ; 
 }
 
 int COORDINATE::getNumberOfNodes() const
 {      
-  _coordinate.getLengthValue() ; 
+  return _coordinate.getLengthValue() ; 
 }
 
 
index 4bb0ee8b33699380eda56675bd532a48417af671..d77b848394c0926e03ab77f97c014ac588533892 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Coordinate.hxx
-//  Module : MED
-
 /*
  File Coordinate.hxx
  $Header$
@@ -66,7 +40,7 @@ protected:
                                         Storing the object (not a pointer to this object) is more convenient for memory
                                         management.
                                         */
-  MEDARRAY<double>            _coordinate;
+  mutable MEDARRAY<double>            _coordinate;
 
                                     /*! PointerOf to an array of size spaceDimension storing axes names*/
   PointerOf<string>          _coordinateName;
@@ -87,7 +61,7 @@ public :
   COORDINATE();
   COORDINATE(int SpaceDimension, int NumberOfNodes, medModeSwitch Mode);
   COORDINATE(const COORDINATE & m);
-  ~COORDINATE();
+  virtual ~COORDINATE();
 
   void setCoordinates(MEDARRAY<double> *Coordinate);
   void setCoordinates(const medModeSwitch Mode, const double *Coordinate);
@@ -101,13 +75,13 @@ public :
   int             getSpaceDimension() const;
   int             getNumberOfNodes() const;
 
-  const int*      getNodesNumbers() const;
+  virtual const int*      getNodesNumbers() const;
   //const int*            getNodesNumbers() ;
   string          getCoordinatesSystem() const;
 
-  const double *  getCoordinates(medModeSwitch Mode);
-  double          getCoordinate(int Number,int Axis);
-  const double *  getCoordinateAxis(int Axis);
+  virtual const double *  getCoordinates(medModeSwitch Mode);
+  virtual double          getCoordinate(int Number,int Axis);
+  virtual const double *  getCoordinateAxis(int Axis);
 
   const string * getCoordinatesNames() const;
   string   getCoordinateName(int Axis) const;
diff --git a/src/MEDMEM/MEDMEM_DriverTools.cxx b/src/MEDMEM/MEDMEM_DriverTools.cxx
new file mode 100644 (file)
index 0000000..82451e5
--- /dev/null
@@ -0,0 +1,423 @@
+using namespace std;
+#include "MEDMEM_DriverTools.hxx"
+#include "MEDMEM_STRING.hxx"
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Group.hxx"
+#include <algorithm>
+
+
+// Cet opérateur permet d'ordonner les mailles dans un set suivant l'ordre requis par MED
+bool _maille::operator < (const _maille& ma) const
+{
+    // si le type géométrique differe, la comparaison est basée dessus
+    // sinon on se base sur une comparaison des numéros de sommets 
+    if(geometricType==ma.geometricType)
+    {
+       // construction de deux vecteur temporaire contenant les numeros de sommets
+       // pour faire le tri et les comparaisons
+       size_t l=sommets.size();
+       std::vector<int> v1(l);
+       std::vector<int> v2(l);
+       for (unsigned int i=0; i!=l; ++i)
+         {
+           v1[i]=sommets[i]->second.number;
+           v2[i]=ma.sommets[i]->second.number;
+         }
+       std::sort(v1.begin(), v1.end());
+       std::sort(v2.begin(), v2.end());
+       for(std::vector<int>::const_iterator i1=v1.begin(), i2=v2.begin(); i1!=v1.end(); ++i1, ++i2)
+           if(*i1 != *i2)
+               return *i1 < *i2;
+       return false; // cas d'égalité
+    }
+    else
+       return geometricType<ma.geometricType;
+};
+
+
+// retourne l'entité d'une maille en fonction de la dimension du maillage.
+MED_EN::medEntityMesh _maille::getEntity(const int meshDimension) const throw (MEDEXCEPTION)
+{
+  const char * LOC = "_maille::getEntity(const int meshDimension)" ;
+  BEGIN_OF(LOC);
+
+  int mailleDimension = this->dimension();
+  medEntityMesh entity;
+  if (mailleDimension == meshDimension)
+    entity = MED_CELL;
+  else
+    switch (mailleDimension)
+      {
+      case 0 :
+       entity = MED_NODE;
+       break;
+      case 1 :
+       entity = MED_EDGE;
+       break;
+      case 2 :
+       entity = MED_FACE;
+       break;
+      default :
+       throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Impossible de determiner l'entite de la maille."));
+      }
+return entity;
+
+END_OF(LOC);
+};
+
+std::ostream& operator << (std::ostream& os, const _maille& ma)
+{
+    os << "maille " << ma.ordre << " (" << ma.geometricType << ") : < ";
+    std::vector< std::map<int,_noeud>::iterator >::const_iterator i=ma.sommets.begin();
+    os << (*i++)->second.number ;
+    for( ; i!=ma.sommets.end(); ++i)
+       os << ", " << (*i)->second.number;
+    os << " >";
+    return os;
+}
+
+std::ostream& operator << (std::ostream& os, const _groupe& gr)
+{
+    os << "--- Groupe " << gr.nom << " --- " << std::endl ;
+    os << " -> liste des sous-groupes : ";
+    for( std::list<int>::const_iterator i=gr.groupes.begin(); i!=gr.groupes.end(); ++i)
+       os << *i << " ";
+    os << std::endl << " -> liste des mailles : " << std::endl;
+    for( _groupe::mailleIter i=gr.mailles.begin(); i!=gr.mailles.end(); i++)
+       os << "    " << *(*i) << std::endl;
+    return os;
+}
+
+std::ostream& operator << (std::ostream& os, const _noeud& no)
+{
+    os << "noeud " << no.number << " : < ";
+    std::vector<double>::const_iterator i=no.coord.begin();
+    os << *i++ ;
+    for( ; i!=no.coord.end(); ++i)
+       os << ", " << *i;
+    os << " >";
+    return os;
+}
+
+std::ostream& operator << (std::ostream& os, const _intermediateMED& mi)
+{
+    os << "Set des mailles : " << std::endl;
+    for( std::set<_maille>::const_iterator i=mi.maillage.begin(); i!=mi.maillage.end(); ++i)
+       os << *i << std::endl;
+    
+    os << std::endl << "Vector des groupes : " << std::endl;
+   // for( std::vector<_groupe>::const_iterator i=mi.groupes.begin(); i!=mi.groupes.end(); ++i)
+    for (unsigned int i=0; i!=mi.groupes.size(); i++)
+      os << std::setw(3) << i << " " << mi.groupes[i] << std::endl;
+    
+    os << std::endl << "map des noeuds : " << std::endl;
+    for( std::map<int,_noeud>::const_iterator i=mi.points.begin(); i!=mi.points.end(); ++i)
+       os << i->second << std::endl;
+    return os;
+}
+
+void _intermediateMED::numerotationMaillage()
+{
+    // numerotation des mailles par entité
+    int i_maille=0;
+    std::set<_maille>::iterator i=maillage.begin();
+    int dimension=i->dimension();
+    for( ; i!=maillage.end(); ++i)
+    {
+       if ( dimension!=i->dimension() ) // on change d'entite
+       {
+           dimension=i->dimension();
+           i_maille=0;
+       }
+       (*i).ordre=++i_maille;
+    }
+}
+
+void _intermediateMED::numerotationPoints()
+{
+    // Fonction de renumerotation des noeuds (necessaire quand il y a des trous dans la numerotation.
+    int i_noeud=0;
+    for( std::map<int,_noeud>::const_iterator i=points.begin(); i!=points.end(); ++i)
+       i->second.number = ++i_noeud ;
+}
+    
+
+/*!
+ * \if developper
+ * create a MED COORDINATE from the intermediate structure.
+ * \endif
+ */
+COORDINATE *
+_intermediateMED::getCoordinate()
+{
+    const medModeSwitch mode=MED_FULL_INTERLACE;
+    const string coordinateSystem="CARTESIAN";
+
+    int spaceDimension=points.begin()->second.coord.size();
+    int numberOfNodes=points.size();
+
+
+    // creation du tableau des coordonnees en mode MED_FULL_INTERLACE
+    double * coord = new double[spaceDimension*numberOfNodes];
+    int k=0;
+    for( std::map<int,_noeud>::const_iterator i=points.begin(); i!=points.end(); ++i, ++k)
+       std::copy(i->second.coord.begin(), i->second.coord.end(), coord+k*spaceDimension);
+
+    // creation de l'objet COORDINATE
+    COORDINATE * coordinate = new COORDINATE(spaceDimension, numberOfNodes, mode);
+    coordinate->setCoordinates(mode,coord);
+    delete [] coord;
+    coordinate->setCoordinatesSystem(coordinateSystem);
+    return coordinate;
+}
+
+
+  /*!
+   * \if developper
+   * create a MED CONNECTIVITY from the intermediate structure.
+   * for memory optimisation, clear the intermediate structure (the "maillage" set )
+   * \endif
+   */
+CONNECTIVITY * 
+_intermediateMED::getConnectivity()
+{
+    const char * LOC = "_intermediateMED::getConnectivity() : ";
+    BEGIN_OF(LOC);
+    int numberOfNodes=points.size(); // number of nodes in the mesh
+    int numberOfTypes=0;
+    medEntityMesh entity;
+    medGeometryElement * types=NULL; // pointeurs pour allouer les structures MED
+    int * count=NULL;
+    int * connectivity=NULL;
+    CONNECTIVITY *Connectivity, *Constituent;
+
+    medGeometryElement type=0; // variables de travail
+    int nbtype=0;
+    int dimension=0;
+    bool first = true;
+
+    std::vector<medGeometryElement> vtype; // tableau de travail : stockage des types geometriques pour UNE entite
+    std::vector<int> vcount; // tableau de travail : nombre d'elements pour chaque type geometrique de vtype
+
+    std::set<_maille>::const_iterator i=maillage.begin(); // iterateurs sur les mailles
+    std::set<_maille>::const_iterator j=maillage.begin();
+
+    // renumerote les points de 1 a n (pour le cas ou certains points ne sont pas presents dans le maillage d'origine) 
+    numerotationPoints(); 
+
+    do 
+    {
+       // boucle sur les entites de la structure maillage :
+       //   - on parcourt une premiere fois avec i les mailles d'une entite pour récupérer 
+       //     des infos sur les types geometriques, leur nombre et le nombre d'elements.
+       //   - on alloue la connectivite
+       //   - on parcourt une deuxieme fois avec j pour lire les noeuds.
+
+
+       type=i->geometricType; // init boucle for
+       dimension=i->dimension();
+       nbtype=0;
+       vtype.push_back(type);
+       // Boucle sur i de parcours des mailles d'une entite
+       // Une entite se termine lorsqu'on atteint la fin de maillage ou lorsque la dimension des mailles change
+       for( ; i!=maillage.end() && dimension==i->dimension() ; ++i)
+       {
+           if (type != i->geometricType) // si changement de type geometrique
+           {
+               vcount.push_back(nbtype); // stocke le nombre d'elements de type nbtype
+               nbtype=0;
+               type=i->geometricType;
+               vtype.push_back(type); // stocke le nouveau type geometrique rencontre
+           }
+
+           ++nbtype;
+       }
+       vcount.push_back(nbtype); // n'a pas été stocké dans la boucle
+
+       
+       // Pour l'entite qu'on vient de parcourir, allocation des tableau et creation de la connectivite
+//     cout << "Dimension = " << dimension << endl;
+//     cout << "Nombre de type geometriques : " << vtype.size() << endl;
+//     for (unsigned k=0; k!=vtype.size(); ++k )
+//         cout << "  -> " << vtype[k] << " : " << vcount[k] << endl;
+
+       numberOfTypes=vtype.size(); // nombre de types de l'entite
+       
+       if ( i==maillage.end() ) // cas de l'entite de plus haut niveau
+           entity=MED_CELL;
+       else if (dimension==2 )
+           entity=MED_FACE;
+       else if (dimension==1 )
+           entity=MED_EDGE;
+       else if (dimension==0 )
+           entity=MED_NODE;
+
+       Connectivity = new CONNECTIVITY(numberOfTypes,entity);
+       Connectivity->setEntityDimension(dimension);
+       Connectivity->setNumberOfNodes(numberOfNodes);
+       
+       types = new medGeometryElement[numberOfTypes];
+       std::copy(vtype.begin(),vtype.end(),types);
+       Connectivity->setGeometricTypes(types,entity);
+       delete [] types;
+
+       count = new int[numberOfTypes+1];
+       count[0]=1;
+       for (unsigned int k=0; k!=vcount.size(); ++k )
+         count[k+1]=count[k]+vcount[k];
+       Connectivity->setCount (count, entity);
+       delete [] count;
+
+       for (int k=0; k!=numberOfTypes; ++k )
+         {
+           // pour chaque type geometrique k, copie des sommets dans connectivity et set dans Connectivity
+           int nbSommetsParMaille = j->sommets.size();
+           int nbSommets = vcount[k] * j->sommets.size();
+           connectivity = new int[ nbSommets ];
+           for (int l=0; l!=vcount[k]; ++l, ++j)
+           {
+               for ( unsigned n=0; n != j->sommets.size(); ++n)
+                   connectivity[nbSommetsParMaille*l+n] = j->sommets[n]->second.number;
+               maillage.erase(j);    ; // dangereux, mais optimise la mémoire consommée!
+           }
+
+           Connectivity->setNodal  (connectivity, entity, vtype[k]);
+           delete [] connectivity;
+         }
+               
+       if (i!=j)
+           throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Erreur de lecture des mailles ."));
+
+       if ( ! first)
+           Connectivity->setConstituent (Constituent);
+       else
+           first = false;
+       Constituent = Connectivity; // stocke Connectivity pour utilisation dans setConstituent lors de la boucle suivante
+
+       vtype.clear();
+       vcount.clear();
+
+    }
+    while ( i != maillage.end() );
+
+    END_OF(LOC);
+    return Connectivity;
+}
+
+
+  /*!
+   * \if developper
+   * fill the arguments vector of groups from the intermediate structure.
+   * This function must be called before getConnectivity()
+   * \endif
+   */
+void
+_intermediateMED::getGroups(std::vector<GROUP *> & _groupCell, std::vector<GROUP *> & _groupFace, std::vector<GROUP *> & _groupEdge, std::vector<GROUP *> & _groupNode, MESH * _ptrMesh)
+{
+    const char * LOC = "_intermediateMED::getGroups() : ";
+    BEGIN_OF(LOC);
+    if (maillage.size() == 0)
+       throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Erreur : il n'y a plus de mailles (appeler getConnectivity apres getGroups!)."));
+
+    int dimension_maillage=maillage.rbegin()->dimension();
+
+    numerotationMaillage(); // Renumerotation des mailles par entite
+
+    for (unsigned int i=0; i!=this->groupes.size(); ++i)
+    {
+       if (groupes[i].mailles.size()==0)
+           continue; // si le groupe est vide, on passe au suivant
+
+       int nb_geometric_types=1;
+       _groupe::mailleIter j=groupes[i].mailles.begin(); 
+       // initialise groupe_entity a l'entite de la premiere maille du groupe
+       medEntityMesh groupe_entity = (**j).getEntity(dimension_maillage);
+       medGeometryElement geometrictype=(**j).geometricType;
+
+       //Parcours des mailles (a partir de la deuxieme) pour compter les types geometriques
+       for ( ++j ; j!=groupes[i].mailles.end(); ++j )
+       {
+           //Compte nombre de types geometriques
+           if ( (**j).geometricType != geometrictype ) // si on change de type geometrique
+           {
+               nb_geometric_types++;
+               geometrictype=(**j).geometricType;
+           }
+
+           //Test si groupe valide : le groupe doit pointer vers des entites de meme dimension
+           if ((**j).dimension() != dimension_maillage)
+               continue;
+       }
+
+       // le groupe est valide -> on le traite
+       MED_EN::medGeometryElement * tab_types_geometriques = new MED_EN::medGeometryElement[nb_geometric_types];
+       int * tab_index_types_geometriques = new int[nb_geometric_types+1];
+       int * tab_numeros_elements = new int[groupes[i].mailles.size()];
+       int * tab_nombres_elements = new int[nb_geometric_types];
+
+       //Remplit tableaux entree des methodes set
+       int indice_mailles=0;
+       j=groupes[i].mailles.begin();
+       geometrictype=(**j).geometricType;
+       tab_index_types_geometriques[0]=1;
+       int indice_types_geometriques=1;
+       tab_types_geometriques[0]=geometrictype;
+       //parcours des mailles du groupe
+       for (  ; j!=groupes[i].mailles.end(); ++j , ++indice_mailles)
+       {
+           tab_numeros_elements[indice_mailles]=((**j).ordre);
+           if ((**j).geometricType != geometrictype)
+           {
+               tab_index_types_geometriques[indice_types_geometriques]=indice_mailles+1;
+               geometrictype=(**j).geometricType;
+               tab_types_geometriques[indice_types_geometriques]=geometrictype;
+               ++indice_types_geometriques;
+           }
+       }
+       tab_index_types_geometriques[indice_types_geometriques]=indice_mailles+1;
+       for (int k=0; k != nb_geometric_types; ++k)
+       {
+           tab_nombres_elements[k] = tab_index_types_geometriques[k+1]-tab_index_types_geometriques[k];
+       }
+
+       //Determination type entite du groupe
+       vector <GROUP *> * vect_group;
+       switch ( groupe_entity )
+       {
+           case MED_CELL :
+               vect_group= & _groupCell;
+               break;
+           case MED_FACE :
+               vect_group= & _groupFace;
+               break;
+           case MED_EDGE :
+               vect_group= & _groupEdge;
+               break;
+           case MED_NODE :
+               vect_group= & _groupNode;
+               break;
+       }
+       //Creation nouveau groupe MED
+       GROUP * new_group = new GROUP();
+       //Appel methodes set
+       new_group->setTotalNumberOfElements(groupes[i].mailles.size());
+       new_group->setName(groupes[i].nom);
+       new_group->setMesh(_ptrMesh);
+       new_group->setNumberOfGeometricType(nb_geometric_types);
+       new_group->setGeometricType(tab_types_geometriques);
+       new_group->setNumberOfElements(tab_nombres_elements);
+       new_group->setNumber(tab_index_types_geometriques,tab_numeros_elements);
+       new_group->setEntity(groupe_entity);
+       new_group->setAll(groupes[i].mailles.size() == maillage.size());
+       vect_group->push_back(new_group);
+       delete [] tab_types_geometriques;
+       delete [] tab_index_types_geometriques;
+       delete [] tab_numeros_elements;
+       delete [] tab_nombres_elements;
+    }
+
+    END_OF(LOC);
+}
+
+/////
diff --git a/src/MEDMEM/MEDMEM_DriverTools.hxx b/src/MEDMEM/MEDMEM_DriverTools.hxx
new file mode 100644 (file)
index 0000000..7ea40d0
--- /dev/null
@@ -0,0 +1,91 @@
+#ifndef DRIVERTOOLS_HXX
+#define DRIVERTOOLS_HXX
+
+
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_Exception.hxx"
+#include <string>
+#include <vector>
+#include <set>
+#include <list>
+#include <map>
+#include <iostream>
+
+class MESH;
+class CONNECTIVITY;
+class COORDINATE;
+class GROUP;
+
+struct _noeud
+{
+    mutable int number;
+    std::vector<double> coord;
+};
+
+struct _maille
+{
+    typedef std::map<int,_noeud>::iterator iter;
+    MED_EN::medGeometryElement geometricType;
+    std::vector< iter > sommets;
+    mutable unsigned ordre; // l'ordre est fixé après insertion dans le set, et ne change ni l'état, ni l'ordre -> mutable
+
+    _maille(MED_EN::medGeometryElement _geometricType, size_t nelem) : geometricType(_geometricType),ordre(0)
+    {
+       sommets.reserve(nelem);
+    };
+    int dimension() const // retourne la dimension de la maille
+    {
+       return geometricType/100;
+    };
+    bool operator < (const _maille& ma) const;
+    MED_EN::medEntityMesh getEntity(const int meshDimension) const throw (MEDEXCEPTION);
+};
+
+struct _mailleIteratorCompare // pour ordonner le set d'iterateurs sur mailles
+{
+    bool operator () (std::set<_maille>::iterator i1, std::set<_maille>::iterator i2)
+    {
+       return *i1<*i2;
+    }
+};
+
+struct _groupe
+{
+    typedef std::set< std::set<_maille>::iterator>::const_iterator mailleIter;
+    std::string nom;
+    std::set< std::set<_maille>::iterator, _mailleIteratorCompare > mailles; // iterateurs sur les mailles composant le groupe
+    std::list<int> groupes; // indices des sous-groupes composant le groupe
+};
+
+/*!
+ * \if developper
+ * Intermediate structure used by drivers to store data read from the other format file.
+ * The structure provides functions that transform the stored data to the MED format : 
+ * getCoordinate(), getConnectivity(), getGroups().
+ * The elements inserted in maillage and points are automaticaly ordered.
+ * Renumbering are performed by getConnectivity & getGroups before writing the MED structures.
+ * Read the conception ducumentation for more details.
+ * \endif
+ */
+struct _intermediateMED
+{
+    std::set<_maille> maillage;
+    std::vector<_groupe> groupes;
+    std::map< int, _noeud > points;
+
+    CONNECTIVITY * getConnectivity(); // set MED connectivity from the intermediate structure
+    COORDINATE * getCoordinate(); // set MED coordinate from the intermediate structure
+    void getGroups(std::vector<GROUP *> & _groupCell, std::vector<GROUP *> & _groupFace, std::vector<GROUP *> & _groupEdge, std::vector<GROUP *> & _groupNode, MESH * _ptrMesh);
+
+    // used by previous functions to renumber points & mesh.
+    void numerotationMaillage(); 
+    void numerotationPoints();
+
+};
+
+std::ostream& operator << (std::ostream& , const _maille& );
+std::ostream& operator << (std::ostream& , const _groupe& );
+std::ostream& operator << (std::ostream& , const _noeud& );
+std::ostream& operator << (std::ostream& , const _intermediateMED& );
+
+#endif /* DRIVERTOOLS_HXX */
index 9ca1920f2126fb40341284a69436c4a633f2ad22..3eb13e6856c06263502238f51bfd84e3070d2d08 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_DriversDef.cxx
-//  Module : MED
-
 using namespace std;
 #include "MEDMEM_DriversDef.hxx"
 
@@ -53,7 +27,14 @@ GEO_NAME::GEO_NAME() : map<int,string>()
   table[(int)MED_PYRA13 ] = "MED_PYRA13" ;
   assert( table.find( (int)MED_PYRA13 ) != table.end() ) ;
 }
-  
+GEO_NAME::~GEO_NAME()
+{
+  MESSAGE(" destructor GEO_NAME::~GEO_NAME() "<< size() );
+  clear();
+  MESSAGE(" end of destructor GEO_NAME::~GEO_NAME() "<< size() );
+}
 string & GEO_NAME::operator[]( const med_geometrie_element &c ) const
 {
   map<int,string> &table = (map<int,string>&)*this ;
@@ -73,6 +54,14 @@ ENT_NAME::ENT_NAME() : map<int,string>()
   table[(int)MED_ARETE  ] = "MED_ARETE";
   table[(int)MED_NOEUD  ] = "MED_NOEUD";
 }
+
+ENT_NAME::~ENT_NAME()
+{
+  MESSAGE(" destructor ENT_NAME::~ENT_NAME() "<< size() );
+  clear();
+  MESSAGE(" end of destructor ENT_NAME::~ENT_NAME() "<< size() );
+}
+
 string & ENT_NAME::operator[]( const med_entite_maillage &c ) const
 {
   map<int,string> &table = (map<int,string>&)*this ;
@@ -83,26 +72,47 @@ string & ENT_NAME::operator[]( const med_entite_maillage &c ) const
 MESH_ENTITIES::MESH_ENTITIES () : map<int, const list<med_geometrie_element> >() 
 {
   // Override the const declaration in order to used the find method below
-  map<int, const list<med_geometrie_element> > &table = (map<int, const list<med_geometrie_element> >&)*this ;
+  //  map<int, const list<med_geometrie_element> > &table = (map<int, const list<med_geometrie_element> >&)*this ; unused local variable
   
   // Initialize the value associated with the ROUGE_ key ( use the private operator = )
   {
-    const med_geometrie_element T[] =  { MED_POINT1,  MED_SEG2,  MED_SEG3,   MED_TRIA3,
-                                         MED_TRIA6,   MED_QUAD4, MED_QUAD8,  MED_TETRA4,
-                                         MED_TETRA10, MED_HEXA8, MED_HEXA20, MED_PENTA6,
-                                         MED_PENTA15,MED_PYRA5, MED_PYRA13 };
+    const med_geometrie_element T[] =  {
+      MED_POINT1,
+      MED_SEG2,
+      MED_SEG3,
+      MED_TRIA3,
+      MED_QUAD4,
+      MED_TRIA6,
+      MED_QUAD8,
+      MED_TETRA4,
+      MED_PYRA5,
+      MED_PENTA6,
+      MED_HEXA8,
+      MED_TETRA10,
+      MED_PYRA13,
+      MED_PENTA15,
+      MED_HEXA20};
+
     static const list<med_geometrie_element> geomList(T,T+sizeof(T)/sizeof(med_geometrie_element));   
     (*this)[MED_MAILLE] = geomList;
   }
   
   {
-    const med_geometrie_element T[] =  { MED_TRIA3,MED_TRIA6, MED_QUAD4,MED_QUAD8 };
+    const med_geometrie_element T[] =  {
+      MED_TRIA3,
+      MED_QUAD4,
+      MED_TRIA6,
+      MED_QUAD8};
+
     static const list<med_geometrie_element> geomList(T,T+sizeof(T)/sizeof(med_geometrie_element));   
     (*this)[MED_FACE] = geomList; 
   }
   
   {
-    const med_geometrie_element T[] =  { MED_SEG2,MED_SEG3 };
+    const med_geometrie_element T[] =  {
+      MED_SEG2,
+      MED_SEG3 };
+
     static const list<med_geometrie_element> geomList(T,T+sizeof(T)/sizeof(med_geometrie_element));   
     (*this)[MED_ARETE] = geomList; 
   }
@@ -116,6 +126,13 @@ MESH_ENTITIES::MESH_ENTITIES () : map<int, const list<med_geometrie_element> >()
   
 }
 
+MESH_ENTITIES::~MESH_ENTITIES()
+{
+  MESSAGE(" destructor MESH_ENTITIES::~MESH_ENTITIES() "<< size() );
+  clear();
+  MESSAGE(" end of destructor MESH_ENTITIES::~MESH_ENTITIES() "<< size() );
+}
+
 const list<med_geometrie_element> & MESH_ENTITIES::operator[]( const  med_entite_maillage &c ) const
 {
   map<int,const list<med_geometrie_element> > &table = (map<int,const list<med_geometrie_element> >&)*this ;
index 873bb8689808c9628b0ab3bfc6d0ef558657821b..c058d546ea06273f8d5600650eb7660713f15242 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_DriversDef.hxx
-//  Module : MED
-
 # ifndef DRIVERS_DEF_HXX
 # define DRIVERS_DEF_HXX
 
@@ -35,6 +9,7 @@
 using namespace std ;
 
 #include "MEDMEM_define.hxx"
+#include "utilities.h"
 namespace MED_FR 
 {
 
@@ -53,6 +28,7 @@ class GEO_NAME : public map<int,string>
 public :
   
   GEO_NAME();
+  ~GEO_NAME();
   string & operator[]( const MED_FR::med_geometrie_element &c ) const;
 } ;
 
@@ -76,6 +52,7 @@ class ENT_NAME : public map<int,string>
 public :
 
   ENT_NAME ();
+  ~ENT_NAME();
   string & operator[]( const MED_FR::med_entite_maillage &c ) const;
 } ;
 
@@ -100,6 +77,7 @@ class MESH_ENTITIES : public map<int, const list<MED_FR::med_geometrie_element>
 public :
 
   MESH_ENTITIES ();
+  ~MESH_ENTITIES();
   const list<MED_FR::med_geometrie_element> & operator[]( const  MED_FR::med_entite_maillage &c ) const;
   
 private:
index 915f4fc7569af51029a4f0e3b36ef52ff7d6dcfb..bafedca549e721db23b3508c47255457ade2bea9 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Exception.cxx
-//  Module : MED
-
 using namespace std;
 /*
  File MedException.cxx
index aa4245f61f29512fa1dbacce2684ed60d71df24d..e6eb49a4c36d0b6a0a2d9ee479bb3eecebc7c250 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Exception.hxx
-//  Module : MED
-
 /*
  File MedException.hxx
  $Header$
index d85fa5ec5bd78f8ddf9c10687d6dd9f927613b7c..45d647b2f11f81b3eb7f243e449a81ac5d3485f2 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Family.cxx
-//  Module : MED
-
 using namespace std;
 /*
  File MEDMEM_Family.cxx
index 02a40a72931cd9674c413c928eb740d75d6cae4a..2be15c6c0b2d5709e672ad4194ce30b72ce341d1 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Family.hxx
-//  Module : MED
-
 #ifndef FAMILY_HXX
 #define FAMILY_HXX
 
@@ -41,7 +15,7 @@
 
 */
 
-class FAMILY : public SUPPORT
+class FAMILY : virtual public SUPPORT
 {
 protected :
   /*!
@@ -98,6 +72,7 @@ public:
   /*!
     \if developper
     Constructor to use with med driver.
+    \endif
   */
   FAMILY( MESH* Mesh, int Identifier, string Name, 
          int NumberOfAttribute, int *AttributeIdentifier,
@@ -116,7 +91,7 @@ public:
   FAMILY(const SUPPORT & s);
 
                        /*! Destructor. */
-  ~FAMILY();
+  virtual ~FAMILY();
   FAMILY & operator=(const FAMILY &fam);
   friend ostream & operator<<(ostream &os, FAMILY &my) ;
 
index 18191c26d69b36f631fed5f5ccc090209fa0be9c..7c52fc42fe7377e5520d21fe9a2403a457a7e654 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Field.cxx
-//  Module : MED
-
 using namespace std;
 #include "MEDMEM_Field.hxx"
 
@@ -131,26 +105,176 @@ FIELD_::~FIELD_()
 
   MESSAGE("In this object FIELD_ there is(are) " << _drivers.size() << " driver(s)");
 
-  for (int index=0; index < _drivers.size(); index++ )
+  for (unsigned int index=0; index < _drivers.size(); index++ )
     {
       SCRUTE(_drivers[index]);
       if ( _drivers[index] != NULL) delete _drivers[index];
     }
 }
 
+/*! 
+  \if developper
+  PROVISOIRE : retourne des volumes, surfaces ou longueurs suivant les cas
+  \endif
+*/
+FIELD<double>* FIELD_::_getFieldSize() const
+{
+    FIELD<double>* p_field_size;
+    switch (getSupport()->getEntity())
+    {
+       case MED_CELL :
+           switch (getSupport()->getMesh()->getSpaceDimension() ) 
+           {
+               case 1:
+                   p_field_size=getSupport()->getMesh()->getLength(getSupport() );
+                   break;
+               case 2:
+                   p_field_size=getSupport()->getMesh()->getArea(getSupport() );
+                   break;
+               case 3:
+                   p_field_size=getSupport()->getMesh()->getVolume(getSupport() );
+                   break;
+           }
+           break;
+           
+       case MED_FACE :
+           p_field_size=getSupport()->getMesh()->getArea(getSupport() );
+           break;
+
+       case MED_EDGE :
+           p_field_size=getSupport()->getMesh()->getLength(getSupport() );
+           break;
+    }
+    return p_field_size;
+}
+
+
+/*! 
+  \if developper
+  Check up the compatibility of field before computing sobolev norm 
+  \endif
+*/
+void FIELD_::_checkNormCompatibility(const FIELD<double>* support_volume) const throw (MEDEXCEPTION)
+{
+    string diagnosis;
+    if( getSupport()->getEntity() == MED_NODE )
+    {
+       diagnosis="Cannot compute sobolev norm on a field "+getName()+
+           " : it has support on nodes!";
+       throw MEDEXCEPTION(diagnosis.c_str());
+    }
+       
+    if (getNumberOfValues()*getNumberOfComponents()<= 0) // Size of array has to be strictly positive
+    {
+       diagnosis="Cannot compute the norm of "+getName()+
+           " : it size is non positive!";
+       throw MEDEXCEPTION(diagnosis.c_str());
+    }
+
+    const int* nbGauss=getSupport()->getNumberOfGaussPoint();
+    for (int i=0; i<getSupport()->getNumberOfTypes(); ++i)
+       if(nbGauss[i]!=1)
+       {
+           diagnosis="Cannot compute Lnorm of "+getName()+
+           " : Gauss numbers greater than one are not yet implemented!";
+           throw MEDEXCEPTION(diagnosis.c_str());
+       }
+
+    if(support_volume) // if the user has supplied the volume
+    {
+       if(support_volume->getSupport()!=getSupport())
+       {
+           diagnosis="Cannot compute Lnorm of "+getName()+
+           " : the volume furnished has not the same support!";
+           throw MEDEXCEPTION(diagnosis.c_str());
+       }
+       if(support_volume->getNumberOfValues()!=getNumberOfValues())
+       {
+           diagnosis="Cannot compute Lnorm of "+getName()+
+           " : the volume furnished has not the same number of values!";
+           throw MEDEXCEPTION(diagnosis.c_str());
+       }
+    }
+
+}
+
+/*! 
+  \if developper
+   Check up the compatibility of fields before performing an arithmetic operation
+  \endif
+*/
+void FIELD_::_checkFieldCompatibility(const FIELD_& m, const FIELD_& n ) throw (MEDEXCEPTION)
+{
+    string diagnosis;
+
+    // check-up, fill diagnosis if some incompatibility is found.
+    if(m._support != n._support)
+       diagnosis+="They don't have the same support!";
+    else if(m._numberOfComponents != n._numberOfComponents)
+       diagnosis+="They don't have the same number of components!";
+    else if(m._numberOfValues != n._numberOfValues)
+       diagnosis+="They don't have the same number of values!";
+    else
+    {
+       for(int i=0; i<m._numberOfComponents; i++)
+       {
+// Not yet implemented   
+//         if(m._componentsTypes[i] != n._componentsTypes[i])
+//         {
+//             diagnosis+="Components don't have the same types!";
+//             break;
+//         }
+           if(m._MEDComponentsUnits[i] != n._MEDComponentsUnits[i])
+           {
+               diagnosis+="Components don't have the same units!";
+               break;
+           }
+       }
+    }
+
+    if(diagnosis.size()) // if fields are not compatible : complete diagnosis and throw exception
+    {
+       diagnosis="Field's operation not allowed!\nThe fields " + m._name + " and " 
+                + n._name + " are not compatible.\n" + diagnosis;
+       throw MEDEXCEPTION(diagnosis.c_str());
+    }
+
+    if( m.getNumberOfValues()<=0 || m.getNumberOfComponents()<=0) // check up the size is strictly positive
+    {
+       diagnosis="Field's operation not allowed!\nThe fields " + m._name + " and " 
+                + n._name + " are empty! (size<=0).\n";
+       throw MEDEXCEPTION(diagnosis.c_str());
+    }
+
+}
+
 //  void     FIELD_::setIterationNumber (int IterationNumber)           {};
 //  void     FIELD_::setOrderNumber     (int OrderNumber)               {}; 
 //  void     FIELD_::setFieldName       (string& fieldName)             {}; 
          
-void     FIELD_::rmDriver      (int index)                            {};
+void     FIELD_::rmDriver      (int index)
+{
+  MESSAGE("void FIELD_::rmDriver(int index) : removing the driver " << index);
+};
 int      FIELD_::addDriver     (driverTypes driverType, 
                                 const string & fileName,
-                               const string & driverFieldName)       {};
-int      FIELD_::addDriver     (GENDRIVER & driver)                   {};
+                               const string & driverFieldName)
+{
+  MESSAGE("int FIELD_::addDriver(driverTypes driverType, const string & fileName, const string & driverFieldName) : adding the driver " << driverType << " fileName = " << fileName.c_str() << " driverFieldName = " << driverFieldName.c_str());
+  return 0;
+};
+int      FIELD_::addDriver     (GENDRIVER & driver)
+{
+  MESSAGE("int FIELD_::addDriver(GENDRIVER & driver) : driver " << driver);
+  return 0;
+};
+void     FIELD_::openAppend    ( void )                               {};
 void     FIELD_::write         (const GENDRIVER &)                    {};
+void     FIELD_::writeAppend   (const GENDRIVER &)                    {};
 void     FIELD_::read          (const GENDRIVER &)                    {};
-void     FIELD_::write         (int index, const string & driverName) {};
-void     FIELD_::read          (int index)                                  {};
+void     FIELD_::write         (int , const string & ) {};
+void     FIELD_::writeAppend   (int , const string & ) {};
+void     FIELD_::read          (int )                                  {};
 
 //  void                     FIELD_::setValueType(med_type_champ ValueType) {};
 //  med_type_champ FIELD_::getValueType() {};
index 419c10a4dff73742efa841bc05fd942eff878fe4..b1127f69de2ed0cdeb0e977f28f6857c53bcb688 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Field.hxx
-//  Module : MED
-
 /*
  File Field.hxx
  $Header$
@@ -33,6 +7,8 @@
 #define FIELD_HXX
 
 #include <vector>
+#include <algorithm>
+#include <cmath>
 
 #include "utilities.h"
 #include "MEDMEM_Exception.hxx"
@@ -46,6 +22,9 @@
 #include "MEDMEM_MedFieldDriver.hxx"
 #include "MEDMEM_MedMedDriver.hxx"
 
+#include "MEDMEM_VtkFieldDriver.hxx"
+#include "MEDMEM_VtkMedDriver.hxx"
+
 using namespace MED_EN;
 
 /*!
@@ -143,9 +122,17 @@ protected:
   double         _time;
   int            _orderNumber ;
 
+  // _valueType should be a static const. Here is an initialization exemple 
+  // template < classType T > struct SET_VALUE_TYPE { static const med_type_champ _valueType = 0; }
+  // template < > struct SET_VALUE_TYPE<double> { static const med_type_champ _valueType = MED_EN::MED_REEL64; }
+  // template < > struct SET_VALUE_TYPE<int> { static const med_type_champ _valueType = MED_EN::MED_INT32; }
+  // static const med_type_champ _valueType = SET_VALUE_TYPE <T>::_valueType;
   med_type_champ _valueType ;
 
   vector<GENDRIVER *> _drivers; // Storage of the drivers currently in use
+  static void _checkFieldCompatibility(const FIELD_& m, const FIELD_& n ) throw (MEDEXCEPTION);
+  void _checkNormCompatibility(const FIELD<double>* p_field_volume=NULL) const  throw (MEDEXCEPTION);
+  FIELD<double>* _getFieldSize() const;
 
 public:
 
@@ -153,6 +140,8 @@ public:
   friend class MED_MED_WRONLY_DRIVER;
   friend class MED_MED_RDWR_DRIVER;
 
+  friend class VTK_MED_DRIVER;
+
   /*!
     Constructor.
   */
@@ -169,7 +158,7 @@ public:
   /*!
     Destructor.
   */
-  ~FIELD_();
+  virtual ~FIELD_();
 
 //    virtual  void     setIterationNumber (int IterationNumber);
 //    virtual  void     setOrderNumber     (int OrderNumber);
@@ -182,37 +171,41 @@ public:
   virtual  int      addDriver( GENDRIVER & driver);
   virtual  void     read (const GENDRIVER &);
   virtual  void     read(int index=0);
+  virtual void openAppend( void );
   virtual  void     write(const GENDRIVER &);
   virtual  void     write(int index=0, const string & driverName="");
 
-  inline void     setName(string Name);
+  virtual  void     writeAppend(const GENDRIVER &);
+  virtual  void     writeAppend(int index=0, const string & driverName="");
+
+  inline void     setName(const string Name);
   inline string   getName() const;
-  inline void     setDescription(string Description);
+  inline void     setDescription(const string Description);
   inline string   getDescription() const;
   inline const SUPPORT * getSupport() const;
-  inline void     setSupport(SUPPORT * support);
-  inline void     setNumberOfComponents(int NumberOfComponents);
+  inline void     setSupport(const SUPPORT * support);
+  inline void     setNumberOfComponents(const int NumberOfComponents);
   inline int      getNumberOfComponents() const;
-  inline void     setNumberOfValues(int NumberOfValues);
+  inline void     setNumberOfValues(const int NumberOfValues);
   inline int      getNumberOfValues() const;
   //    inline void     setComponentType(int *ComponentType);
   //    inline int *    getComponentType() const;
   //    inline int      getComponentTypeI(int i) const;
-  inline void     setComponentsNames(string * ComponentsNames);
-  inline void     setComponentName(int i, string ComponentName);
+  inline void     setComponentsNames(const string * ComponentsNames);
+  inline void     setComponentName(int i, const string ComponentName);
   inline const string * getComponentsNames() const;
   inline string   getComponentName(int i) const;
-  inline void     setComponentsDescriptions(string *ComponentsDescriptions);
-  inline void     setComponentDescription(int i, string ComponentDescription);
+  inline void     setComponentsDescriptions(const string * ComponentsDescriptions);
+  inline void     setComponentDescription(int i, const string ComponentDescription);
   inline const string * getComponentsDescriptions() const;
   inline string   getComponentDescription(int i) const;
 
   // provisoire : en attendant de regler le probleme des unites !
-  inline void     setComponentsUnits(UNIT * ComponentsUnits);
+  inline void     setComponentsUnits(const UNIT * ComponentsUnits);
   inline const UNIT *   getComponentsUnits() const;
   inline const UNIT *   getComponentUnit(int i) const;
-  inline void     setMEDComponentsUnits(string * MEDComponentsUnits);
-  inline void     setMEDComponentUnit(int i, string MEDComponentUnit);
+  inline void     setMEDComponentsUnits(const string * MEDComponentsUnits);
+  inline void     setMEDComponentUnit(int i, const string MEDComponentUnit);
   inline const string * getMEDComponentsUnits() const;
   inline string   getMEDComponentUnit(int i) const;
 
@@ -223,7 +216,7 @@ public:
   inline void     setOrderNumber(int OrderNumber);
   inline int      getOrderNumber() const;
 
-  inline void     setValueType (med_type_champ ValueType) ;
+  inline void     setValueType (const med_type_champ ValueType) ;
   inline med_type_champ getValueType () const;
 
 };
@@ -238,7 +231,7 @@ public:
 /*!
   Set FIELD name.
 */
-inline void FIELD_::setName(string Name)
+inline void FIELD_::setName(const string Name)
 {
   _name=Name;
 }
@@ -252,7 +245,7 @@ inline string FIELD_::getName() const
 /*!
   Set FIELD description.
 */
-inline void FIELD_::setDescription(string Description)
+inline void FIELD_::setDescription(const string Description)
 {
   _description=Description;
 }
@@ -313,7 +306,7 @@ inline int FIELD_::getNumberOfValues() const
   Duplicate the ComponentsNames string array to put components names in
   FIELD. ComponentsNames size must be equal to number of components.
 */
-inline void FIELD_::setComponentsNames(string * ComponentsNames)
+inline void FIELD_::setComponentsNames(const string * ComponentsNames)
 {
   if (NULL == _componentsNames)
     _componentsNames = new string[_numberOfComponents] ;
@@ -325,7 +318,7 @@ inline void FIELD_::setComponentsNames(string * ComponentsNames)
 
   i must be >=1 and <= number of components.
 */
-inline void FIELD_::setComponentName(int i, string ComponentName)
+inline void FIELD_::setComponentName(int i, const string ComponentName)
 {
   _componentsNames[i-1]=ComponentName ;
 }
@@ -352,7 +345,7 @@ inline string FIELD_::getComponentName(int i) const
   descriptions in FIELD.
   ComponentsDescriptions size must be equal to number of components.
 */
-inline void FIELD_::setComponentsDescriptions(string *ComponentsDescriptions)
+inline void FIELD_::setComponentsDescriptions(const string * ComponentsDescriptions)
 {
   if (NULL == _componentsDescriptions)
     _componentsDescriptions = new string[_numberOfComponents] ;
@@ -364,7 +357,7 @@ inline void FIELD_::setComponentsDescriptions(string *ComponentsDescriptions)
 
   i must be >=1 and <= number of components.
 */
-inline void FIELD_::setComponentDescription(int i,string ComponentDescription)
+inline void FIELD_::setComponentDescription(int i,const string ComponentDescription)
 {
   _componentsDescriptions[i-1]=ComponentDescription ;
 }
@@ -393,7 +386,7 @@ inline string FIELD_::getComponentDescription(int i) const
   units in FIELD.
   ComponentsUnits size must be equal to number of components.
 */
-inline void FIELD_::setComponentsUnits(UNIT * ComponentsUnits)
+inline void FIELD_::setComponentsUnits(const UNIT * ComponentsUnits)
 {
   if (NULL == _componentsUnits)
     _componentsUnits = new UNIT[_numberOfComponents] ;
@@ -424,7 +417,7 @@ inline const UNIT * FIELD_::getComponentUnit(int i) const
   MEDComponentsUnits size must be equal to number of components.
   
 */
-inline void FIELD_::setMEDComponentsUnits(string * MEDComponentsUnits)
+inline void FIELD_::setMEDComponentsUnits(const string * MEDComponentsUnits)
 {
   if (NULL == _MEDComponentsUnits)
     _MEDComponentsUnits = new string[_numberOfComponents] ;
@@ -436,7 +429,7 @@ inline void FIELD_::setMEDComponentsUnits(string * MEDComponentsUnits)
 
   i must be >=1 and <= number of components.
 */
-inline void FIELD_::setMEDComponentUnit(int i, string MEDComponentUnit)
+inline void FIELD_::setMEDComponentUnit(int i, const string MEDComponentUnit)
 {
   _MEDComponentsUnits[i-1]=MEDComponentUnit ;
 }
@@ -512,7 +505,7 @@ inline  const SUPPORT * FIELD_::getSupport() const
 
   Reference is not duplicate, so it must not be deleted.
 */
-inline void FIELD_::setSupport(SUPPORT * support)
+inline void FIELD_::setSupport(const SUPPORT * support)
 {
   _support = support ;
 }
@@ -526,7 +519,7 @@ inline med_type_champ FIELD_::getValueType () const
 /*!
   Set the FIELD med value type (MED_INT32 or MED_REEL64).
 */
-inline void FIELD_::setValueType (med_type_champ ValueType)
+inline void FIELD_::setValueType (const med_type_champ ValueType)
 {
   _valueType = ValueType ;
 }
@@ -569,6 +562,8 @@ protected:
 
   //    static INSTANCE_DE<MED_FIELD_RDONLY_DRIVER> inst_med_rdonly ;
   static INSTANCE_DE<MED_FIELD_RDWR_DRIVER<T> >   inst_med ;
+  static INSTANCE_DE<VTK_FIELD_DRIVER<T> >   inst_vtk ;
+
   static const INSTANCE * const instances[] ;
 
   // ------ End of Drivers Management Part
@@ -577,19 +572,52 @@ protected:
   MEDARRAY<T> *_value ;
 
 private:
+  void _operation(const FIELD& m,const FIELD& n, const medModeSwitch mode, char* Op);
+  void _operationInitialize(const FIELD& m,const FIELD& n, char* Op);
+  void _add_in_place(const FIELD& m,const FIELD& n, const medModeSwitch mode);
+  void _sub_in_place(const FIELD& m,const FIELD& n, const medModeSwitch mode);
+  void _mul_in_place(const FIELD& m,const FIELD& n, const medModeSwitch mode);
+  void _div_in_place(const FIELD& m,const FIELD& n, const medModeSwitch mode);
   //setValueType() ;
 
 public:
   FIELD();
   FIELD(const FIELD &m);
   FIELD & operator=(const FIELD &m);   // A FAIRE
-  FIELD(const SUPPORT * Support, const int NumberOfComponents); // Ajout NB Constructeur FIELD avec allocation de memoire de tous ses attribut
+  FIELD(const SUPPORT * Support, const int NumberOfComponents, const medModeSwitch Mode=MED_FULL_INTERLACE)  throw (MEDEXCEPTION) ; // Ajout NB Constructeur FIELD avec allocation de memoire de tous ses attribut
   FIELD(const SUPPORT * Support, driverTypes driverType,
-       const string & fileName="", const string & fieldName="");
+       const string & fileName="", const string & fieldName="",
+       const int iterationNumber = -1, const int orderNumber = -1)
+    throw (MEDEXCEPTION);
   ~FIELD();
 
+  const FIELD operator+(const FIELD& m) const;
+  const FIELD operator-(const FIELD& m) const;
+  const FIELD operator*(const FIELD& m) const;
+  const FIELD operator/(const FIELD& m) const;
+  const FIELD operator-() const;
+  FIELD& operator+=(const FIELD& m);
+  FIELD& operator-=(const FIELD& m);
+  FIELD& operator*=(const FIELD& m);
+  FIELD& operator/=(const FIELD& m);
+  static FIELD* add(const FIELD& m, const FIELD& n);
+  static FIELD* sub(const FIELD& m, const FIELD& n);
+  static FIELD* mul(const FIELD& m, const FIELD& n);
+  static FIELD* div(const FIELD& m, const FIELD& n);
+  double normMax() const throw (MEDEXCEPTION);
+  double norm2() const throw (MEDEXCEPTION);
+  void   applyLin(T a, T b);
+  template <T T_function(T)> void applyFunc();
+  static FIELD* scalarProduct(const FIELD& m, const FIELD& n);
+  double normL2(int component, const FIELD<double> * p_field_volume=NULL) const;
+  double normL2(const FIELD<double> * p_field_volume=NULL) const;
+  double normL1(int component, const FIELD<double> * p_field_volume=NULL) const;
+  double normL1(const FIELD<double> * p_field_volume=NULL) const;
+
   friend class MED_FIELD_RDONLY_DRIVER<T>;
   friend class MED_FIELD_WRONLY_DRIVER<T>;
+
+  friend class VTK_FIELD_DRIVER<T>;
   //friend class MED_FIELD_RDWR_DRIVER  <T>;
 
   void init ();
@@ -609,6 +637,9 @@ public:
   inline void write(int index=0, const string & driverName = "");
   inline void write(const GENDRIVER &);
 
+  inline void writeAppend(int index=0, const string & driverName = "");
+  inline void writeAppend(const GENDRIVER &);
+
   inline void     setValue(MEDARRAY<T> *Value);
 
   inline MEDARRAY<T>* getvalue() const;
@@ -678,7 +709,7 @@ public:
 // --------------------
 
 /*!
-  Constructor.
+  Constructor with no parameter, most of the attribut members are set to NULL.
 */
 template <class T>  FIELD<T>::FIELD():
  _value((MEDARRAY<T>*)NULL)
@@ -687,13 +718,15 @@ template <class T>  FIELD<T>::FIELD():
 }
 
 /*!
-  Constructor.
+  Constructor with parameters such that all attrribut are set but the _value
+  attrribut is allocated but not set.
 */
 template <class T>  FIELD<T>::FIELD(const SUPPORT * Support,
-                                   const int NumberOfComponents):
+                                   const int NumberOfComponents, const medModeSwitch Mode) throw (MEDEXCEPTION) :
   FIELD_(Support, NumberOfComponents)
 {
-  BEGIN_OF("FIELD<T>::FIELD(const SUPPORT * Support, const int NumberOfComponents)");
+  BEGIN_OF("FIELD<T>::FIELD(const SUPPORT * Support, const int NumberOfComponents, const medModeSwitch Mode)");
+  SCRUTE(this);
 
   try {
     _numberOfValues = Support->getNumberOfElements(MED_ALL_ELEMENTS);
@@ -704,12 +737,12 @@ template <class T>  FIELD<T>::FIELD(const SUPPORT * Support,
   }
   MESSAGE("FIELD : constructeur : "<< _numberOfValues <<" et "<< NumberOfComponents);
   if (0<_numberOfValues) {
-    _value = new MEDARRAY<T>::MEDARRAY(_numberOfComponents,_numberOfValues);
+    _value = new MEDARRAY<T>(_numberOfComponents,_numberOfValues,Mode);
     _isRead = true ;
   } else
     _value = (MEDARRAY<T>*)NULL ;
 
-  END_OF("FIELD<T>::FIELD(const SUPPORT * Support, const int NumberOfComponents)");
+  END_OF("FIELD<T>::FIELD(const SUPPORT * Support, const int NumberOfComponents, const medModeSwitch Mode)");
 }
 
 /*!
@@ -726,10 +759,11 @@ template <class T> void FIELD<T>::init ()
 template <class T> FIELD<T>::FIELD(const FIELD & m):
   FIELD_((FIELD_) m)
 {
+  MESSAGE("Constructeur FIELD de recopie");
   if (m._value != NULL)
     {
       // copie only default !
-      _value = new MEDARRAY<T>::MEDARRAY(* m._value,false);
+      _value = new MEDARRAY<T>(* m._value,false);
     }
   else
     _value = (MEDARRAY<T> *) NULL;
@@ -741,17 +775,872 @@ template <class T> FIELD<T>::FIELD(const FIELD & m):
 */
 template <class T> FIELD<T> & FIELD<T>::operator=(const FIELD &m)
 {
+  MESSAGE("Appel de FIELD<T>::operator=");
+}
+
+/*!
+     Overload addition operator.
+     This operation is authorized only for compatible fields that have the same support.
+     The compatibility checking includes equality tests of the folowing data members:/n
+     - _support
+     - _numberOfComponents
+     - _numberOfValues
+     - _componentsTypes
+     - _MEDComponentsUnits.
+
+     The data members of the returned field are initialized, based on the first field, except for the name, 
+     which is the combination of the two field's names and the operator.
+     Advised Utilisation in C++ : <tt> FIELD<T> c = a + b; </tt> /n
+     In this case, the (recent) compilators perform optimisation and don't call the copy constructor.
+     When using python, this operator calls the copy constructor in any case.
+     The user has to be aware that when using operator + in associatives expressions like
+     <tt> a = b + c + d +e; </tt> /n
+     no optimisation is performed : the evaluation of last expression requires the construction of
+     3 temporary fields.
+*/
+template <class T>
+const FIELD<T> FIELD<T>::operator+(const FIELD & m) const
+{
+    BEGIN_OF("FIELD<T>::operator+(const FIELD & m)");
+    FIELD_::_checkFieldCompatibility(*this, m); // may throw exception
+
+    // Select mode : avoid if possible any calculation of other mode for fields m or *this
+    medModeSwitch mode;
+    if(this->getvalue()->getMode()==m.getvalue()->getMode() || this->getvalue()->isOtherCalculated())
+       mode=m.getvalue()->getMode();
+    else
+       mode=this->getvalue()->getMode();
+    
+    // Creation of the result - memory is allocated by FIELD constructor
+    FIELD<T> result(this->getSupport(),this->getNumberOfComponents(),mode);
+    //result._operation(*this,m,mode,"+"); // perform Atribute's initialization & addition
+    result._operationInitialize(*this,m,"+"); // perform Atribute's initialization
+    result._add_in_place(*this,m,mode); // perform addition
+
+    END_OF("FIELD<T>::operator+(const FIELD & m)");
+    return result;
+}
+
+/*!  Overloaded Operator +=
+ *   Operations are directly performed in the first field's array.
+ *   This operation is authorized only for compatible fields that have the same support.
+ */
+template <class T>
+FIELD<T>& FIELD<T>::operator+=(const FIELD & m)
+{
+    BEGIN_OF("FIELD<T>::operator+=(const FIELD & m)");
+    FIELD_::_checkFieldCompatibility(*this, m); // may throw exception
+
+    // We choose to keep *this mode, even if it may cost a re-calculation for m
+    medModeSwitch mode=this->getvalue()->getMode();
+    const T* value1=m.getValue(mode); // get pointers to the values we are adding
+
+    // get a non const pointer to the inside array of values and perform operation
+    T * value=const_cast<T *> (getValue(mode));
+    const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
+    const T* endV=value+size; // pointer to the end of value
+    for(;value!=endV; value1++,value++)
+       *value += *value1;
+    // if it exists, the alternate mode needs to be cleared because it is not up-to-date anymore
+    this->getvalue()->clearOtherMode();
+    END_OF("FIELD<T>::operator+=(const FIELD & m)");
+    return *this;
+}
+
+
+/*! Addition of fields. Static member function.
+ *  The function return a pointer to a new created field that holds the addition.
+ *  Data members are checked for compatibility and initialized.
+ *  The user is in charge of memory deallocation.
+ */
+template <class T>
+FIELD<T>* FIELD<T>::add(const FIELD& m, const FIELD& n)
+{
+    BEGIN_OF("FIELD<T>::add(const FIELD & m, const FIELD& n)");
+    FIELD_::_checkFieldCompatibility(m, n); // may throw exception
+
+    // Select mode : avoid if possible any calculation of other mode for fields m or *this
+    medModeSwitch mode;
+    if(m.getvalue()->getMode()==n.getvalue()->getMode() || n.getvalue()->isOtherCalculated())
+       mode=m.getvalue()->getMode();
+    else
+       mode=n.getvalue()->getMode();
+    
+    // Creation of a new field
+    FIELD<T>* result = new FIELD<T>(m.getSupport(),m.getNumberOfComponents(),mode);
+    result->_operationInitialize(m,n,"+"); // perform Atribute's initialization
+    result->_add_in_place(m,n,mode); // perform addition
+
+    END_OF("FIELD<T>::add(const FIELD & m, const FIELD& n)");
+    return result;
+}
+
+/*!
+     Overload substraction operator.
+     This operation is authorized only for compatible fields that have the same support.
+     The compatibility checking includes equality tests of the folowing data members:/n
+     - _support
+     - _numberOfComponents
+     - _numberOfValues
+     - _componentsTypes
+     - _MEDComponentsUnits.
+
+     The data members of the returned field are initialized, based on the first field, except for the name, 
+     which is the combination of the two field's names and the operator.
+     Advised Utilisation in C++ : <tt> FIELD<T> c = a - b; </tt> /n
+     In this case, the (recent) compilators perform optimisation and don't call the copy constructor.
+     When using python, this operator calls the copy constructor in any case.
+     The user has to be aware that when using operator - in associatives expressions like
+     <tt> a = b - c - d -e; </tt> /n
+     no optimisation is performed : the evaluation of last expression requires the construction of
+     3 temporary fields.
+*/
+template <class T>
+const FIELD<T> FIELD<T>::operator-(const FIELD & m) const
+{
+    BEGIN_OF("FIELD<T>::operator-(const FIELD & m)");
+    FIELD_::_checkFieldCompatibility(*this, m); // may throw exception
+
+    // Select mode : avoid if possible any calculation of other mode for fields m or *this
+    medModeSwitch mode;
+    if(this->getvalue()->getMode()==m.getvalue()->getMode() || this->getvalue()->isOtherCalculated())
+       mode=m.getvalue()->getMode();
+    else
+       mode=this->getvalue()->getMode();
+    
+    // Creation of the result - memory is allocated by FIELD constructor
+    FIELD<T> result(this->getSupport(),this->getNumberOfComponents(),mode);
+    //result._operation(*this,m,mode,"-"); // perform Atribute's initialization & substraction
+    result._operationInitialize(*this,m,"-"); // perform Atribute's initialization
+    result._sub_in_place(*this,m,mode); // perform substracion
+
+    END_OF("FIELD<T>::operator-(const FIELD & m)");
+    return result;
+}
+
+template <class T>
+const FIELD<T> FIELD<T>::operator-() const
+{
+    BEGIN_OF("FIELD<T>::operator-()");
+
+    medModeSwitch mode=this->getvalue()->getMode();
+    // Creation of the result - memory is allocated by FIELD constructor
+    FIELD<T> result(this->getSupport(),this->getNumberOfComponents(),mode);
+    // Atribute's initialization 
+    result.setName("- "+getName());
+    result.setComponentsNames(getComponentsNames());
+    // not yet implemented    setComponentType(getComponentType());
+    result.setComponentsDescriptions(getComponentsDescriptions());
+    result.setMEDComponentsUnits(getMEDComponentsUnits());
+    result.setComponentsUnits(getComponentsUnits());
+    result.setIterationNumber(getIterationNumber());
+    result.setTime(getTime());
+    result.setOrderNumber(getOrderNumber());
+    result.setValueType(getValueType());
+
+    const T* value1=getValue(mode); 
+    // get a non const pointer to the inside array of values and perform operation
+    T * value=const_cast<T *> (result.getValue(mode));
+    const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
+    const T* endV=value+size; // pointer to the end of value
+
+    for(;value!=endV; value1++,value++)
+       *value = -(*value1);
+    END_OF("FIELD<T>::operator-=(const FIELD & m)");
+    return result;
+}
+
+/*!  Overloaded Operator -=
+ *   Operations are directly performed in the first field's array.
+ *   This operation is authorized only for compatible fields that have the same support.
+ */
+template <class T>
+FIELD<T>& FIELD<T>::operator-=(const FIELD & m)
+{
+    BEGIN_OF("FIELD<T>::operator-=(const FIELD & m)");
+    FIELD_::_checkFieldCompatibility(*this, m); // may throw exception
+
+    // We choose to keep *this mode, even if it may cost a re-calculation for m
+    medModeSwitch mode=this->getvalue()->getMode();
+    const T* value1=m.getValue(mode); // get pointers to the values we are adding
+
+    // get a non const pointer to the inside array of values and perform operation
+    T * value=const_cast<T *> (getValue(mode));
+    const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
+    const T* endV=value+size; // pointer to the end of value
+
+    for(;value!=endV; value1++,value++)
+       *value -= *value1;
+    // if it exists, the alternate mode needs to be cleared because it is not up-to-date anymore
+    this->getvalue()->clearOtherMode();
+    END_OF("FIELD<T>::operator-=(const FIELD & m)");
+    return *this;
+}
+
+
+/*! Substraction of fields. Static member function.
+ *  The function return a pointer to a new created field that holds the substraction.
+ *  Data members are checked for compatibility and initialized.
+ *  The user is in charge of memory deallocation.
+ */
+template <class T>
+FIELD<T>* FIELD<T>::sub(const FIELD& m, const FIELD& n)
+{
+    BEGIN_OF("FIELD<T>::sub(const FIELD & m, const FIELD& n)");
+    FIELD_::_checkFieldCompatibility(m, n); // may throw exception
+
+    // Select mode : avoid if possible any calculation of other mode for fields m or *this
+    medModeSwitch mode;
+    if(m.getvalue()->getMode()==n.getvalue()->getMode() || n.getvalue()->isOtherCalculated())
+       mode=m.getvalue()->getMode();
+    else
+       mode=n.getvalue()->getMode();
+    
+    // Creation of a new field
+    FIELD<T>* result = new FIELD<T>(m.getSupport(),m.getNumberOfComponents(),mode);
+    result->_operationInitialize(m,n,"-"); // perform Atribute's initialization
+    result->_sub_in_place(m,n,mode); // perform substraction
+
+    END_OF("FIELD<T>::sub(const FIELD & m, const FIELD& n)");
+    return result;
+}
+
+/*!
+     Overload multiplication operator.
+     This operation is authorized only for compatible fields that have the same support.
+     The compatibility checking includes equality tests of the folowing data members:/n
+     - _support
+     - _numberOfComponents
+     - _numberOfValues
+     - _componentsTypes
+     - _MEDComponentsUnits.
+
+     The data members of the returned field are initialized, based on the first field, except for the name, 
+     which is the combination of the two field's names and the operator.
+     Advised Utilisation in C++ : <tt> FIELD<T> c = a * b; </tt> /n
+     In this case, the (recent) compilators perform optimisation and don't call the copy constructor.
+     When using python, this operator calls the copy constructor in any case.
+     The user has to be aware that when using operator * in associatives expressions like
+     <tt> a = b * c * d *e; </tt> /n
+     no optimisation is performed : the evaluation of last expression requires the construction of
+     3 temporary fields.
+*/
+template <class T>
+const FIELD<T> FIELD<T>::operator*(const FIELD & m) const
+{
+    BEGIN_OF("FIELD<T>::operator*(const FIELD & m)");
+    FIELD_::_checkFieldCompatibility(*this, m); // may throw exception
+
+    // Select mode : avoid if possible any calculation of other mode for fields m or *this
+    medModeSwitch mode;
+    if(this->getvalue()->getMode()==m.getvalue()->getMode() || this->getvalue()->isOtherCalculated())
+       mode=m.getvalue()->getMode();
+    else
+       mode=this->getvalue()->getMode();
+    
+    // Creation of the result - memory is allocated by FIELD constructor
+    FIELD<T> result(this->getSupport(),this->getNumberOfComponents(),mode);
+    //result._operation(*this,m,mode,"*"); // perform Atribute's initialization & multiplication
+    result._operationInitialize(*this,m,"*"); // perform Atribute's initialization
+    result._mul_in_place(*this,m,mode); // perform multiplication
+
+    END_OF("FIELD<T>::operator*(const FIELD & m)");
+    return result;
+}
+
+/*!  Overloaded Operator *=
+ *   Operations are directly performed in the first field's array.
+ *   This operation is authorized only for compatible fields that have the same support.
+ */
+template <class T>
+FIELD<T>& FIELD<T>::operator*=(const FIELD & m)
+{
+    BEGIN_OF("FIELD<T>::operator*=(const FIELD & m)");
+    FIELD_::_checkFieldCompatibility(*this, m); // may throw exception
+
+    // We choose to keep *this mode, even if it may cost a re-calculation for m
+    medModeSwitch mode=this->getvalue()->getMode();
+    const T* value1=m.getValue(mode); // get pointers to the values we are adding
+
+    // get a non const pointer to the inside array of values and perform operation
+    T * value=const_cast<T *> (getValue(mode));
+    const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
+    const T* endV=value+size; // pointer to the end of value
+
+    for(;value!=endV; value1++,value++)
+       *value *= *value1;
+    // if it exists, the alternate mode needs to be cleared because it is not up-to-date anymore
+    this->getvalue()->clearOtherMode();
+    END_OF("FIELD<T>::operator*=(const FIELD & m)");
+    return *this;
+}
+
+
+/*! Multiplication of fields. Static member function.
+ *  The function return a pointer to a new created field that holds the multiplication.
+ *  Data members are checked for compatibility and initialized.
+ *  The user is in charge of memory deallocation.
+ */
+template <class T>
+FIELD<T>* FIELD<T>::mul(const FIELD& m, const FIELD& n)
+{
+    BEGIN_OF("FIELD<T>::mul(const FIELD & m, const FIELD& n)");
+    FIELD_::_checkFieldCompatibility(m, n); // may throw exception
+
+    // Select mode : avoid if possible any calculation of other mode for fields m or *this
+    medModeSwitch mode;
+    if(m.getvalue()->getMode()==n.getvalue()->getMode() || n.getvalue()->isOtherCalculated())
+       mode=m.getvalue()->getMode();
+    else
+       mode=n.getvalue()->getMode();
+    
+    // Creation of a new field
+    FIELD<T>* result = new FIELD<T>(m.getSupport(),m.getNumberOfComponents(),mode);
+    result->_operationInitialize(m,n,"*"); // perform Atribute's initialization
+    result->_mul_in_place(m,n,mode); // perform multiplication
+
+    END_OF("FIELD<T>::mul(const FIELD & m, const FIELD& n)");
+    return result;
+}
+
+
+/*!
+     Overload division operator.
+     This operation is authorized only for compatible fields that have the same support.
+     The compatibility checking includes equality tests of the folowing data members:/n
+     - _support
+     - _numberOfComponents
+     - _numberOfValues
+     - _componentsTypes
+     - _MEDComponentsUnits.
+
+     The data members of the returned field are initialized, based on the first field, except for the name, 
+     which is the combination of the two field's names and the operator.
+     Advised Utilisation in C++ : <tt> FIELD<T> c = a / b; </tt> /n
+     In this case, the (recent) compilators perform optimisation and don't call the copy constructor.
+     When using python, this operator calls the copy constructor in any case.
+     The user has to be aware that when using operator / in associatives expressions like
+     <tt> a = b / c / d /e; </tt> /n
+     no optimisation is performed : the evaluation of last expression requires the construction of
+     3 temporary fields.
+*/
+template <class T>
+const FIELD<T> FIELD<T>::operator/(const FIELD & m) const
+{
+    BEGIN_OF("FIELD<T>::operator/(const FIELD & m)");
+    FIELD_::_checkFieldCompatibility(*this, m); // may throw exception
+
+    // Select mode : avoid if possible any calculation of other mode for fields m or *this
+    medModeSwitch mode;
+    if(this->getvalue()->getMode()==m.getvalue()->getMode() || this->getvalue()->isOtherCalculated())
+       mode=m.getvalue()->getMode();
+    else
+       mode=this->getvalue()->getMode();
+    
+    // Creation of the result - memory is allocated by FIELD constructor
+    FIELD<T> result(this->getSupport(),this->getNumberOfComponents(),mode);
+    //result._operation(*this,m,mode,"/"); // perform Atribute's initialization & division
+    result._operationInitialize(*this,m,"/"); // perform Atribute's initialization
+    result._div_in_place(*this,m,mode); // perform division
+
+    END_OF("FIELD<T>::operator/(const FIELD & m)");
+    return result;
+}
+
+
+/*!  Overloaded Operator /=
+ *   Operations are directly performed in the first field's array.
+ *   This operation is authorized only for compatible fields that have the same support.
+ */
+template <class T>
+FIELD<T>& FIELD<T>::operator/=(const FIELD & m)
+{
+    BEGIN_OF("FIELD<T>::operator/=(const FIELD & m)");
+    FIELD_::_checkFieldCompatibility(*this, m); // may throw exception
+
+    // We choose to keep *this mode, even if it may cost a re-calculation for m
+    medModeSwitch mode=this->getvalue()->getMode();
+    const T* value1=m.getValue(mode); // get pointers to the values we are adding
+
+    // get a non const pointer to the inside array of values and perform operation
+    T * value=const_cast<T *> (getValue(mode));
+    const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
+    const T* endV=value+size; // pointer to the end of value
+
+    for(;value!=endV; value1++,value++)
+       *value /= *value1;
+    // if it exists, the alternate mode needs to be cleared because it is not up-to-date anymore
+    this->getvalue()->clearOtherMode();
+    END_OF("FIELD<T>::operator/=(const FIELD & m)");
+    return *this;
+}
+
+
+/*! Division of fields. Static member function.
+ *  The function return a pointer to a new created field that holds the division.
+ *  Data members are checked for compatibility and initialized.
+ *  The user is in charge of memory deallocation.
+ */
+template <class T>
+FIELD<T>* FIELD<T>::div(const FIELD& m, const FIELD& n)
+{
+    BEGIN_OF("FIELD<T>::div(const FIELD & m, const FIELD& n)");
+    FIELD_::_checkFieldCompatibility(m, n); // may throw exception
+
+    // Select mode : avoid if possible any calculation of other mode for fields m or *this
+    medModeSwitch mode;
+    if(m.getvalue()->getMode()==n.getvalue()->getMode() || n.getvalue()->isOtherCalculated())
+       mode=m.getvalue()->getMode();
+    else
+       mode=n.getvalue()->getMode();
+    
+    // Creation of a new field
+    FIELD<T>* result = new FIELD<T>(m.getSupport(),m.getNumberOfComponents(),mode);
+    result->_operationInitialize(m,n,"/"); // perform Atribute's initialization
+    result->_div_in_place(m,n,mode); // perform division
+
+    END_OF("FIELD<T>::div(const FIELD & m, const FIELD& n)");
+    return result;
+}
+
+
+/*!
+  \if developper
+  This internal method initialize the members of a new field created to hold the result of the operation Op .
+  Initialization is based on the first field, except for the name, which is the combination of the two field's names
+  and the operator.
+  \endif
+*/
+template <class T>
+void FIELD<T>::_operationInitialize(const FIELD& m,const FIELD& n, char* Op)
+{
+    MESSAGE("Appel methode interne _add" << Op);
+
+    // Atribute's initialization (copy of the first field's attributes)
+    // Other data members (_support, _numberOfValues) are initialized in the field's constr.
+    setName(m.getName()+" "+Op+" "+n.getName());
+    setComponentsNames(m.getComponentsNames());
+    // not yet implemented    setComponentType(m.getComponentType());
+    setComponentsDescriptions(m.getComponentsDescriptions());
+    setMEDComponentsUnits(m.getMEDComponentsUnits());
+
+    // The following data member may differ from field m to n.
+    // The initialization is done based on the first field.
+    setComponentsUnits(m.getComponentsUnits());
+    setIterationNumber(m.getIterationNumber());
+    setTime(m.getTime());
+    setOrderNumber(m.getOrderNumber());
+    setValueType(m.getValueType());
+}
+
+
+/*!
+  \if developper
+  Internal method called by FIELD<T>::operator+ and FIELD<T>::add to perform addition "in place".
+  This method is applied to a just created field with medModeSwitch mode.
+  For this reason, the alternate mode doesn't need to be set to 0 after performing operation : 
+  it doesn't exist!
+  \endif
+*/
+template <class T>
+void FIELD<T>::_add_in_place(const FIELD& m,const FIELD& n, const medModeSwitch mode)
+{
+    // get pointers to the values we are adding
+    const T* value1=m.getValue(mode);
+    const T* value2=n.getValue(mode);
+    // get a non const pointer to the inside array of values and perform operation
+    T * value=const_cast<T *> (getValue(mode));
+
+    const int size=getNumberOfValues()*getNumberOfComponents();
+    SCRUTE(size);
+    const T* endV1=value1+size;
+    for(;value1!=endV1; value1++,value2++,value++)
+       *value=(*value1)+(*value2);
+}
+
+/*!
+  \if developper
+  Internal method called by FIELD<T>::operator- and FIELD<T>::sub to perform substraction "in place".
+  This method is applied to a just created field with medModeSwitch mode.
+  For this reason, the alternate mode doesn't need to be set to 0 after performing operation : 
+  it doesn't exist!
+  \endif
+*/
+template <class T>
+void FIELD<T>::_sub_in_place(const FIELD& m,const FIELD& n, const medModeSwitch mode)
+{
+    // get pointers to the values we are adding
+    const T* value1=m.getValue(mode);
+    const T* value2=n.getValue(mode);
+    // get a non const pointer to the inside array of values and perform operation
+    T * value=const_cast<T *> (getValue(mode));
+
+    const int size=getNumberOfValues()*getNumberOfComponents();
+    SCRUTE(size);
+    const T* endV1=value1+size;
+    for(;value1!=endV1; value1++,value2++,value++)
+       *value=(*value1)-(*value2);
+}
+
+/*!
+  \if developper
+  Internal method called by FIELD<T>::operator* and FIELD<T>::mul to perform multiplication "in place".
+  This method is applied to a just created field with medModeSwitch mode.
+  For this reason, the alternate mode doesn't need to be set to 0 after performing operation : 
+  it doesn't exist!
+  \endif
+*/
+template <class T>
+void FIELD<T>::_mul_in_place(const FIELD& m,const FIELD& n, const medModeSwitch mode)
+{
+    // get pointers to the values we are adding
+    const T* value1=m.getValue(mode);
+    const T* value2=n.getValue(mode);
+    // get a non const pointer to the inside array of values and perform operation
+    T * value=const_cast<T *> (getValue(mode));
+
+    const int size=getNumberOfValues()*getNumberOfComponents();
+    SCRUTE(size);
+    const T* endV1=value1+size;
+    for(;value1!=endV1; value1++,value2++,value++)
+       *value=(*value1)*(*value2);
+}
+
+/*!
+  \if developper
+  Internal method called by FIELD<T>::operator/ and FIELD<T>::div to perform division "in place".
+  This method is applied to a just created field with medModeSwitch mode.
+  For this reason, the alternate mode doesn't need to be set to 0 after performing operation : 
+  it doesn't exist!
+  \endif
+*/
+template <class T>
+void FIELD<T>::_div_in_place(const FIELD& m,const FIELD& n, const medModeSwitch mode)
+{
+    // get pointers to the values we are adding
+    const T* value1=m.getValue(mode);
+    const T* value2=n.getValue(mode);
+    // get a non const pointer to the inside array of values and perform operation
+    T * value=const_cast<T *> (getValue(mode));
+
+    const int size=getNumberOfValues()*getNumberOfComponents();
+    SCRUTE(size);
+    const T* endV1=value1+size;
+    for(;value1!=endV1; value1++,value2++,value++)
+       *value=(*value1)/(*value2);
+}
+
+/*!  Return Max Norm 
+ */
+template <class T> double FIELD<T>::normMax() const throw (MEDEXCEPTION)
+{
+    const T* value=getValue(getvalue()->getMode()); // get pointer to the values
+    const int size=getNumberOfValues()*getNumberOfComponents();
+    if (size <= 0) // Size of array has to be strictly positive
+    {
+       string diagnosis;
+       diagnosis="FIELD<T>::normMax() : cannot compute the norm of "+getName()+
+           " : it size is non positive!";
+       throw MEDEXCEPTION(diagnosis.c_str());
+    }
+    const T* lastvalue=value+size; // get pointer just after last value
+    const T* pMax=value; // pointer to the max value
+    const T* pMin=value; // pointer to the min value
+
+    // get pointers to the max & min value of array
+    while ( ++value != lastvalue )
+    {
+       if ( *pMin > *value )
+           pMin=value;
+       if ( *pMax < *value )
+           pMax=value;
+    }
+
+    T Max= *pMax>(T) 0 ? *pMax : -*pMax; // Max=abs(*pMax)
+    T Min= *pMin>(T) 0 ? *pMin : -*pMin; // Min=abs(*pMin)
+
+    return Max>Min ? static_cast<double>(Max) : static_cast<double>(Min);
+}
+
+/*!  Return Euclidien norm 
+ */
+template <class T> double FIELD<T>::norm2() const throw (MEDEXCEPTION)
+{
+    const T* value=this->getValue(this->getvalue()->getMode()); // get const pointer to the values
+    const int size=getNumberOfValues()*getNumberOfComponents(); // get size of array
+    if (size <= 0) // Size of array has to be strictly positive
+    {
+       string diagnosis;
+       diagnosis="FIELD<T>::norm2() : cannot compute the norm of "+getName()+
+           " : it size is non positive!";
+       throw MEDEXCEPTION(diagnosis.c_str());
+    }
+    const T* lastvalue=value+size; // point just after last value
+    
+    T result((T)0); // init
+    for( ; value!=lastvalue ; ++value)
+       result += (*value) * (*value);
+    
+    return std::sqrt(static_cast<double> (result));
+}
+
+
+/*!  Apply to each (scalar) field component the template parameter T_function, 
+ *   which is a pointer to function.
+ *   Since the pointer is known at compile time, the function is inlined into the inner loop!
+ *   calculation is done "in place".
+ *   Use examples : 
+ *   
+ *   \code  myField.applyFunc<std::sqrt>();  // apply sqare root function \endcode
+ *     \code myField.applyFunc<myFunction>(); // apply your own created function \endcode
+ */
+template <class T> template <T T_function(T)> 
+void FIELD<T>::applyFunc()
+{
+    medModeSwitch mode=getvalue()->getMode();
+
+    // get a non const pointer to the inside array of values and perform operation
+    T * value=const_cast<T *> (getValue(mode));
+    const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
+
+    if (size>0) // for a negative size, there is nothing to do
+    {
+       const T* lastvalue=value+size; // pointer to the end of value
+       for(;value!=lastvalue; ++value) // apply linear transformation
+           *value = T_function(*value);
+       // if it exists, the alternate mode needs to be cleared because it is not up-to-date anymore
+       getvalue()->clearOtherMode();
+    }
 }
+    
+  
+/*!  Apply to each (scalar) field component the linear function x -> ax+b.
+ *   calculation is done "in place".
+ */
+template <class T> void FIELD<T>::applyLin(T a, T b)
+{
+    medModeSwitch mode=getvalue()->getMode();
+
+    // get a non const pointer to the inside array of values and perform operation in place
+    T * value=const_cast<T *> (getValue(mode));
+    const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
+
+    if (size>0) // for a negative size, there is nothing to do
+    {
+       const T* lastvalue=value+size; // pointer to the end of value
+       for(;value!=lastvalue; ++value) // apply linear transformation
+           *value = a*(*value)+b;
+       // if it exists, the alternate mode needs to be cleared because it is not up-to-date anymore
+       getvalue()->clearOtherMode();
+    }
+}
+
 
 /*!
-  Constructor.
+ *   Return a pointer to a new field that holds the scalar product. Static member function.
+ *   This operation is authorized only for compatible fields that have the same support.
+ *   The compatibility checking includes equality tests of the folowing data members:/n
+ *   - _support
+ *   - _numberOfComponents
+ *   - _numberOfValues
+ *   - _componentsTypes
+ *   - _MEDComponentsUnits.
+ *   Data members are initialized.
+ *   The new field point to the same support and has one component.
+ *   Each value of it is the scalar product of the two argument's fields.
+ *   The user is in charge of memory deallocation.
+ */
+template <class T> FIELD<T>* FIELD<T>::scalarProduct(const FIELD & m, const FIELD & n)
+{
+    FIELD_::_checkFieldCompatibility( m, n); // may throw exception
+    // we need a MED_FULL_INTERLACE representation of m & n to compute the scalar product
+    const medModeSwitch mode=MED_FULL_INTERLACE; 
+
+    const int numberOfElements=m.getNumberOfValues(); // strictly positive
+    const int NumberOfComponents=m.getNumberOfComponents(); // strictly positive
+
+    // Creation & init of a the result field on the same suppot, with one component
+    FIELD<T>* result = new FIELD<T>(m.getSupport(),1,mode);
+    result->setName( "scalarProduct ( " + m.getName() + " , " + n.getName() + " )" );
+    result->setIterationNumber(m.getIterationNumber());
+    result->setTime(m.getTime());
+    result->setOrderNumber(m.getOrderNumber());
+    result->setValueType(m.getValueType());
+
+    const T* value1=m.getValue(mode); // get const pointer to the values
+    const T* value2=n.getValue(mode); // get const pointer to the values
+    // get a non const pointer to the inside array of values and perform operation
+    T * value=const_cast<T *> (result->getValue(mode));
+    
+    const T* lastvalue=value+numberOfElements; // pointing just after last value of result
+    for ( ; value!=lastvalue ; ++value ) // loop on all elements
+    {
+       *value=(T)0; // initialize value
+       const T* endofRow=value1+NumberOfComponents; // pointing just after end of row
+       for ( ; value1 != endofRow; ++value1, ++value2) // computation of dot product
+           *value += (*value1) * (*value2);
+    }
+    return result;
+}
+
+/*!  Return L2 Norm  of the field's component.
+ *   Cannot be applied to a field with a support on nodes.
+ *   If the optional p_field_volume argument is furnished, the volume is not re-calculated.
+ */
+template <class T> double FIELD<T>::normL2(int component, const FIELD<double> * p_field_volume) const
+{
+    _checkNormCompatibility(p_field_volume); // may throw exception
+    if ( component<1 || component>getNumberOfComponents() )
+       throw MEDEXCEPTION(STRING("FIELD<T>::normL2() : The component argument should be between 1 and the number of components"));
+
+    const FIELD<double> * p_field_size=p_field_volume;
+    if(!p_field_volume) // if the user don't supply the volume
+       p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh]
+
+    // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size
+    const double* vol=p_field_size->getValue(MED_FULL_INTERLACE); 
+    const T* value=getValueI( MED_NO_INTERLACE, component); // get pointer to the component's values
+    const T* lastvalue=value+getNumberOfValues(); // pointing just after the end of column
+
+    double integrale=0.0;
+    double totVol=0.0;
+    for (; value!=lastvalue ; ++value ,++vol) 
+    {
+       integrale += static_cast<double>((*value) * (*value)) * (*vol);
+       totVol+=*vol;
+    }
+
+    if(!p_field_volume) // if the user didn't supply the volume
+       delete p_field_size; // delete temporary volume field
+    if( totVol <= 0)
+       throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!"));
+
+    return integrale/totVol;
+}
+
+/*!  Return L2 Norm  of the field.
+ *   Cannot be applied to a field with a support on nodes.
+ *   If the optional p_field_volume argument is furnished, the volume is not re-calculated.
+ */
+template <class T> double FIELD<T>::normL2(const FIELD<double> * p_field_volume) const
+{
+    _checkNormCompatibility(p_field_volume); // may throw exception
+    const FIELD<double> * p_field_size=p_field_volume;
+    if(!p_field_volume) // if the user don't supply the volume
+       p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh]
+
+    // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size
+    const double* vol=p_field_size->getValue(MED_FULL_INTERLACE); 
+    const double* lastvol=vol+getNumberOfValues(); // pointing just after the end of vol
+    const T* value=getValue( MED_NO_INTERLACE); // get pointer to the field's values
+
+    double totVol=0.0;
+    const double* p_vol=vol;
+    for (p_vol=vol; p_vol!=lastvol ; ++p_vol) // calculate total volume
+       totVol+=*p_vol;
+    
+    double integrale=0.0;
+    for (int i=1; i<=getNumberOfComponents(); ++i) // compute integral on all components
+       for (p_vol=vol; p_vol!=lastvol ; ++value ,++p_vol) 
+           integrale += static_cast<double>((*value) * (*value)) * (*p_vol);
+
+    if(!p_field_volume) // if the user didn't supply the volume
+       delete p_field_size; // delete temporary volume field
+    if( totVol <= 0)
+       throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!"));
+
+    return integrale/totVol;
+}
+
+/*!  Return L1 Norm  of the field's component.
+ *   Cannot be applied to a field with a support on nodes.
+ *   If the optional p_field_volume argument is furnished, the volume is not re-calculated.
+ */
+template <class T> double FIELD<T>::normL1(int component, const FIELD<double> * p_field_volume) const
+{
+    _checkNormCompatibility(p_field_volume); // may throw exception
+    if ( component<1 || component>getNumberOfComponents() )
+       throw MEDEXCEPTION(STRING("FIELD<T>::normL2() : The component argument should be between 1 and the number of components"));
+
+    const FIELD<double> * p_field_size=p_field_volume;
+    if(!p_field_volume) // if the user don't supply the volume
+       p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh]
+
+    // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size
+    const double* vol=p_field_size->getValue(MED_FULL_INTERLACE); 
+    const T* value=getValueI( MED_NO_INTERLACE, component); // get pointer to the component's values
+    const T* lastvalue=value+getNumberOfValues(); // pointing just after the end of column
+
+    double integrale=0.0;
+    double totVol=0.0;
+    for (; value!=lastvalue ; ++value ,++vol) 
+    {
+       integrale += std::abs( static_cast<double>(*value) ) * (*vol);
+       totVol+=*vol;
+    }
+
+    if(!p_field_volume) // if the user didn't supply the volume
+       delete p_field_size; // delete temporary volume field
+    if( totVol <= 0)
+       throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!"));
+
+    return integrale/totVol;
+}
+
+/*!  Return L1 Norm  of the field.
+ *   Cannot be applied to a field with a support on nodes.
+ *   If the optional p_field_volume argument is furnished, the volume is not re-calculated.
+ */
+template <class T> double FIELD<T>::normL1(const FIELD<double> * p_field_volume) const
+{
+    _checkNormCompatibility(p_field_volume); // may throw exception
+    const FIELD<double> * p_field_size=p_field_volume;
+    if(!p_field_volume) // if the user don't supply the volume
+       p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh]
+
+    // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size
+    const double* vol=p_field_size->getValue(MED_FULL_INTERLACE); 
+    const double* lastvol=vol+getNumberOfValues(); // pointing just after the end of vol
+    const T* value=getValue( MED_NO_INTERLACE); // get pointer to the field's values
+
+    double totVol=0.0;
+    const double* p_vol=vol;
+    for (p_vol=vol; p_vol!=lastvol ; ++p_vol) // calculate total volume
+       totVol+=*p_vol;
+    
+    double integrale=0.0;
+    for (int i=1; i<=getNumberOfComponents(); ++i) // compute integral on all components
+       for (p_vol=vol; p_vol!=lastvol ; ++value ,++p_vol) 
+           integrale += std::abs( static_cast<double>(*value) ) * (*p_vol);
+
+    if(!p_field_volume) // if the user didn't supply the volume
+       delete p_field_size; // delete temporary volume field
+    if( totVol <= 0)
+       throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!"));
+
+    return integrale/totVol;
+}
+
+
+
+
+/*!
+  Constructor with parameters; the object is set via a file and its associated
+  driver. For the moment only the MED_DRIVER is considered and if the last two
+  argument (iterationNumber and orderNumber) are not set; their default value
+  is -1. If the field fieldDriverName with the iteration number
+  iterationNumber and the order number orderNumber does not exist in the file
+  fieldDriverName; the constructor raises an exception.
 */
 template <class T> FIELD<T>::FIELD(const SUPPORT * Support,
                                   driverTypes driverType,
                                   const string & fileName/*=""*/,
-                                  const string & fieldDriverName/*=""*/)
+                                  const string & fieldDriverName/*=""*/,
+                                  const int iterationNumber,
+                                  const int orderNumber)
+  throw (MEDEXCEPTION)
 {
-  const char * LOC = "template <class T> FIELD<T>::FIELD(const SUPPORT * Support, driverTypes driverType, const string & fileName=\"\", const string & fieldName=\"\") : ";
+  const char * LOC = "template <class T> FIELD<T>::FIELD(const SUPPORT * Support, driverTypes driverType, const string & fileName=\"\", const string & fieldName=\"\", const int iterationNumber=-1, const int orderNumber=-1) : ";
 
   int current;
 
@@ -762,9 +1651,19 @@ template <class T> FIELD<T>::FIELD(const SUPPORT * Support,
   _support = Support;
   _value = (MEDARRAY<T>*)NULL;
 
-  MED_FIELD_RDONLY_DRIVER<T> myDriver(fileName,this);
-  myDriver.setFieldName(fieldDriverName);
-  current = addDriver(myDriver);
+  _iterationNumber = iterationNumber;
+  _time = 0.0;
+  _orderNumber = orderNumber;
+
+  switch(driverType)
+    {
+    case MED_DRIVER :
+      {
+       MED_FIELD_RDONLY_DRIVER<T> myDriver(fileName,this);
+       myDriver.setFieldName(fieldDriverName);
+       current = addDriver(myDriver);
+       break;
+      }
 //   current = addDriver(driverType,fileName,fieldDriverName);
 //   switch(_drivers[current]->getAccessMode() ) {
 //   case MED_WRONLY : {
@@ -774,6 +1673,13 @@ template <class T> FIELD<T>::FIELD(const SUPPORT * Support,
 //   default : {
 //   }
 //   }
+    default :
+      {
+       throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Driver type unknown : can't create driver!"));
+       break;
+      }
+    }
+
   _drivers[current]->open();
   _drivers[current]->read();
   _drivers[current]->close();
@@ -787,6 +1693,7 @@ template <class T> FIELD<T>::FIELD(const SUPPORT * Support,
 template <class T> FIELD<T>::~FIELD()
 {
   BEGIN_OF(" Destructeur FIELD<T>::~FIELD()");
+  SCRUTE(this);
   if (_value) delete _value;
   END_OF(" Destructeur FIELD<T>::~FIELD()");
 }
@@ -818,7 +1725,7 @@ template <class T> void FIELD<T>::allocValue(const int NumberOfComponents)
     _numberOfValues = _support->getNumberOfElements(MED_ALL_ELEMENTS);
     MESSAGE(LOC <<" : "<<_numberOfValues <<" et "<< NumberOfComponents);
 
-    _value = new MEDARRAY<T>::MEDARRAY(_numberOfComponents,_numberOfValues);
+    _value = new MEDARRAY<T>(_numberOfComponents,_numberOfValues);
 
     _isRead = true ;
   }
@@ -855,7 +1762,7 @@ template <class T> void FIELD<T>::allocValue(const int NumberOfComponents, const
 
   MESSAGE("FIELD : constructeur : "<<LengthValue <<" et "<< NumberOfComponents);
   _numberOfValues = LengthValue ;
-  _value = new MEDARRAY<T>::MEDARRAY(_numberOfComponents,_numberOfValues);
+  _value = new MEDARRAY<T>(_numberOfComponents,_numberOfValues);
   _isRead = true ;
 
   SCRUTE(_value);
@@ -882,13 +1789,17 @@ template <class T> void FIELD<T>::deallocValue()
 
 
 template <class T>       FIELD<T>::INSTANCE_DE<MED_FIELD_RDWR_DRIVER<T> >     FIELD<T>::inst_med  ;
-template <class T> const FIELD<T>::INSTANCE * const FIELD<T>::instances[] = { &FIELD<T>::inst_med } ;
+
+template <class T>       FIELD<T>::INSTANCE_DE<VTK_FIELD_DRIVER<T> >     FIELD<T>::inst_vtk  ;
+
+template <class T> const typename FIELD<T>::INSTANCE * const FIELD<T>::instances[] = { &FIELD<T>::inst_med,  &FIELD<T>::inst_vtk} ;
 
 
 /*!
   Create the specified driver and return its index reference to path to 
   read or write methods.
 */
+
 template <class T> int FIELD<T>::addDriver(driverTypes driverType,
                                           const string & fileName/*="Default File Name.med"*/,
                                           const string & driverName/*="Default Field Name"*/)
@@ -897,18 +1808,51 @@ template <class T> int FIELD<T>::addDriver(driverTypes driverType,
 
   GENDRIVER * driver;
   int current;
+  int itDriver = (int) NO_DRIVER;
 
   BEGIN_OF(LOC);
 
-  driver = instances[driverType]->run(fileName, this) ;
+  SCRUTE(driverType);
+
+  SCRUTE(instances[driverType]);
+
+  switch(driverType)
+    {
+    case MED_DRIVER : {
+      itDriver = (int) driverType ;
+      break ;
+    }
+
+    case VTK_DRIVER : {
+      itDriver = 1 ;
+      break ;
+    }
+
+    case GIBI_DRIVER : {
+      throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD"));
+      break;
+    }
+
+    case NO_DRIVER : {
+      throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD"));
+      break;
+    }
+    }
+
+  if (itDriver == ((int) NO_DRIVER))
+    throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD"));
+
+  driver = instances[itDriver]->run(fileName, this) ;
+
   _drivers.push_back(driver);
+
   current = _drivers.size()-1;
 
   _drivers[current]->setFieldName(driverName);
-  return current;
 
   END_OF(LOC);
 
+  return current;
 }
 
 
@@ -926,7 +1870,7 @@ template <class T> inline int FIELD<T>::addDriver (GENDRIVER & driver )
 
   _drivers.push_back(newDriver);
   return _drivers.size() -1 ;
-  
+
   END_OF(LOC);
 };
 
@@ -945,7 +1889,7 @@ template <class T> void FIELD<T>::rmDriver (int index/*=0*/)
   }
   else
     throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
-                                     << "The index given is invalid, index must be between  0 and  |"
+                                     << "The <index given is invalid, index must be between  0 and  |"
                                      << _drivers.size()
                                      )
                           );
@@ -998,6 +1942,30 @@ template <class T> inline void FIELD<T>::write(int index/*=0*/, const string & d
   END_OF(LOC);
 }
 
+/*!
+  Write FIELD in the file specified in the driver given by its index. Use this
+  method for ASCII drivers (e.g. VTK_DRIVER)
+*/
+template <class T> inline void FIELD<T>::writeAppend(int index/*=0*/, const string & driverName /*= ""*/)
+{
+  const char * LOC = "FIELD<T>::write(int index=0, const string & driverName = \"\") : ";
+  BEGIN_OF(LOC);
+
+  if( _drivers[index] ) {
+    _drivers[index]->openAppend();
+    if (driverName != "") _drivers[index]->setFieldName(driverName);
+    _drivers[index]->writeAppend();
+    _drivers[index]->close();
+  }
+  else
+    throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+                                     << "The index given is invalid, index must be between  0 and |"
+                                     << _drivers.size()
+                                     )
+                          );
+  END_OF(LOC);
+}
+
 /*!
   \internal
   Write FIELD with the driver which is equal to the given driver.
@@ -1009,7 +1977,7 @@ template <class T> inline void FIELD<T>::write(const GENDRIVER & genDriver)
   const char * LOC = " FIELD<T>::write(const GENDRIVER &) : ";
   BEGIN_OF(LOC);
 
-  for (int index=0; index < _drivers.size(); index++ )
+  for (unsigned int index=0; index < _drivers.size(); index++ )
     if ( *_drivers[index] == genDriver ) {
       _drivers[index]->open();
       _drivers[index]->write();
@@ -1020,6 +1988,28 @@ template <class T> inline void FIELD<T>::write(const GENDRIVER & genDriver)
 
 }
 
+/*!
+  \internal
+  Write FIELD with the driver which is equal to the given driver.
+
+  Use by MED object. Use this method for ASCII drivers (e.g. VTK_DRIVER).
+*/
+template <class T> inline void FIELD<T>::writeAppend(const GENDRIVER & genDriver)
+{
+  const char * LOC = " FIELD<T>::write(const GENDRIVER &) : ";
+  BEGIN_OF(LOC);
+
+  for (unsigned int index=0; index < _drivers.size(); index++ )
+    if ( *_drivers[index] == genDriver ) {
+      _drivers[index]->openAppend();
+      _drivers[index]->writeAppend();
+      _drivers[index]->close();
+    }
+
+  END_OF(LOC);
+
+}
+
 /*!
   \internal
   Read FIELD with the driver which is equal to the given driver.
@@ -1031,7 +2021,7 @@ template <class T> inline void FIELD<T>::read(const GENDRIVER & genDriver)
   const char * LOC = " FIELD<T>::read(const GENDRIVER &) : ";
   BEGIN_OF(LOC);
 
-  for (int index=0; index < _drivers.size(); index++ )
+  for (unsigned int index=0; index < _drivers.size(); index++ )
     if ( *_drivers[index] == genDriver ) {
       _drivers[index]->open();
       _drivers[index]->read();
index 41b07769508af5945bce2d9c59573d8123cfd5c9..1545acf2b4510746e300d49d972ef04a013915a6 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_GenDriver.cxx
-//  Module : MED
-
 using namespace std;
 #include "MEDMEM_GenDriver.hxx"
 #include "MEDMEM_STRING.hxx"
@@ -71,8 +45,11 @@ GENDRIVER & GENDRIVER::operator=(const GENDRIVER &  genDriver) {
 void GENDRIVER::writeFrom      ( void ) {};
 void GENDRIVER::readFileStruct ( void ) {};
 
-void GENDRIVER::setMeshName    (const string & meshName) {};
-void GENDRIVER::setFieldName   (const string & fieldName) {};
+void GENDRIVER::setMeshName    (const string & ) {};
+void GENDRIVER::setFieldName   (const string & ) {};
+
+void GENDRIVER::openAppend ( void ) {};
+void GENDRIVER::writeAppend ( void ) const {};
 
 void GENDRIVER::setId ( int id ) {
   const char * LOC = "void GENDRIVER::setId ( int id ) : ";
@@ -142,6 +119,9 @@ ostream & operator<<(ostream &os,const GENDRIVER & drv)
     case MED_RDWR :
       os<<"C'est un IO d'READ/WRITE"<<endl;
       break;
+    case MED_REMP :
+      os <<"C'est un IO de remplacement"<<endl;
+      break;
     }
   switch (drv._status)
     {
@@ -149,7 +129,7 @@ ostream & operator<<(ostream &os,const GENDRIVER & drv)
       os<<"L'IO_Mesh_MED est open"<<endl;
       break;
     case MED_CLOSED :
-      os<<"L'IO_Mesh_MED est fermé"<<endl;
+      os<<"L'IO_Mesh_MED est fermé"<<endl;
       break;
     case MED_INVALID :
       os<<"L'IO_Mesh_MED est non-valide"<<endl;
@@ -169,3 +149,4 @@ bool GENDRIVER::operator ==(const GENDRIVER &genDriver) const {
     ( _driverType == genDriver._driverType );
   
 };
+
index 9e9813cf7fdda46c3e1e7bd1fb8ca1f51f53b920..0fcdeda65ffc6395c5439caf5880bf9dcb1b3d26 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_GenDriver.hxx
-//  Module : MED
-
 #ifndef GENDRIVER_HXX
 #define GENDRIVER_HXX
 
@@ -58,6 +32,7 @@ protected :
   int            _status;     // The file status {MED_INVALID, MED_OPENED, MED_CLOSED } 
   driverTypes    _driverType; //  A FAIRE LE POSITIONNER DS TOUTES LES SS CLASSES !!
 
+
 public:
   /*!
     Constructor.
@@ -92,6 +67,11 @@ public:
     Open file.
   */
   virtual void open ( void ) = 0;
+  /*!
+    Open file with the append option. This method is used especially
+    on ASCII drivers (e.g. VTK_DRIVER).
+  */
+  virtual void openAppend ( void );
   /*!
     Close file.
   */
@@ -100,6 +80,11 @@ public:
     Write object in opened file.
   */
   virtual void write( void ) const = 0;
+  /*!
+    Write object in opened file. This method is used especially
+    on ASCII drivers (e.g. VTK_DRIVER).
+  */
+  virtual void writeAppend( void ) const;
   /*!
     Read object in opened file.
   */
@@ -124,5 +109,4 @@ public:
 };
 
 
-
 #endif /* GENDRIVER_HXX */
index 0da08ffa57efa8f024217e98d3592d30a17ecc7e..0de7ab1a87206ae2ecda2ea4d0dde50c7ff61795 100644 (file)
@@ -1,13 +1,7 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  CEA/DEN, EDF R&D
-//
-//
-//
-//  File   : MEDMEM_GibiMeshDriver.cxx
-//  Module : MED
-
 using namespace std;
+
+#include <algorithm>
+
 #include "MEDMEM_GibiMeshDriver.hxx"
 
 #include "MEDMEM_DriversDef.hxx"
@@ -18,6 +12,18 @@ using namespace std;
 #include "MEDMEM_Connectivity.hxx"
 #include "MEDMEM_Mesh.hxx"
 #include "MEDMEM_CellModel.hxx"
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_DriverTools.hxx"
+
+/////
+using namespace MED_EN;
+/////
+
+
+/////
+const size_t GIBI_MESH_DRIVER::nb_geometrie_gibi;
+const medGeometryElement GIBI_MESH_DRIVER::geomGIBItoMED[nb_geometrie_gibi];
+/////
 
 // Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor 
 
@@ -33,10 +39,10 @@ GIBI_MESH_DRIVER::GIBI_MESH_DRIVER(const string & fileName,
                                    MESH * ptrMesh,
                                    MED_EN::med_mode_acces accessMode): 
   GENDRIVER(fileName,accessMode),
-  _ptrMesh(ptrMesh),
+  _ptrMesh(ptrMesh)
   // A VOIR _medIdt(MED_INVALID), 
-  _meshName("")
 {
+  _meshName=fileName.substr(0,fileName.rfind("."));
 }
   
 GIBI_MESH_DRIVER::GIBI_MESH_DRIVER(const GIBI_MESH_DRIVER & driver): 
@@ -54,40 +60,31 @@ GIBI_MESH_DRIVER::~GIBI_MESH_DRIVER()
 void GIBI_MESH_DRIVER::open()
   throw (MEDEXCEPTION)
 {
-  const char * LOC = "GIBI_MESH_DRIVER::open()" ;
-  BEGIN_OF(LOC);
-
-//   if (_medIdt > 0) 
-//     _status = MED_OPENED; 
-//   else {
-//     _medIdt = MED_INVALID;
-//     _status = MED_CLOSED;
-//     throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode));
-//   }
-  
+    const char * LOC = "GIBI_MESH_DRIVER::open()" ;
+    BEGIN_OF(LOC);
+
+    _gibi.open(_fileName.c_str(), ios::in);
+    if(_gibi)
+       _status = MED_OPENED;
+    else
+    {
+       _status = MED_CLOSED;
+       throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode ios::in"));
+    }
   END_OF(LOC);
 }
   
 void GIBI_MESH_DRIVER::close()
   throw (MEDEXCEPTION)
 {
-  const char * LOC = "GIBI_MESH_DRIVER::close() " ;
-  BEGIN_OF(LOC);
-
-//   int err = 0;
-//   if ( _status == MED_OPENED) {
-//     err=MED_FR::MEDfermer(_medIdt);
-//     H5close(); // If we call H5close() all the files are closed.
-//     if (err != 0)
-//       throw MEDEXCEPTION( LOCALIZED(STRING(LOC)
-//                                 <<" Error when closing file !"
-//                                 )
-//                       );
-//     _status = MED_CLOSED;
-//     _medIdt = MED_INVALID;
-//   }
-
-  END_OF(LOC);
+    const char * LOC = "GIBI_MESH_DRIVER::close() " ;
+    BEGIN_OF(LOC);
+    if ( _status == MED_OPENED) 
+    {
+       _gibi.close();
+       _status = MED_CLOSED;
+    }
+    END_OF(LOC);
 }
 
 void    GIBI_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; };
@@ -99,42 +96,301 @@ string  GIBI_MESH_DRIVER::getMeshName() const { return _meshName; };
 GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(): GIBI_MESH_DRIVER()
 {
 }
-  
+
 GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const string & fileName,
-                                                 MESH * ptrMesh):
-  GIBI_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY)
+       MESH * ptrMesh):
+GIBI_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY)
 { 
-  MESSAGE("GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
+    MESSAGE("GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
 }
-  
-GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const GIBI_MESH_RDONLY_DRIVER & driver): 
-  GIBI_MESH_DRIVER(driver)
+
+    GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const GIBI_MESH_RDONLY_DRIVER & driver): 
+GIBI_MESH_DRIVER(driver)
 {
 }
 
 GIBI_MESH_RDONLY_DRIVER::~GIBI_MESH_RDONLY_DRIVER()
 {
-  //MESSAGE("GIBI_MESH_RDONLY_DRIVER::~GIBI_MESH_RDONLY_DRIVER() has been destroyed");
+    //MESSAGE("GIBI_MESH_RDONLY_DRIVER::~GIBI_MESH_RDONLY_DRIVER() has been destroyed");
 }
   
 GENDRIVER * GIBI_MESH_RDONLY_DRIVER::copy(void) const
 {
-  return new GIBI_MESH_RDONLY_DRIVER(*this);
+    return new GIBI_MESH_RDONLY_DRIVER(*this);
 }
 
-void GIBI_MESH_RDONLY_DRIVER::read(void)
-  throw (MEDEXCEPTION)
+void GIBI_MESH_RDONLY_DRIVER::read(void) throw (MEDEXCEPTION)
 {
-  const char * LOC = "GIBI_MESH_RDONLY_DRIVER::read() : " ;
-  BEGIN_OF(LOC);
-  if (_status!=MED_OPENED)
-    throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : "  <<  " (the file is not opened)." )) ;
-
-  _ptrMesh->_name =  _meshName;
-  
-  END_OF(LOC);
+    const char * LOC = "GIBI_MESH_RDONLY_DRIVER::read() : " ;
+    BEGIN_OF(LOC);
+
+    if (_status!=MED_OPENED)
+       throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : "  
+                                                <<  " (the file is not opened)." )) ;
+
+    // LECTURE DES DONNEES DS FICHIER GIBI
+
+    _intermediateMED medi; // structure de données intermédiaire pour conversion gibi->med
+    string buf_ligne; // pour lire une ligne
+    const char* enregistrement_type="ENREGISTREMENT DE TYPE";
+    std::vector<int> numero_noeuds; // tableau de travail (indices)
+
+
+    while ( getline(_gibi, buf_ligne) ) // boucle externe de recherche de "ENREGISTREMENT DE TYPE"
+    {
+       string::size_type pos = buf_ligne.find(enregistrement_type);
+       if ( pos==string::npos )
+           continue; // "ENREGISTREMENT DE TYPE" non trouvé -> on lit la ligne suivante
+
+       // lecture du numéro d'enregistrement
+       int numero_enregistrement;
+       istringstream buf(buf_ligne.c_str()+strlen(enregistrement_type)+1);
+       buf >> numero_enregistrement;
+
+       enum { ENREG_TYPE_2=2, ENREG_TYPE_4=4}; // énumération des types d'enregistrement traités
+       int niveau, niveau_erreur;
+       unsigned space_dimension,nb_reels;
+       int numero_pile, nb_objets_nommes, nb_objets, nb_indices;
+       string s1,s2,s3,s4,s5,s6,s7; // temporary strings
+       int i1; //temporary int
+       double d1; //temporary double
+       vector<int> indices_objets_nommes;
+       vector<string> objets_nommes;
+
+       switch (numero_enregistrement)
+         {
+         case ENREG_TYPE_4:
+           MESSAGE(LOC << "---- Traitement enregistrement de type 4");
+           _gibi >> s1 >> niveau >> s2 >> s3 >> niveau_erreur >> s4 >> space_dimension;
+           if ( !_gibi || s1!="NIVEAU" || s3!="ERREUR" || s4!="DIMENSION" ) // verification mots -cles
+             throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Could not read file " << _fileName 
+                                          << " : syntax error in type 4 record"));
+           break;
+
+         case ENREG_TYPE_2:
+           {
+             MESSAGE(LOC << "---- Traitement enregistrement de type 2");
+             _gibi >> s1 >> s2 >> numero_pile >> s3 >> s4 >> s5 >> nb_objets_nommes >> s6 >> s7 >> nb_objets;
+             if ( !_gibi || s1!="PILE"   || s2!="NUMERO"       || s3!="NBRE"  // verification mots -cles
+                  || s4!="OBJETS" || s5!="NOMMES"       || s6!="NBRE"   
+                  || s7!="OBJETS" || nb_objets_nommes<0 || nb_objets<0  )
+               {
+                 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Could not read file " << _fileName 
+                                              << " : error in type 2 record"));
+               }
+
+             // lecture des objets nommés et de leurs indices
+             objets_nommes.resize(nb_objets_nommes);
+             indices_objets_nommes.resize(nb_objets_nommes);
+             for (int i=0; i!=nb_objets_nommes; ++i)
+               _gibi >> objets_nommes[i];
+
+             for (int i=0; i!=nb_objets_nommes; ++i)
+               _gibi >> indices_objets_nommes[i];
+               
+             // boucle interne : lecture de la pile
+             enum {PILE_SOUS_MAILLAGE=1, PILE_NOEUDS=32, PILE_COORDONNEES=33};
+             switch(numero_pile)
+               {
+               case PILE_SOUS_MAILLAGE:
+                 {
+                   medi.groupes.reserve(nb_objets);
+                   for (int objet=0; objet!=nb_objets; ++objet) // pour chaque groupe
+                     {
+                       unsigned type_geom_castem, nb_reference,nb_noeud,nb_elements, nb_sous_maillage;
+                       _gibi >> type_geom_castem >> nb_sous_maillage >> nb_reference >> nb_noeud >> nb_elements;
+                       
+                       // le cas type_geom_castem=0 correspond aux maillages composites
+                       if (type_geom_castem<0 || (type_geom_castem>0 && geomGIBItoMED[type_geom_castem-1]==MED_NONE) )
+                         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Error while reading file " << _fileName 
+                                                      << "\nCastem geometric type " << type_geom_castem 
+                                                      << " does not have a correspondant MED geometric type!" ));
+
+                       // lecture des references (non utilisé pour MED)
+                       for( unsigned i=0; i!=nb_reference; ++i)
+                         _gibi >> i1;
+                       
+                       // lecture des couleurs (non utilisé pour MED)
+                       for( unsigned i=0; i!=nb_elements; ++i)
+                         _gibi >> i1;
+                       
+                       _groupe groupe;
+                       // si le groupe se compose de sous-maillages (ie groupe composite) 
+                       if (type_geom_castem==0 && nb_sous_maillage>0) 
+                         {
+                           // lecture des indices des sous-maillages, stockage.
+                           // les mailles correspondant a ces sous_maillages seront inserees a la fin du case
+                           for (unsigned i=0; i!=nb_sous_maillage; ++i)
+                             {
+                               _gibi >> i1;
+                               groupe.groupes.push_back(i1);
+                             }
+                         }
+                       else
+                         {
+                           pair<set<_maille>::iterator,bool> p;
+                           pair<map<int,_noeud>::iterator,bool> p_no;
+                           _noeud no;
+                           no.coord.reserve(space_dimension);
+                           no.coord.resize(space_dimension);
+                           _maille ma(geomGIBItoMED[type_geom_castem-1], nb_noeud);
+                           ma.sommets.resize(nb_noeud);
+
+                           // lecture pour chaque maille des sommets et insertions
+                           for( unsigned i=0; i!=nb_elements; ++i)
+                             {
+                               for (unsigned n=0; n!=nb_noeud; ++n)
+                                 {
+                                   _gibi >> i1;
+                                   no.number=i1;
+                                   p_no=medi.points.insert(make_pair(i1, no));
+                                   ma.sommets[n]=p_no.first;
+                                 }
+
+                               p=medi.maillage.insert(ma);
+                               groupe.mailles.insert(p.first); // on stocke dans le groupe un iterateur sur la maille
+
+//                                 cout << "   " << p.second << ": ";
+//                                 for (unsigned n=0; n!=nb_noeud; ++n)
+//                                     cout <<  ma.sommets[n]->second.number << " ";
+//                                 cout << endl;
+                               
+                             }
+                         }
+                       medi.groupes.push_back(groupe);
+                     }
+
+                   for (int i=0; i!=nb_objets_nommes; ++i)
+                     medi.groupes[indices_objets_nommes[i]-1].nom=objets_nommes[i];
+                   
+                   // scanne les groupes à la recherche de groupes composites
+                   for( std::vector<_groupe>::iterator i=medi.groupes.begin(); i!=medi.groupes.end(); ++i)
+                     {
+                       if( i->groupes.size() ) // le groupe i contient des sous-maillages
+                         {
+                           for( std::list<int>::iterator j=i->groupes.begin(); j!=i->groupes.end(); ++j)
+                             {
+                               // pour chacun des sous-maillages j, on recupere les iterateurs *k sur les  maille 
+                               // contenues et on les insere dans le groupe i
+                               std::set< std::set<_maille>::iterator >::const_iterator k=medi.groupes[*j-1].mailles.begin();
+                               for( ; k!=medi.groupes[*j-1].mailles.end(); ++k)
+                                 i->mailles.insert(*k);
+                             }
+                           i->groupes.clear(); // après avoir insere leur mailles, on efface les groupes composites
+                         }
+                     }
+                   
+                   break;
+                 }// Fin case PILE_SOUS_MAILLAGE
+                       
+               case PILE_NOEUDS:
+                 {
+                   std::vector<int> place_noeuds;
+                   _gibi >> nb_indices;
+                   if (nb_indices != nb_objets)
+                     {
+                       throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Could not read file " << _fileName 
+                                                    << "Erreur de lecture dans enregistrement de type " << ENREG_TYPE_2 
+                                                    << " (pile " << PILE_NOEUDS << ")" ));
+                     }
+                   
+                   place_noeuds.resize(nb_objets);
+                   for (unsigned i=0; i!=place_noeuds.size(); ++i)
+                     _gibi >> place_noeuds[i];
+                   int max=(* std::max_element(place_noeuds.begin(),place_noeuds.end()));
+
+                   // numero_noeuds contient pour chacun des max noeuds qu'on va lire dans le case PILE_COORDONNEES
+                   // son indice dans la connectivite du maillage. Cet indice correspond egalement a la cle du map
+                   // medi.points ou l'on stocke les noeuds.
+                   numero_noeuds.resize(max,-1);
+                   for (unsigned i=0; i!=place_noeuds.size(); ++i)
+                     numero_noeuds[place_noeuds[i]-1]=i+1;
+                   break;
+                 }
+                 
+               case PILE_COORDONNEES:
+                 _gibi >> nb_reels;
+                 // PROVISOIRE : certains fichier gibi n'ont 
+                 if (nb_reels < numero_noeuds.size()*(space_dimension))
+                   throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Could not read file " << _fileName 
+                                                << "Erreur de lecture dans enregistrement de type " << ENREG_TYPE_2 
+                                                << " (pile " << PILE_COORDONNEES << ")" ));
+
+                 for (unsigned i=0; i!=numero_noeuds.size(); ++i)
+                   {
+                     // si le noeud est utilisé dans le maillage, on lit ses coordonnées et on les stocke dans la structure
+                     if ( (numero_noeuds[i] != -1) && (medi.points.find(numero_noeuds[i])!=medi.points.end()) ) 
+                       {
+                         for (unsigned j=0; j!=space_dimension; ++j)
+                           _gibi >> medi.points[numero_noeuds[i]].coord[j];
+                         _gibi >> d1; // on ne conserve pas la densite
+                       }
+                     else // sinon, on passe au noeud suivant
+                       {
+                         for (unsigned j=0; j!=space_dimension+1; ++j)
+                           _gibi >> d1;
+                       }
+                   }
+                 break;
+
+               } // Fin switch numero_pile
+             break;
+           } // Fin case ENREG_TYPE_2
+         }
+
+    } //  fin de la boucle while de lecture externe
+
+    // impression résultats
+    MESSAGE(LOC << "GIBI_MESH_RDONLY_DRIVER::read : RESULTATS STRUCTURE INTERMEDIAIRES : ");
+    MESSAGE(LOC <<  medi );
+
+           // TRANSFORMATION EN STRUCTURES MED
+    if ( ! _ptrMesh->isEmpty() )
+    {
+       throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Mesh object not empty : can't fill it!"));
+    }
+    else if ( medi.maillage.size()==0 || medi.groupes.size()==0 || medi.points.size()==0)
+    {
+       throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Error while reading file " << _fileName 
+                   << " The data read are not completed " ) ) ;
+    }
+    else
+    {
+       _ptrMesh->_name = _meshName;
+       _ptrMesh->_spaceDimension = medi.points.begin()->second.coord.size();
+       _ptrMesh->_meshDimension = medi.maillage.rbegin()->dimension();
+       _ptrMesh->_numberOfNodes = medi.points.size();
+       _ptrMesh->_isAGrid = 0;
+       _ptrMesh->_coordinate = medi.getCoordinate();
+
+       //Construction des groupes
+       vector<GROUP *> groupCell, groupFace, groupEdge, groupNode;
+       medi.getGroups(groupCell, groupFace, groupEdge, groupNode, _ptrMesh);
+       _ptrMesh->_groupCell = groupCell;
+       _ptrMesh->_groupFace = groupFace;
+       _ptrMesh->_groupEdge = groupEdge;
+       _ptrMesh->_groupNode = groupNode;
+
+       //Affectation derniers attributs objet Mesh
+       _ptrMesh->_numberOfCellsGroups = _ptrMesh->_groupCell.size();
+       _ptrMesh->_numberOfFacesGroups = _ptrMesh->_groupFace.size();
+       _ptrMesh->_numberOfEdgesGroups = _ptrMesh->_groupEdge.size();
+       _ptrMesh->_numberOfNodesGroups = _ptrMesh->_groupNode.size();
+
+       // appele en dernier car cette fonction detruit le maillage intermediaire!
+       _ptrMesh->_connectivity = medi.getConnectivity(); 
+
+       // calcul de la connectivite d-1 complete, avec renumerotation des groupes
+       if (_ptrMesh->_spaceDimension==3)
+           _ptrMesh->_connectivity->updateGroup(_ptrMesh->_groupFace) ;
+       else if (_ptrMesh->_spaceDimension==2)
+           _ptrMesh->_connectivity->updateGroup(_ptrMesh->_groupEdge) ;
+       
+    }
+
+
+
+    END_OF(LOC);
 }
 
 void GIBI_MESH_RDONLY_DRIVER::write( void ) const
index a6a154958e30379dda27ec816d5a7f7bf56a5115..bc25416b944810e887c659cd595619a4e4829bb6 100644 (file)
@@ -1,17 +1,9 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  CEA/DEN, EDF R&D
-//
-//
-//
-//  File   : MEDMEM_GibiMeshDriver.hxx
-//  Module : MED
-
 #ifndef GIBI_MESH_DRIVER_HXX
 #define GIBI_MESH_DRIVER_HXX
 
 #include <string>
 #include <vector>
+#include <fstream>
 
 #include "MEDMEM_define.hxx"
 #include "MEDMEM_GenDriver.hxx"
 #include "MEDMEM_Exception.hxx"
 #include "utilities.h"
 
+/////
+#include <sstream>
+#include <iomanip>
+/////
+
 class MESH;
 class FAMILY;
 class GROUP;
@@ -40,8 +37,25 @@ protected:
   
   MESH *          _ptrMesh;
   // A VOIR FILE DESCRIPTEUR ? MED_FR::med_idt _medIdt;
-  string          _meshName;    
+  string          _meshName;
+  /////
+  ifstream _gibi;
   
+  // tableau de correspondance des types géométriques de CASTEM -> MED
+  static const size_t nb_geometrie_gibi=47;
+  static const medGeometryElement geomGIBItoMED[nb_geometrie_gibi] =  // A COMPLETER
+    {   /*1 */ MED_POINT1 ,/*2 */ MED_SEG2   ,/*3 */ MED_SEG3   ,/*4 */ MED_TRIA3  ,/*5 */ MED_NONE   ,
+       /*6 */ MED_TRIA6  ,/*7 */ MED_NONE   ,/*8 */ MED_QUAD4  ,/*9 */ MED_NONE   ,/*10*/ MED_QUAD8  ,
+       /*11*/ MED_NONE   ,/*12*/ MED_NONE   ,/*13*/ MED_NONE   ,/*14*/ MED_HEXA8  ,/*15*/ MED_HEXA20 ,
+       /*16*/ MED_PENTA6 ,/*17*/ MED_PENTA15,/*18*/ MED_NONE   ,/*19*/ MED_NONE   ,/*20*/ MED_NONE   ,
+       /*21*/ MED_NONE   ,/*22*/ MED_NONE   ,/*23*/ MED_TETRA4 ,/*24*/ MED_TETRA10,/*25*/ MED_PYRA5  ,
+       /*26*/ MED_PYRA13 ,/*27*/ MED_NONE   ,/*28*/ MED_NONE   ,/*29*/ MED_NONE   ,/*30*/ MED_NONE   ,
+       /*31*/ MED_NONE   ,/*32*/ MED_NONE   ,/*33*/ MED_NONE   ,/*34*/ MED_NONE   ,/*35*/ MED_NONE   ,
+       /*36*/ MED_NONE   ,/*37*/ MED_NONE   ,/*38*/ MED_NONE   ,/*39*/ MED_NONE   ,/*40*/ MED_NONE   ,
+       /*41*/ MED_NONE   ,/*42*/ MED_NONE   ,/*43*/ MED_NONE   ,/*44*/ MED_NONE   ,/*45*/ MED_NONE   ,
+       /*46*/ MED_NONE   ,/*47*/ MED_NONE   };
+  /////
+
 public :
 
   /*!
index 40d448b087351d99f8da82a2fb2ffdb3e0753dd4..d6f2d6b6aa88894c94733077ee0bb59085e6431f 100644 (file)
@@ -1,15 +1,15 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  CEA/DEN, EDF R&D
-//
-//
-//
-//  File   : MEDMEM_Grid.hxx
-//  Author : Edward AGAPOV (eap)
-//  Module : MED
-//  $Header$
-
 using namespace std;
+// File      : MEDMEM_Grid.hxx
+// Created   : Wed Dec 18 08:35:26 2002
+// Descr     : class containing structured mesh data
+
+// Author    : Edward AGAPOV (eap)
+// Project   : SALOME Pro
+// Module    : MED 
+// Copyright : Open CASCADE
+// $Header$
+
+
 #include "MEDMEM_Grid.hxx"
 #include <MEDMEM_CellModel.hxx>
 #include <MEDMEM_SkyLineArray.hxx>
@@ -96,17 +96,17 @@ GRID & GRID::operator=(const GRID & otherGrid)
 //           (MED_DRIVER, ....) associated with file <fileName>. 
 //=======================================================================
 
-GRID::GRID(driverTypes driverType,
-           const string &  fileName,
-           const string &  driverName) {
+GRID::GRID(driverTypes driverType, const string &  fileName,
+           const string &  driverName) : MESH(driverType, fileName, driverName)
+{
   const char * LOC ="GRID::GRID(driverTypes , const string &  , const string &) : ";
   
   BEGIN_OF(LOC);
   
 //  int current;
 
-  init();
-  MESH(driverType,fileName,driverName);
+//   init();
+//   MESH(driverType,fileName,driverName);
 
 //   current = addDriver(driverType,fileName,driverName);
   
@@ -123,6 +123,8 @@ GRID::GRID(driverTypes driverType,
 
 //   // fill some fields of MESH
 //   fillMeshAfterRead();
+
+  fillMeshAfterRead();
     
   END_OF(LOC);
 };
@@ -181,7 +183,7 @@ void GRID::fillMeshAfterRead()
 //purpose  : 
 //=======================================================================
 
-void GRID::fillCoordinates()
+void GRID::fillCoordinates() const
 {
   if (_is_coordinates_filled)
   {
@@ -198,7 +200,8 @@ void GRID::fillCoordinates()
   bool hasJ = _jArrayLength, hasK = _kArrayLength;
   int J = hasJ ? _jArrayLength : 1;
   int K = hasK ? _kArrayLength : 1;
-  int nb, i, j, k;
+  //int nb, !! UNUSED VARIABLE !!
+  int i, j, k;
   for (k=0; k < K; ++k) {
     for (j=0; j < J; ++j) {
       for (i=0; i < _iArrayLength; ++i) {
@@ -221,7 +224,7 @@ void GRID::fillCoordinates()
     }
   }
       
-  _is_coordinates_filled = true;
+  (const_cast <GRID *> (this))->_is_coordinates_filled = true;
   END_OF(LOC);
 }
 
@@ -231,10 +234,11 @@ void GRID::fillCoordinates()
 //=======================================================================
 
 CONNECTIVITY * GRID::makeConnectivity (const medEntityMesh           Entity,
-                                            const medGeometryElement Geometry,
-                                            const int                NbEntities,
-                                            const int                NbNodes,
-                                            int *                    NodeNumbers)
+                                      const medGeometryElement Geometry,
+                                      const int                NbEntities,
+                                      const int                NbNodes,
+                                      int *                    NodeNumbers)
+  const
 {
   CONNECTIVITY * Connectivity     = new CONNECTIVITY(Entity) ;
   Connectivity->_numberOfNodes    = NbNodes ;
@@ -288,7 +292,7 @@ CONNECTIVITY * GRID::makeConnectivity (const medEntityMesh           Entity,
 //purpose  : fill _coordinates and _connectivity of MESH if not yet done
 //=======================================================================
 
-void GRID::fillConnectivity()
+void GRID::fillConnectivity() const
 {
   if (_is_connectivity_filled)
   {
@@ -634,7 +638,7 @@ void GRID::fillConnectivity()
 
   MESH::_connectivity  = CellCNCT;
 
-  _is_connectivity_filled = true;
+  (const_cast <GRID *> (this))->_is_connectivity_filled = true;
 
   END_OF(LOC);
 }
@@ -644,7 +648,7 @@ void GRID::fillConnectivity()
 //purpose  : return array length. Axis = [1,2,3] meaning [i,j,k],
 //=======================================================================
 
-int GRID::getArrayLength( const int Axis ) throw (MEDEXCEPTION)
+int GRID::getArrayLength( const int Axis ) const throw (MEDEXCEPTION)
 {
   switch (Axis) {
   case 1: return _iArrayLength;
@@ -663,8 +667,7 @@ int GRID::getArrayLength( const int Axis ) throw (MEDEXCEPTION)
 //           exception if i is out of range 0 <= i < getArrayLength(Axis);
 //=======================================================================
 
-const double GRID::getArrayValue (const int Axis, const int i)
-     throw (MEDEXCEPTION)
+const double GRID::getArrayValue (const int Axis, const int i) const throw (MEDEXCEPTION)
 {
   if (i < 0 || i >= getArrayLength(Axis))
     throw MED_EXCEPTION
@@ -684,10 +687,12 @@ const double GRID::getArrayValue (const int Axis, const int i)
 //=======================================================================
 
 int GRID::getEdgeNumber(const int Axis, const int i, const int j, const int k)
-     throw (MEDEXCEPTION)
+  const throw (MEDEXCEPTION)
 {
   const char * LOC = "GRID::getEdgeNumber(Axis, i,j,k) :";
 
+  BEGIN_OF(LOC);
+
   int Len[4] = {0,_iArrayLength, _jArrayLength, _kArrayLength }, I=1, J=2, K=3;
   int maxAxis = Len[ K ] ? 3 : 2;
   
@@ -710,7 +715,9 @@ int GRID::getEdgeNumber(const int Axis, const int i, const int j, const int k)
     Len[J]-- ;
     Nb += Len[ I ]*Len[ J ]*Len[ K ];
   }
-  
+
+  END_OF(LOC);
+
   return Nb;
 }
 
@@ -725,10 +732,12 @@ int GRID::getEdgeNumber(const int Axis, const int i, const int j, const int k)
 //=======================================================================
 
 int GRID::getFaceNumber(const int Axis, const int i, const int j, const int k)
-     throw (MEDEXCEPTION)
+  const throw (MEDEXCEPTION)
 {
   const char * LOC = "GRID::getFaceNumber(Axis, i,j,k) :";
   
+  BEGIN_OF(LOC);
+
 //  if (Axis <= 0 || Axis > 3)
   if (Axis < 0 || Axis > 3)
     throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Axis = " << Axis));
@@ -748,7 +757,9 @@ int GRID::getFaceNumber(const int Axis, const int i, const int j, const int k)
     Len[J]++ ;
     Nb += Len[ I ]*Len[ J ]*Len[ K ];
   }
-  
+
+  END_OF(LOC);
+
   return Nb;
 }
 
@@ -757,15 +768,18 @@ int GRID::getFaceNumber(const int Axis, const int i, const int j, const int k)
 //purpose  : 
 //=======================================================================
 
-void GRID::getNodePosition(const int Number, int& i, int& j, int& k)
-     throw (MEDEXCEPTION)
+void GRID::getNodePosition(const int Number, int& i, int& j, int& k) const
+  throw (MEDEXCEPTION)
 {
   const char * LOC = "GRID::getNodePosition(Number, i,j,k) :";
   
+  BEGIN_OF(LOC);
+
   if (Number <= 0 || Number > _numberOfNodes)
     throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number));
 
-  int Len[] = {_iArrayLength, _jArrayLength, _kArrayLength }, I=0, J=1, K=2;
+  int Len[] = {_iArrayLength, _jArrayLength, _kArrayLength }, I=0, J=1;
+  // , K=2; !! UNUSED VARIABLE !!
 
   int ijLen = Len[I] * Len[J]; // nb in a full k layer
   int kLen = (Number - 1) % ijLen;    // nb in the non full k layer
@@ -775,6 +789,9 @@ void GRID::getNodePosition(const int Number, int& i, int& j, int& k)
   k = (Number - 1) / ijLen;
 
   ////cout <<" NODE POS: " << Number << " - " << i << ", " << j << ", " << k << endl;
+
+  END_OF(LOC);
+
 }
 
 //=======================================================================
@@ -782,12 +799,15 @@ void GRID::getNodePosition(const int Number, int& i, int& j, int& k)
 //purpose  : 
 //=======================================================================
 
-void GRID::getCellPosition(const int Number, int& i, int& j, int& k)
-     throw (MEDEXCEPTION)
+void GRID::getCellPosition(const int Number, int& i, int& j, int& k) const
+  throw (MEDEXCEPTION)
 {
   const char * LOC = "GRID::getCellPosition(Number, i,j,k) :";
   
-  int Len[4] = {0,_iArrayLength-1, _jArrayLength-1, _kArrayLength-1 }, I=1, J=2, K=3;
+  BEGIN_OF(LOC);
+
+  int Len[4] = {0,_iArrayLength-1, _jArrayLength-1, _kArrayLength-1 }, I=1, J=2;
+  // , K=3; !! UNUSED VARIABLE !!
 
 //  if (Number <= 0 || Number > getCellNumber(Len[I]-1, Len[J]-1, Len[K]-1))
 //    throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number));
@@ -798,6 +818,8 @@ void GRID::getCellPosition(const int Number, int& i, int& j, int& k)
   i = kLen % Len[J];
   j = kLen / Len[J];
   k = (Number - 1) / ijLen;
+
+  END_OF(LOC);
 }
 
 //=======================================================================
@@ -806,10 +828,12 @@ void GRID::getCellPosition(const int Number, int& i, int& j, int& k)
 //=======================================================================
 
 void GRID::getEdgePosition(const int Number, int& Axis, int& i, int& j, int& k)
-     throw (MEDEXCEPTION)
+  const throw (MEDEXCEPTION)
 {
   const char * LOC = "GRID::getEdgePosition(Number, i,j,k) :";
 
+  BEGIN_OF(LOC);
+
   if (!_jArrayLength)
     throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "no edges in the grid: "));
   
@@ -849,6 +873,9 @@ void GRID::getEdgePosition(const int Number, int& Axis, int& i, int& j, int& k)
       j = kLen / Len[J];
       k = (theNb - 1) / ijLen;
     }
+
+    END_OF(LOC);
+
     return;
   }
   
@@ -866,15 +893,17 @@ void GRID::getEdgePosition(const int Number, int& Axis, int& i, int& j, int& k)
 //=======================================================================
 
 void GRID::getFacePosition(const int Number, int& Axis, int& i, int& j, int& k)
-     throw (MEDEXCEPTION)
+  const throw (MEDEXCEPTION)
 {
   const char * LOC = "GRID::getFacePosition(Number, i,j,k) :";
 
-     if (_kArrayLength == 0) {
-         getCellPosition(Number, i, j, k);
-         Axis = 1;
-         return;
-     };
+  BEGIN_OF(LOC);
+
+  if (_kArrayLength == 0) {
+    getCellPosition(Number, i, j, k);
+    Axis = 1;
+    return;
+  };
 
   if (!_kArrayLength)
     throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "no faces in the grid: "));
@@ -913,6 +942,9 @@ void GRID::getFacePosition(const int Number, int& Axis, int& i, int& j, int& k)
       j = kLen / Len[J];
       k = (theNb - 1) / ijLen;
     }
+
+    END_OF(LOC);
+
     return;
   }
   
@@ -949,3 +981,25 @@ void GRID::writeUnstructured(int index, const string & driverName)
                          ); 
   END_OF(LOC);
 }
+
+void GRID::read(int index)  
+{ 
+  const char * LOC = "GRID::read(int index=0) : ";
+  BEGIN_OF(LOC);
+
+  if (_drivers[index]) {
+    _drivers[index]->open();   
+    _drivers[index]->read(); 
+    _drivers[index]->close(); 
+  }
+  else
+    throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) 
+                                     << "The index given is invalid, index must be between  0 and |" 
+                                     << _drivers.size() 
+                                     )
+                          );
+  if (_isAGrid)
+    fillMeshAfterRead();
+
+  END_OF(LOC);
+}
index 09f938bc5ad682da42924fddc2c049c8a2bed379..4c19f21491ed1a4d3614e268cb358cbb7152e159 100644 (file)
@@ -1,13 +1,12 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  CEA/DEN, EDF R&D
-//
-//
-//
-//  File   : MEDMEM_Grid.hxx
-//  Author : Edward AGAPOV (eap)
-//  Module : MED
-//  $Header$
+// File      : MEDMEM_Grid.hxx
+// Created   : Wed Dec 18 08:35:26 2002
+// Descr     : class containing structured mesh data
+
+// Author    : Edward AGAPOV (eap)
+// Project   : SALOME Pro
+// Module    : MED 
+// Copyright : Open CASCADE
+// $Header$
 
 #ifndef MEDMEM_Grid_HeaderFile
 #define MEDMEM_Grid_HeaderFile
@@ -47,11 +46,10 @@ class GRID: public MESH
   //   Protected Methods
   //-----------------------//
 
-  CONNECTIVITY * makeConnectivity (const medEntityMesh      Entity,
-                                   const medGeometryElement Geometry,
-                                   const int                NbEntities,
-                                   const int                NbNodes,
-                                   int *                    NodeNumbers);
+  CONNECTIVITY * makeConnectivity (const medEntityMesh Entity,
+                                  const medGeometryElement Geometry,
+                                  const int NbEntities, const int NbNodes,
+                                  int * NodeNumbers) const ;
   // creates nodal connectivity
 
   
@@ -84,8 +82,8 @@ class GRID: public MESH
   virtual ~GRID();
   virtual void init();
 
-  void fillCoordinates();
-  void fillConnectivity();
+  void fillCoordinates() const ;
+  void fillConnectivity() const ;
   // fill _coordinates and _connectivity of MESH if not yet done
 
   inline void makeUnstructured();
@@ -97,6 +95,8 @@ class GRID: public MESH
   void writeUnstructured(int index=0, const string & driverName = "");
   // write a Grid as an Unstructured mesh
 
+  void read(int index=0);
+
   //   API Methods returning fields of MESH that are filled while reading.
   //   So they need not to be redefined
 
@@ -143,16 +143,16 @@ class GRID: public MESH
 
   // Specific GRID methods
 
-  inline int getNodeNumber(const int i, const int j=0, const int k=0);
+  inline int getNodeNumber(const int i, const int j=0, const int k=0) const;
   // return a NODE number by its position in the grid.
   // WARNING: be carefull, there is no check that i,j,k are within a good range
   // A good range is: 0 <= X < getArrayLength( X_Axis )
-  inline int getCellNumber(const int i, const int j=0, const int k=0) ;
+  inline int getCellNumber(const int i, const int j=0, const int k=0) const ;
   // return a CELL number by its position in the grid.
   // WARNING: be carefull, there is no check that i,j,k are within a good range
   // A good range is: 0 <= X < (getArrayLength( X_Axis )-1)
 
-  int getEdgeNumber(const int Axis, const int i, const int j=0, const int k=0) throw (MEDEXCEPTION) ;
+  int getEdgeNumber(const int Axis, const int i, const int j=0, const int k=0) const throw (MEDEXCEPTION) ;
   // return an EDGE number by its position in the grid.
   // Axis [1,2,3] means one of directions: along i, j or k.
   // It selects an edge of ones having same (i,j,k):
@@ -163,7 +163,7 @@ class GRID: public MESH
   // 0 <= X < (getArrayLength( X_Axis )-1)
   // 0 <= X < getArrayLength( NOT_X_Axis )
 
-  int getFaceNumber(const int Axis, const int i, const int j=0, const int k=0) throw (MEDEXCEPTION) ;
+  int getFaceNumber(const int Axis, const int i, const int j=0, const int k=0) const throw (MEDEXCEPTION) ;
   // return a FACE number by its position in the grid.
   // Axis [1,2,3] means one of directions: along i, j or k.
   // It selects a face of ones having same (i,j,k):
@@ -175,10 +175,10 @@ class GRID: public MESH
   // 0 <= X < getArrayLength( X_Axis )
   
 
-  void getNodePosition(const int Number, int& i, int& j, int& k) throw (MEDEXCEPTION) ;
-  void getCellPosition(const int Number, int& i, int& j, int& k) throw (MEDEXCEPTION) ;
-  void getEdgePosition(const int Number, int& Axis, int& i, int& j, int& k) throw (MEDEXCEPTION) ;
-  void getFacePosition(const int Number, int& Axis, int& i, int& j, int& k) throw (MEDEXCEPTION) ;
+  void getNodePosition(const int Number, int& i, int& j, int& k) const throw (MEDEXCEPTION) ;
+  void getCellPosition(const int Number, int& i, int& j, int& k) const throw (MEDEXCEPTION) ;
+  void getEdgePosition(const int Number, int& Axis, int& i, int& j, int& k) const throw (MEDEXCEPTION) ;
+  void getFacePosition(const int Number, int& Axis, int& i, int& j, int& k) const throw (MEDEXCEPTION) ;
   // return position (i,j,k) of an entity #Number
   // Axis: [1,2,3], see get*Number for details
   // Exception for Number out of range
@@ -189,15 +189,58 @@ class GRID: public MESH
   inline med_grid_type getGridType() const;
   // return MED_CARTESIAN, MED_POLAR or MED_BODY_FITTED
 
-  int getArrayLength( const int Axis ) throw (MEDEXCEPTION);
+  int getArrayLength( const int Axis ) const throw (MEDEXCEPTION);
   // return array length. Axis = [1,2,3] meaning [i,j,k],
   // exception if Axis out of [1-3] range
 
-  const double getArrayValue (const int Axis, const int i) throw (MEDEXCEPTION) ;
+  const double getArrayValue (const int Axis, const int i) const throw (MEDEXCEPTION) ;
   // return i-th array component. Axis = [1,2,3] meaning [i,j,k],
   // exception if Axis out of [1 - 3] range
   // exception if i is out of range [0 - (getArrayLength(Axis)-1)];
 
+  inline const COORDINATE * getCoordinateptr() const;
+
+  inline const double * getCoordinates(medModeSwitch Mode) const;
+
+  inline const double getCoordinate(int Number,int Axis) const;
+
+  inline int getNumberOfTypes(medEntityMesh Entity) const;
+
+  inline const medGeometryElement * getTypes(medEntityMesh Entity) const;
+
+  inline const CELLMODEL * getCellsTypes(medEntityMesh Entity) const;
+
+  const int * getGlobalNumberingIndex(medEntityMesh Entity) const;
+
+  inline int getNumberOfElements(medEntityMesh Entity,
+                                medGeometryElement Type) const;
+
+  inline bool existConnectivity(medConnectivity ConnectivityType,
+                               medEntityMesh Entity) const;
+
+  inline medGeometryElement getElementType(medEntityMesh Entity,
+                                          int Number) const;
+
+  inline void calculateConnectivity(medModeSwitch Mode,
+                                   medConnectivity ConnectivityType,
+                                   medEntityMesh Entity) const ;
+
+  inline const CONNECTIVITY* getConnectivityptr() const;
+
+  inline const int * getConnectivity(medModeSwitch Mode,
+                                    medConnectivity ConnectivityType,
+                                    medEntityMesh Entity, 
+                                    medGeometryElement Type) const;
+
+  inline const int * getConnectivityIndex(medConnectivity ConnectivityType,
+                                         medEntityMesh Entity) const;
+
+  inline const int * getReverseConnectivity(medConnectivity ConnectivityType,
+                                           medEntityMesh Entity=MED_CELL) const;
+
+  inline const int * getReverseConnectivityIndex(medConnectivity ConnectivityType,
+                                                medEntityMesh Entity=MED_CELL) const;
+
   //  Setting fields
 
   inline void setGridType(med_grid_type gridType);
@@ -221,7 +264,7 @@ inline med_grid_type GRID::getGridType() const
 //purpose  : 
 //=======================================================================
 
-inline int GRID::getNodeNumber(const int i, const int j, const int k)
+inline int GRID::getNodeNumber(const int i, const int j, const int k) const
 {
   return 1 + i + _iArrayLength * j + _iArrayLength * _jArrayLength * k;
 }
@@ -231,7 +274,7 @@ inline int GRID::getNodeNumber(const int i, const int j, const int k)
 //purpose  : 
 //=======================================================================
 
-inline int GRID::getCellNumber(const int i, const int j, const int k)
+inline int GRID::getCellNumber(const int i, const int j, const int k) const
 {
   return 1 + i + (_iArrayLength-1) * j + (_iArrayLength-1) * (_jArrayLength-1) * k;
 }
@@ -257,4 +300,259 @@ inline void GRID::setGridType(med_grid_type gridType)
   _gridType = gridType;
 }
 
+/*! Get the COORDINATES object. Use it only if you need COORDINATES informations not provided by the GRID class via the MESH class.*/
+inline const COORDINATE * GRID::getCoordinateptr() const
+{
+  fillCoordinates();
+  return _coordinate;
+}
+
+/*! Get the whole coordinates array in a given interlacing mode. The interlacing mode are :
+  - MED_NO_INTERLACE   :  X1 X2 Y1 Y2 Z1 Z2
+  - MED_FULL_INTERLACE :  X1 Y1 Z1 X2 Y2 Z2
+ */
+inline const double * GRID::getCoordinates(medModeSwitch Mode) const
+{
+  fillCoordinates();
+  return _coordinate->getCoordinates(Mode);
+}
+
+/*! Get the coordinate n° number on axis n°axis*/
+inline const double GRID::getCoordinate(int number, int axis) const
+{
+  fillCoordinates();
+  return _coordinate->getCoordinate(number,axis);
+}
+
+/*! Get the number of different geometric types for a given entity type.
+
+    medEntityMesh entity : MED_CELL, MED_FACE, MED_EDGE, MED_NODE,
+    MED_ALL_ENTITIES
+
+    If entity is not defined, return 0.
+
+    If there is no connectivity, return an exception.
+*/
+inline int GRID::getNumberOfTypes(medEntityMesh entity) const
+{
+  MESSAGE("GRID::getNumberOfTypes(medEntityMesh entity) : "<<entity);
+  if (entity == MED_NODE)
+    return 1;
+
+  fillConnectivity();
+
+  if (_connectivity != NULL)
+    return _connectivity->getNumberOfTypes(entity);
+  throw MEDEXCEPTION(LOCALIZED("GRID::getNumberOfTypes( medEntityMesh ) : Connectivity not defined !"));
+}
+
+/*!
+  Get the list of geometric types used by a given entity.
+  medEntityMesh entity : MED_CELL, MED_FACE, MED_EDGE, MED_ALL_ENTITIES
+
+  REM : Don't use MED_NODE
+
+  If entity is not defined, return an exception.
+*/
+inline const medGeometryElement * GRID::getTypes(medEntityMesh entity) const
+{
+  if (entity == MED_NODE)
+    throw MEDEXCEPTION(LOCALIZED("GRID::getTypes( medEntityMesh ) : No medGeometryElement with MED_NODE entity !"));
+  // return un tableau de taille 1 contenant MED_NONE, comme les supports pour etre coherent avec getNumberOfTypes ???? PG
+
+  fillConnectivity();
+
+  if (_connectivity != NULL)
+    return _connectivity->getGeometricTypes(entity);
+  throw MEDEXCEPTION(LOCALIZED("GRID::getTypes( medEntityMesh ) : Connectivity not defined !"));
+}
+
+/*!
+  Get the whole list of CELLMODEL used by cells of given type (medEntityMesh).
+
+  REMARK : Don't use MED_NODE as medEntityMesh
+*/
+inline const CELLMODEL * GRID::getCellsTypes(medEntityMesh Entity) const
+{
+  fillConnectivity();
+
+  if (_connectivity != NULL)
+    return _connectivity->getCellsTypes(Entity);
+  throw MEDEXCEPTION(LOCALIZED("GRID::getCellsTypes( medEntityMesh ) : Connectivity not defined !"));
+}
+
+/*! Return an array of size NumbreOfTypes+1 which contains, for each
+    geometric type of the given entity, the first global element number
+    of this type.
+
+    For exemple, if we have a mesh with 5 triangles and 4 quadrangle :
+    - size of GlobalNumberingIndex is 3
+    - GlobalNumberingIndex[0]=1 (the first type)
+    - GlobalNumberingIndex[1]=6 (the second type)
+    - GlobalNumberingIndex[2]=10
+*/
+inline const int * GRID::getGlobalNumberingIndex(medEntityMesh entity) const
+{
+  fillConnectivity();
+
+  if (_connectivity != NULL)
+    return _connectivity->getGlobalNumberingIndex(entity);
+  throw MEDEXCEPTION(LOCALIZED("GRID::getNumberOfTypes( medEntityMesh ) : Connectivity not defined !"));
+}
+
+/*!
+  Return the number of element of given geometric type of given entity. Return 0 if query is not defined.
+
+  Example :
+  - getNumberOfElements(MED_NODE,MED_NONE) : number of node
+  - getNumberOfElements(MED_NODE,MED_TRIA3) : return 0 (not defined)
+  - getNumberOfElements(MED_FACE,MED_TRIA3) : return number of triangles
+  elements defined in face entity (0 if not defined)
+  - getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) : return total number
+  of elements defined in cell entity
+*/
+inline int GRID::getNumberOfElements(medEntityMesh entity, medGeometryElement Type) const
+{
+  //  const char * LOC = "MESH::getNumberOfElements(medEntityMesh,medGeometryElement) : ";
+  if (entity==MED_NODE)
+    if ((Type==MED_NONE)|(Type==MED_ALL_ELEMENTS))
+      return _numberOfNodes;
+    else
+      return 0;
+  //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"wrong medGeometryElement with MED_NODE"));
+  else
+    {
+      fillConnectivity();
+
+      if (_connectivity != (CONNECTIVITY*)NULL)
+       return _connectivity->getNumberOf(entity,Type);
+      else
+       return 0;
+      //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"connectivity not defined !"));
+    }
+}
+
+/*!
+  Return true if the wanted connectivity exist, else return false
+  (to use before a getSomething method).
+ */
+inline bool GRID::existConnectivity(medConnectivity connectivityType, medEntityMesh entity) const
+{
+  fillConnectivity();
+
+  if (_connectivity==(CONNECTIVITY*)NULL)
+    throw MEDEXCEPTION("GRID::existConnectivity(medConnectivity,medEntityMesh) : no connectivity defined !");
+  return _connectivity->existConnectivity(connectivityType,entity);
+}
+
+/*!
+  Return the geometric type of global element Number of entity Entity.
+
+  Throw an exception if Entity is not defined or Number are wrong (too big).
+ */
+inline medGeometryElement GRID::getElementType(medEntityMesh Entity,int Number) const
+{
+  fillConnectivity();
+
+  if (_connectivity==(CONNECTIVITY*)NULL)
+    throw MEDEXCEPTION("GRID::getElementType(medEntityMesh,int) : no connectivity defined !");
+  return _connectivity->getElementType(Entity,Number);
+}
+
+/*!
+  Calculate the ask connectivity. Return an exception if this could not be
+  done. Do nothing if connectivity already exist.
+ */
+
+inline void GRID::calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity) const
+{
+  fillConnectivity();
+
+  if (Mode==MED_FULL_INTERLACE)
+    _connectivity->calculateConnectivity(ConnectivityType,entity);
+  else
+    throw MEDEXCEPTION(LOCALIZED("GRID::calculateConnectivity : only for MED_FULL_INTERLACE mode"));
+}
+
+inline const CONNECTIVITY* GRID::getConnectivityptr() const
+{
+  fillConnectivity();
+
+  return _connectivity;
+}
+
+/*!
+  Return the required connectivity in the right mode for the given
+  geometric type of the given entity.
+
+  To get connectivity for all geometric type, use Mode=MED_FULL_INTERLACE
+  and Type=MED_ALL_ELEMENTS.
+  You must also get the corresponding index array.
+ */
+inline const int * GRID::getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity, medGeometryElement Type) const
+{
+  fillConnectivity();
+
+  if (Mode==MED_FULL_INTERLACE)
+    return _connectivity->getConnectivity(ConnectivityType,entity,Type);
+  throw MEDEXCEPTION(LOCALIZED("GRID::getConnectivity : only for MED_FULL_INTERLACE mode"));
+}
+
+/*!
+  Return the required index array for a connectivity received in
+  MED_FULL_ENTERLACE mode and MED_ALL_ELEMENTS type.
+
+  This array allow to find connectivity of each elements.
+
+  Example : Connectivity of i^{th} elements (1<=i<=NumberOfElement) begin
+  at index ConnectivityIndex[i-1] and end at index ConnectivityIndex[i]-1
+  in Connectivity array (Connectivity[ConnectivityIndex[i-1]-1] is the
+  first value)
+ */
+inline const int * GRID::getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh entity) const
+{
+  fillConnectivity();
+
+  return _connectivity->getConnectivityIndex(ConnectivityType, entity);
+}
+
+/*!
+  Return the reverse connectivity required by ConnectivityType :
+  - If ConnectivityType=MED_NODAL : return connectivity node-cell
+  - If ConnectivityType=MED_DESCENDING : return connectivity face-cell
+
+  You must get ReverseConnectivityIndex array to use it.
+ */
+inline const int * GRID::getReverseConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity/*=MED_CELL*/) const
+{
+  fillConnectivity();
+
+  if (NULL==_connectivity)
+    throw MEDEXCEPTION("GRID::getReverseConnectivity : no connectivity defined in MESH !");
+
+  return _connectivity->getReverseConnectivity(ConnectivityType,Entity);
+}
+
+/*!
+  Return the index array required by ConnectivityType.
+
+  This array allow to find reverse connectivity of each elements.
+
+  Example : Reverse connectivity of i^{th} elements (1<=i<=NumberOfElement)
+  begin at index ReverseConnectivityIndex[i-1] and end at index
+  ReverseConnectivityIndex[i]-1
+  in ReverseConnectivity array (
+  ReverseConnectivity[ReverseConnectivityIndex[i-1]-1]
+  is the first value)
+ */
+inline const int * GRID::getReverseConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity/*=MED_CELL*/) const
+{
+  fillConnectivity();
+
+  if (NULL==_connectivity)
+    throw MEDEXCEPTION("GRID::getReverseConnectivityIndex : no connectivity defined in MESH !");
+
+  return _connectivity->getReverseConnectivityIndex(ConnectivityType,Entity);
+}
+
 #endif
index 4a883f3a5ee09704534fb9f9cc5381d8c5b1ef98..b59d981a587674e18b0a1786bfdf860a9bb5165c 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Group.cxx
-//  Module : MED
-
 using namespace std;
 /*
  File Group.cxx
@@ -80,12 +54,18 @@ GROUP::GROUP(const string & name, const list<FAMILY*> & families) throw (MEDEXCE
   _mesh =  myFamily->getMesh() ;
   _entity = myFamily->getEntity() ;
   bool isOnAllElts = myFamily->isOnAllElements() ;
+
+  SCRUTE(isOnAllElts);
+  SCRUTE(numberOfFamilies);
+
+
   if ((numberOfFamilies==1)&(isOnAllElts))
     {
       _numberOfFamilies = numberOfFamilies;
-      _isOnAllElts = false ;
+      _isOnAllElts = isOnAllElts ;
       _family.resize(_numberOfFamilies) ;
       _family[0] = myFamily;
+      update();
       return;
     }
   else if ((!(numberOfFamilies==1))&(isOnAllElts))
@@ -99,11 +79,15 @@ GROUP::GROUP(const string & name, const list<FAMILY*> & families) throw (MEDEXCE
   const medGeometryElement * geometricType = myFamily->getTypes() ;
   //int * geometricTypeNumber = myFamily->getGeometricTypeNumber() ;
   const int * numberOfGaussPoint = myFamily->getNumberOfGaussPoint() ;
+
+  SCRUTE(_numberOfGeometricType);
+
   for (int i=0 ; i<_numberOfGeometricType; i++) {
     _geometricType[i]= geometricType[i] ;
     // _geometricTypeNumber[i] = geometricTypeNumber[i] ;
     _numberOfGaussPoint[i] = numberOfGaussPoint[i] ;
     _numberOfElements[i]=myFamily->getNumberOfElements(geometricType[i]);
+    MESSAGE(LOC << " Type : " << _geometricType[i] << " number of element(s) " << _numberOfElements[i]);
   }
   _isOnAllElts = false ;
   //_totalNumberOfEntities = myFamily->getNumberOfElements(MED_ALL_ELEMENTS) ;
@@ -112,6 +96,10 @@ GROUP::GROUP(const string & name, const list<FAMILY*> & families) throw (MEDEXCE
   _numberOfFamilies = families.size();
   _family.resize(_numberOfFamilies) ;
   list<FAMILY*>::const_iterator li ;
+
+  MESSAGE(LOC<<"Printing of the object GROUP built right before the blending"<< (SUPPORT) *this);
+
+
   int it = 0 ;
   for (li=families.begin();li!=families.end();li++) {
     blending(*li);
@@ -119,6 +107,8 @@ GROUP::GROUP(const string & name, const list<FAMILY*> & families) throw (MEDEXCE
     it++ ;
   }
 
+  MESSAGE(LOC<<"Printing of the object GROUP built "<< *this);
+
   END_OF(LOC);
 };
 
index c19dcdbba7064f8db294156b51815af3671eea27..46e3ab9eff26f1586fa351ff7d149f36e604939f 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Group.hxx
-//  Module : MED
-
 /*
  File Group.hxx
  $Header$
@@ -47,18 +21,20 @@ class FAMILY;
 
 */
 
-class GROUP : public SUPPORT
+class GROUP : virtual public SUPPORT
 {
 protected :
   /*!
     \if developper
     Number of families in the group.
+    \endif
   */
   int             _numberOfFamilies ;
   /*!
     \if developper
     Vector of families in the group.
     Note that Families are numbered from 1 to N.
+    \endif
   */
   vector<FAMILY*> _family ;
   
@@ -70,7 +46,7 @@ public:
   /*! Copy Constructor. */
   GROUP(const GROUP & m);
   /*! Destructor. */
-  ~GROUP();
+  virtual ~GROUP();
 
   /*! Copy operator. */
   // PN ATTention il n y a pas de copie du vecteur Family ????
diff --git a/src/MEDMEM/MEDMEM_InterpolationWrappers.hxx b/src/MEDMEM/MEDMEM_InterpolationWrappers.hxx
new file mode 100644 (file)
index 0000000..766994f
--- /dev/null
@@ -0,0 +1,75 @@
+
+#ifndef WRAPPERS_HPP
+#define WRAPPERS_HPP
+
+// les classes de wrapping
+
+template <int DIMENSION> class Wrapper_Noeud
+{
+protected :
+  double * coordonnees;
+public :
+       Wrapper_Noeud():coordonnees(NULL) 
+               {
+               }
+        Wrapper_Noeud(const double * coord):coordonnees( (double *) coord) 
+               {
+               }
+       ~Wrapper_Noeud() 
+               {
+               coordonnees=NULL;
+               }
+       void positionne(double *place) 
+               {
+               coordonnees=place;
+               }
+       const double & operator[] (int i) const
+               {
+               return coordonnees[i];
+               }
+       double operator[] (int i)
+               {
+               return coordonnees[i];
+               }
+       friend double DistanceInf(const Wrapper_Noeud<DIMENSION> &A,const Wrapper_Noeud<DIMENSION> &B) 
+               {
+               double max=0;
+               double tmp;
+               for (int i=0;i<DIMENSION;i++)
+                       {
+                       tmp=fabs(A[i]-B[i]);
+                       if (tmp>max) max=tmp;
+                       }
+               return max;
+               }
+       friend double DistanceL2(const Wrapper_Noeud<DIMENSION> &A,const Wrapper_Noeud<DIMENSION> &B)  
+               {
+               double tmp,somme=0;
+               for (int i=0;i<DIMENSION;i++)
+                       {
+                       tmp=(A[i]-B[i]);
+                       somme+=tmp*tmp;
+                       }
+               return sqrt(somme);
+               }
+       };
+       
+template <int DIMENSION> class Wrapper_Nuage
+       {
+       protected : 
+               int nbr_noeuds;
+                const double *  noeuds;
+               Wrapper_Noeud<DIMENSION> show;
+       public :
+               Wrapper_Nuage():nbr_noeuds(0),noeuds(NULL) {}
+                Wrapper_Nuage( const double * const n, int nn):nbr_noeuds(nn),noeuds(n),show(noeuds) {}
+               ~Wrapper_Nuage() {noeuds=NULL;}
+               Wrapper_Noeud<DIMENSION> & operator [] (int i)
+                       {
+                       show.positionne((double *) &noeuds[DIMENSION*i]);
+                       return show;
+                       }
+               int size() const {return nbr_noeuds;}
+       };
+
+#endif
index bc242f80e5a9fa447c395356a473cb3e2e918cae..31821b8ccfe9c40022a6a71dfc6c04b396e24c29 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Med.cxx
-//  Module : MED
-
 using namespace std;
 # include <string> 
 
@@ -53,6 +27,8 @@ MED::MED(driverTypes driverType, const string & fileName)
   const char * LOC = "MED::MED(driverTypes driverType, const string & fileName) : ";
   BEGIN_OF(LOC);
 
+  MESSAGE(LOC << "driverType = " << driverType);
+
   MED_MED_RDONLY_DRIVER * myDriver = new MED_MED_RDONLY_DRIVER(fileName,this) ;
   int current = addDriver(*myDriver);
   //int current= addDriver(driverType,fileName);
@@ -122,18 +98,15 @@ MED::~MED()
     if ( (*currentField).first != NULL) {
       // cast in right type to delete it !
       switch ((*currentField).first->getValueType()) {
-      case MED_INT32 :
-        // mpv: such recursive destructors call is problematic for current ALLIANCES algorithms 
-       //delete (FIELD<int>*) (*currentField).first ;
+      case MED_INT32 : 
+       delete (FIELD<int>*) (*currentField).first ;
        break ;
       case MED_REEL64 :
-        // mpv: such recursive destructors call is problematic for current ALLIANCES algorithms 
-       //delete (FIELD<double>*) (*currentField).first ;
+       delete (FIELD<double>*) (*currentField).first ;
        break ;
       default : 
-       INFOS("Field has type different of int or double, could not destroy its values array !") ;
-        // mpv: such recursive destructors call is problematic for current ALLIANCES algorithms 
-       //delete (*currentField).first;
+       MESSAGE(LOC << "Field has type different of int or double, could not destroy its values array !") ;
+       delete (*currentField).first;
       }
     }
   }
@@ -141,8 +114,7 @@ MED::~MED()
   for ( itSupportOnMesh=_support.begin();itSupportOnMesh != _support.end(); itSupportOnMesh++ ) {
     map<MED_FR::med_entite_maillage,SUPPORT *>::iterator itSupport ;
     for ( itSupport=(*itSupportOnMesh).second.begin();itSupport!=(*itSupportOnMesh).second.end();itSupport++)
-        ;// mpv: such recursive destructors call is problematic for current ALLIANCES algorithms 
-       //delete (*itSupport).second ;
+       delete (*itSupport).second ;
   }
 
   //  map<MESH_NAME_,MESH*>::const_iterator  currentMesh;
@@ -150,11 +122,9 @@ MED::~MED()
     if ( (*currentMesh).second != NULL)
       {
        if (!((*currentMesh).second)->getIsAGrid())
-          ;// mpv: such recursive destructors call is problematic for current ALLIANCES algorithms 
-         //delete (*currentMesh).second;
+         delete (*currentMesh).second;
        else
-          ;// mpv: such recursive destructors call is problematic for current ALLIANCES algorithms 
-         //delete (GRID *) (*currentMesh).second;
+         delete (GRID *) (*currentMesh).second;
       }
   }
 
@@ -162,7 +132,7 @@ MED::~MED()
 
   MESSAGE(LOC << "In this object MED there is(are) " << index << " driver(s):");
 
-  for (int ind=0; ind < _drivers.size(); ind++ )
+  for (unsigned int ind=0; ind < _drivers.size(); ind++ )
     {
       SCRUTE(_drivers[ind]);
       if ( _drivers[ind] != NULL) delete _drivers[ind];
@@ -191,15 +161,50 @@ int MED::addDriver(driverTypes driverType, const string & fileName="Default File
   const char * LOC = "MED::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\") : ";
   GENDRIVER * driver;
   int current;
+  int itDriver = (int) NO_DRIVER;
 
   BEGIN_OF(LOC);
 
   MESSAGE(LOC << " the file name is " << fileName);
-  driver = instances[driverType]->run(fileName, this) ;
+
+  SCRUTE(driverType);
+
+  SCRUTE(instances[driverType]);
+
+  switch(driverType)
+    {
+    case MED_DRIVER : {
+      itDriver = (int) driverType ;
+      break ;
+    }
+
+    case VTK_DRIVER : {
+      itDriver = 1 ;
+      break ;
+    }
+
+    case GIBI_DRIVER : {
+      throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "GIBI_DRIVER has been specified to the method which is not allowed because there is no GIBI driver for the MED object"));
+      break;
+    }
+
+    case NO_DRIVER : {
+      throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "NO_DRIVER has been specified to the method which is not allowed"));
+      break;
+    }
+    }
+
+  if (itDriver == ((int) NO_DRIVER))
+    throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "NO_DRIVER has been specified to the method which is not allowed"));
+
+  driver = instances[itDriver]->run(fileName, this) ;
+
   current = _drivers.size()-1;
+
   driver->setId(current); 
 
   END_OF(LOC);
+
   return current;
 }
 
@@ -392,7 +397,7 @@ void MED::getMeshNames      ( string * meshNames ) const
 {
   const char * LOC = "MED::getMeshNames ( string * ) const : ";
   BEGIN_OF(LOC);
-  int meshNamesSize;
+  unsigned int meshNamesSize;
   
   if (  ( meshNamesSize = sizeof(meshNames) / sizeof(string *) )
        != _meshes.size() )
@@ -518,7 +523,7 @@ void MED::getFieldNames     ( string * fieldNames ) const
   const char * LOC = "MED::getFieldNames ( string * ) const : ";
   BEGIN_OF(LOC);
 
-  int fieldNamesSize =  sizeof(fieldNames) / sizeof(string *);
+  unsigned int fieldNamesSize =  sizeof(fieldNames) / sizeof(string *);
  
   if ( fieldNamesSize != _fields.size() )
     throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) 
@@ -684,16 +689,51 @@ SUPPORT *  MED::getSupport (const string & meshName,MED_FR::med_entite_maillage
   const char * LOC = "MED::getSupport ( const string, MED_FR::med_entite_maillage ) const : ";
   BEGIN_OF(LOC);
 
-  map<MESH_NAME_, map<MED_FR::med_entite_maillage,SUPPORT *> >::const_iterator itSupportOnMesh = _support.find(meshName) ;
+  int index = 0;
+  for (map<MESH_NAME_, map<MED_FR::med_entite_maillage,SUPPORT *> >::const_iterator const_itSupportOnMesh=_support.begin(); const_itSupportOnMesh != _support.end();
+       const_itSupportOnMesh++ )
+    {
+      map<MED_FR::med_entite_maillage,SUPPORT *>::const_iterator const_itSupport ;
+      for (const_itSupport=(*const_itSupportOnMesh).second.begin();
+          const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++) index++;
+    }
+
+  MESSAGE(LOC << "In this MED object there is(are) " << index << " support(s):");
+
+  for (map<MESH_NAME_, map<MED_FR::med_entite_maillage,SUPPORT *> >::const_iterator const_itSupportOnMesh=_support.begin();const_itSupportOnMesh != _support.end(); const_itSupportOnMesh++ )
+    {
+      map<MED_FR::med_entite_maillage,SUPPORT *>::const_iterator const_itSupport ;
+      for (const_itSupport=(*const_itSupportOnMesh).second.begin();
+          const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++)
+       {
+         MESSAGE(LOC << "Support on mesh " << (*const_itSupportOnMesh).first << " on entity " << (*const_itSupport).first << " : " << *((*const_itSupport).second));
+       }
+  }
+
+
+  map<MESH_NAME_, map<MED_FR::med_entite_maillage,SUPPORT *> >::const_iterator const_itSupportOnMesh = _support.find(meshName) ;
   
-  if ( itSupportOnMesh == _support.end() )
+  if ( const_itSupportOnMesh == _support.end() )
     throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) 
                                      << "There is no support on mesh named |" 
                                      << meshName << "|"
                                      )
                           );
  
-  map<MED_FR::med_entite_maillage,SUPPORT *> & SupportOnMesh = (map<MED_FR::med_entite_maillage,SUPPORT *>&) ((*itSupportOnMesh).second) ;
+//   map<MED_FR::med_entite_maillage,SUPPORT *> & SupportOnMesh = (map<MED_FR::med_entite_maillage,SUPPORT *>&) ((*itSupportOnMesh).second) ;
+//   map<MED_FR::med_entite_maillage,SUPPORT *>::const_iterator itSupport = SupportOnMesh.find(entity) ;
+  
+//   if (itSupport == SupportOnMesh.end() )
+//     throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) 
+//                                      << "There is no support on entity "
+//                                  << entity << " in mesh named |" 
+//                                      << meshName << "|"
+//                                      )
+//                           );
+
+
+  map<MED_FR::med_entite_maillage,SUPPORT *> SupportOnMesh = ((*const_itSupportOnMesh).second);
+
   map<MED_FR::med_entite_maillage,SUPPORT *>::const_iterator itSupport = SupportOnMesh.find(entity) ;
   
   if (itSupport == SupportOnMesh.end() )
@@ -755,8 +795,12 @@ void MED::addMesh( MESH * const ptrMesh)
   if ( ! ( meshName = ptrMesh->getName()).size() ) 
     throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrMesh->_name must not be NULL !"));
 
+//   MESH * meshToMed = new MESH(*ptrMesh); DO WE HAVE TO COPY THE ENTRY MESH OR NOT ????? (NB)
+
   _meshes[meshName] = ptrMesh; // if ptrMesh->meshName already exists it is modified
 
+//   _meshes[meshName] = meshToMed;
+
   END_OF(LOC);
 }
 
@@ -799,7 +843,7 @@ void MED::addField( FIELD_ * const ptrField)
   _meshName [ptrField]        = meshName; // if it already exists it is replaced
   _meshes   [meshName]        = ptrMesh;  // if it already exists it is replaced
 
-  int  numberOfTypes = ptrSupport->getNumberOfTypes();
+  //  int  numberOfTypes = ptrSupport->getNumberOfTypes(); !! UNUSED VARIABLE !!
   _support  [meshName][ (MED_FR::med_entite_maillage) ptrSupport->getEntity()] = ptrSupport;// if it already exists it is replaced
 
 
index 7a5efb5cd4685bd1cd62f8ca947d85ffc5bfcc69..137120ae34975fbbb9fce4c8fb72f7a90f7590fa 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Med.hxx
-//  Module : MED
-
 # ifndef MED_HXX
 # define MED_HXX
 
index 805536bf214648f5a0bfe3ce69a7a39ada307155..490fd4b56fd52dec16207158efb0aea97b408987 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_MedFieldDriver.hxx
-//  Module : MED
-
 #ifndef MED_FIELD_DRIVER_HXX
 #define MED_FIELD_DRIVER_HXX
 
@@ -522,6 +496,7 @@ template <class T> void MED_FIELD_RDONLY_DRIVER<T>::read(void)
        MESSAGE("MED_GEOM :"<<(MED_FR::med_geometrie_element)Types[i]);
        MESSAGE("Iteration :"<<_ptrField->getIterationNumber());
        MESSAGE("Order :"<<_ptrField->getOrderNumber());
+        _ptrField->_numberOfValues+=NumberOfValues[i]; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!!
        if ( MED_FR::MEDchampLire(_medIdt,const_cast <char*> (MeshName.c_str()),
                                  const_cast <char*> (_fieldName.c_str()),
                                  (unsigned char*) myValues[i],
@@ -574,7 +549,7 @@ template <class T> void MED_FIELD_RDONLY_DRIVER<T>::read(void)
        for (int j=0; j<NumberOfTypes; j++) {
          T * myValue = myValues[j] ;
          int NumberOf = NumberOfValues[j] ;
-         _ptrField->_numberOfValues+=NumberOf; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!!
+//       _ptrField->_numberOfValues+=NumberOf; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!!
          int offset = NumberOf*i ;
          for (int k=0 ; k<NumberOf; k++) {
            //ValuesT[Count]=myValue[k+offset] ;
@@ -648,6 +623,8 @@ template <class T> void MED_FIELD_WRONLY_DRIVER<T>::write(void) const
 
       MED_EN::med_type_champ ValueType=_ptrField->getValueType() ;
       
+      MESSAGE("Template Type =|"<<ValueType<<"|");
+      
       // le champ existe deja ???
       char * champName = new char[MED_TAILLE_NOM+1] ;
       MED_FR::med_type_champ type ;
@@ -729,33 +706,63 @@ template <class T> void MED_FIELD_WRONLY_DRIVER<T>::write(void) const
       for (int i=0;i<NumberOfType;i++) {
        int NumberOfElements = mySupport->getNumberOfElements(Types[i]) ;
        
-       MESSAGE(" "<<_ptrField->getName());
-       MESSAGE(" "<<NumberOfElements);
-       MESSAGE(" "<<NumberOfGaussPoint[i]);
-       MESSAGE(" "<<mySupport->getEntity());
-       MESSAGE(" "<<Types[i]);
-       MESSAGE(" "<<_ptrField->getIterationNumber());
-       MESSAGE(" "<<_ptrField->getTime());
-       MESSAGE(" "<<_ptrField->getOrderNumber());
-       MESSAGE("MEDchampEcr :"<<MeshName.c_str());
-       
        const T * value = _ptrField->getValueI(MED_EN::MED_FULL_INTERLACE,Index) ;
-
-       err=MED_FR::MEDchampEcr(_medIdt, const_cast <char*> ( MeshName.c_str()) ,                         //( string(mesh_name).resize(MED_TAILLE_NOM).c_str())
+       
+       MESSAGE("_medIdt                         : "<<_medIdt);
+       MESSAGE("MeshName.c_str()                : "<<MeshName.c_str());
+       MESSAGE("_ptrField->getName()            : "<<_ptrField->getName());
+       MESSAGE("value                           : "<<value);
+       MESSAGE("NumberOfElements                : "<<NumberOfElements);
+       MESSAGE("NumberOfGaussPoint[i]           : "<<NumberOfGaussPoint[i]);
+       MESSAGE("mySupport->getEntity()          : "<<mySupport->getEntity());
+       MESSAGE("Types[i]                        : "<<Types[i]);
+       MESSAGE("_ptrField->getIterationNumber() : "<<_ptrField->getIterationNumber());
+       MESSAGE("_ptrField->getTime()            : "<<_ptrField->getTime());
+       MESSAGE("_ptrField->getOrderNumber()     : "<<_ptrField->getOrderNumber());
+       
+/*     char chanom[MED_TAILLE_NOM+1];
+       char chacomp[MED_TAILLE_NOM+1];
+       char chaunit[MED_TAILLE_NOM+1];
+       MED_FR::med_type_champ chatype;
+       med_int chancomp=1;
+       
+       err=MED_FR::MEDchampInfo(_medIdt,1,chanom,&chatype,chacomp,chaunit,chancomp);
+
+       if (err<0) 
+               {
+               cout<<"=======================================================================> gros probleme"<<endl;
+               exit(-1);
+               }
+       cout<<"==================> nom lu            = "<<chanom<<endl;
+       cout<<"==================> type lu           = "<<chatype<<endl;
+       cout<<"==================> nom composante lu = "<<chacomp<<endl;
+       cout<<"==================> nom unit lu       = "<<chaunit<<endl;
+       cout<<"==================> valeur de MED_FR::MED_REEL64 = "<<MED_FR::MED_REEL64<<endl;
+*/     
+
+       err=MED_FR::MEDchampEcr(_medIdt, 
+                               const_cast <char*> ( MeshName.c_str()) ,                         //( string(mesh_name).resize(MED_TAILLE_NOM).c_str())
                                const_cast <char*> ( (_ptrField->getName()).c_str()),
-                               (unsigned char*)value, MED_FR::MED_FULL_INTERLACE,
+                               (unsigned char*)value, 
+                               MED_FR::MED_FULL_INTERLACE,
                                NumberOfElements,
-                               NumberOfGaussPoint[i],MED_ALL, MED_NOPFL, MED_FR::MED_REMP,  // PROFIL NON GERE, mode de remplacement non géré
+                               NumberOfGaussPoint[i],
+                               MED_ALL,
+                               MED_NOPFL,
+                               MED_FR::MED_REMP,  // PROFIL NON GERE, mode de remplacement non géré
                                (MED_FR::med_entite_maillage)mySupport->getEntity(),
                                (MED_FR::med_geometrie_element)Types[i],
-                               _ptrField->getIterationNumber(),"        ",
-                               _ptrField->getTime(),_ptrField->getOrderNumber()
+                               _ptrField->getIterationNumber(),
+                               "        ",
+                               _ptrField->getTime(),
+                               _ptrField->getOrderNumber()
                                );
        if (err < MED_VALID )
          throw MEDEXCEPTION(LOCALIZED( STRING(LOC)
                                        <<": Error in writing Field "<< _ptrField->getName() <<", type "<<Types[i]
                                        )
                             );
+
        Index += NumberOfElements ;
        
       }
index 6b7d0933297a920a8ce58e90ca7fa20d3e8c20a4..fe58c36c6fc9337660cc6e0b0bb58de0d7568750 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_MedMedDriver.cxx
-//  Module : MED
-
 using namespace std;
 # include <string>
 
@@ -87,6 +61,7 @@ void MED_MED_DRIVER::write() const
 }
 GENDRIVER * MED_MED_DRIVER::copy(void) const
 {
+  return new MED_MED_DRIVER(*this) ;
 }
 void MED_MED_DRIVER::writeFrom() const
 {
@@ -223,7 +198,7 @@ void MED_MED_RDONLY_DRIVER::readFileStruct( void )
     char         meshName[MED_TAILLE_NOM+1]="";
     int          meshDim;
     MESH *       ptrMesh;
-    MED_MESH_RDWR_DRIVER * ptrDriver;
+    //    MED_MESH_RDWR_DRIVER * ptrDriver; !! UNUSED VARIABLE !!
     
     numberOfMeshes = MEDnMaa(_medIdt) ;
     if ( numberOfMeshes <= 0 ) 
@@ -287,6 +262,7 @@ void MED_MED_RDONLY_DRIVER::readFileStruct( void )
       MESSAGE(LOC<<"is" << (isAGrid ? "" : " NOT") << " a GRID and its name is "<<ptrMesh->getName());
 
       // we create all global support (for each entity type :
+      int index = 0;
       for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
        string supportName="SupportOnAll_" ;
        supportName+=entNames[(MED_FR::med_entite_maillage)(*currentEntity).first] ;
@@ -297,8 +273,44 @@ void MED_MED_RDONLY_DRIVER::readFileStruct( void )
        mySupport->setEntity((MED_EN::medEntityMesh) (*currentEntity).first);
        mySupport->setAll(true);
        (_ptrMed->_support)[meshName][(MED_FR::med_entite_maillage)(*currentEntity).first] = mySupport ;
+       MESSAGE(LOC<< "The support " << supportName.c_str() << " on entity " << (*currentEntity).first << " is built");
+       index++;
       }
+      MESSAGE(LOC <<"The mesh " <<ptrMesh->getName() << " has " << index << " support(s)");
     }
+
+    map<MESH_NAME_, map<MED_FR::med_entite_maillage,SUPPORT *> >::const_iterator const_itSupportOnMesh ;
+
+    int index = 0;
+
+    vector<SUPPORT *> vectSupp;
+    for (const_itSupportOnMesh=_ptrMed->_support.begin(); const_itSupportOnMesh != _ptrMed->_support.end();
+        const_itSupportOnMesh++ )
+      {
+       map<MED_FR::med_entite_maillage,SUPPORT *>::const_iterator const_itSupport ;
+       for (const_itSupport=(*const_itSupportOnMesh).second.begin();
+            const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++) index++;
+      }
+
+    MESSAGE(LOC << "In this MED object there is(are) " << index << " support(s):");
+
+    vectSupp.resize(index);
+
+    index = 0;
+    for (const_itSupportOnMesh=_ptrMed->_support.begin(); const_itSupportOnMesh != _ptrMed->_support.end();
+        const_itSupportOnMesh++ )
+      {
+       map<MED_FR::med_entite_maillage,SUPPORT *>::const_iterator const_itSupport ;
+       for (const_itSupport=(*const_itSupportOnMesh).second.begin();
+            const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++)
+         {
+           vectSupp[index] = (*const_itSupport).second;
+           SCRUTE(vectSupp[index]);
+           MESSAGE(LOC << "Support number " << index << " is "<< *vectSupp[index]);
+           index++;
+         }
+      }
+
   }
   
   
@@ -543,7 +555,7 @@ void MED_MED_RDONLY_DRIVER::readFileStruct( void )
   }
   
   // read profil count and their names
-  int support_count_= 0 ;
+  //  int support_count_= 0 ; !! UNUSED VARIABLE !!
   // il faut lire les champs pour avoir les profils stockes !!!
   // il faudrait implémenter la lecture des profils dans med !!!
   
index db6375d0cd325ef913d791806b76fc838176a7a4..0b401b81d31b5c59a6b46bb622599306687067ba 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_MedMedDriver.hxx
-//  Module : MED
-
 #ifndef MED_MED_DRIVER_HXX
 #define MED_MED_DRIVER_HXX
 
index cd764c0c139f899b1ef6ff5fae26de00be975762..1c5e9e23264e85d0aef6f50f6106e90d6d8e4058 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_MedMeshDriver.cxx
-//  Module : MED
-
 using namespace std;
 #include "MEDMEM_MedMeshDriver.hxx"
 
@@ -223,9 +197,9 @@ void MED_MESH_RDONLY_DRIVER::read(void)
   buildAllGroups(_ptrMesh->_groupEdge,_ptrMesh->_familyEdge) ;
   _ptrMesh->_numberOfEdgesGroups = _ptrMesh->_groupEdge.size() ;
 
-  MESSAGE(LOC<<"Checking of CellModel !!!!!!!");
+//   MESSAGE(LOC<<"Checking of CellModel !!!!!!!");
 
-  int nbOfTypes =  _ptrMesh->_connectivity->_numberOfTypes;
+//   int nbOfTypes =  _ptrMesh->_connectivity->_numberOfTypes;
 //    for(int i=0;i<nbOfTypes;i++)
 //      {
 //        MESSAGE(LOC << _ptrMesh->_connectivity->_type[i]) ;
@@ -523,7 +497,7 @@ int  MED_MESH_RDONLY_DRIVER::getCOORDINATE()
                     tmp_node_name,NumberOfNodes*MED_TAILLE_PNOM,MED_FR::MED_NOEUD,
                     (MED_FR::med_geometrie_element) MED_NONE);
       if (err == MED_VALID) 
-        INFOS(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have names but we do not read them !");
+        MESSAGE(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have names but we do not read them !");
       delete[] tmp_node_name ;
 
 
@@ -532,9 +506,9 @@ int  MED_MESH_RDONLY_DRIVER::getCOORDINATE()
       err=MEDnumLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
                     tmp_node_number,NumberOfNodes,MED_FR::MED_NOEUD,(MED_FR::med_geometrie_element)0);
       if (err == MED_VALID) {
-        INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
-        INFOS(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have numbers but we do not take care of them !");
-        INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
+        MESSAGE(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
+        MESSAGE(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have numbers but we do not take care of them !");
+        MESSAGE(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
        _ptrMesh->_coordinate->_nodeNumber.set(NumberOfNodes) ; 
        memcpy((int*)_ptrMesh->_coordinate->_nodeNumber,tmp_node_number,sizeof(int)*NumberOfNodes) ;
       } 
@@ -691,15 +665,16 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
 
       // Get the number of cells of each type & store it in <tmp_cells_count>.
       int * tmp_cells_count = new int[MED_NBR_GEOMETRIE_MAILLE] ;
-      for (int i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++) {                       // EF :ON SCANNE DES GEOMETRIES INUTILES, UTILISER LES MAPS
+      int i;
+      for (i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++) {                       // EF :ON SCANNE DES GEOMETRIES INUTILES, UTILISER LES MAPS
        tmp_cells_count[i]=MEDnEntMaa(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
                                      MED_FR::MED_CONN,(MED_FR::med_entite_maillage) Entity,
                                       all_cell_type[i],MED_FR::MED_NOD); 
 
-        // We suppose there is no cells used as faces, this is forbidden !!!
-
-       // Only in version 2.2.x of MED, but before, it's right :-(
 
+        // Get the greatest dimension of the cells : Connectivity->_entityDimension
+        // We suppose there is no cells used as faces in MED 2.2.x , this is forbidden !!!
+       // In version prior to 2.2.x, it is possible
        if (tmp_cells_count[i]>0) { 
          Connectivity->_entityDimension=all_cell_type[i]/100;  
          Connectivity->_numberOfTypes++;
@@ -707,7 +682,7 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
       }
       
 
-      // well if there is nothing, we quit !
+      // If there is no nodal connectivity, we quit !
       if ( Connectivity->_numberOfTypes == 0 ) {
        delete[] tmp_cells_count ;
        return MED_ERROR ;
@@ -722,18 +697,27 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
        return MED_ERROR ;
       }
 
-      // we get version number
-//        string medVersion(version_med);
-//        int firstNumber = 
-      int * tmp_edges_count = new int[MED_NBR_GEOMETRIE_MAILLE] ;
+      // we get MED version number
+      // If MED version is < 2.2 then the cells which dimension
+      // is lesser than the main dimension ( Connectivity->_entityDimension )
+      // are either faces or edges
+
+      //        string medVersion(version_med);
+      //        int firstNumber = 
+      int * tmpEdgeCount = new int[MED_NBR_GEOMETRIE_MAILLE] ;
+      tmpEdgeCount[0]     = 0 ;
       int numberOfEdgesTypes = 0;
-      int * tmp_faces_count = new int[MED_NBR_GEOMETRIE_MAILLE] ;
+      int * tmpFaceCount = new int[MED_NBR_GEOMETRIE_MAILLE] ;
+      tmpFaceCount[0]     = 0 ;
       int numberOfFacesTypes = 0;
+  
       if ((version_med != "2.2")&(Entity==MED_FR::MED_MAILLE)) {
-       Connectivity->_numberOfTypes=0;
-       for (int i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++) {
-         tmp_faces_count[i]=0;
-         tmp_edges_count[i]=0;
+       
+        Connectivity->_numberOfTypes=0;
+       
+        for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++) {
+         tmpFaceCount[i]=0;
+         tmpEdgeCount[i]=0;
          if (tmp_cells_count[i]!=0) {
            int dimension = all_cell_type[i]/100 ;
            if (Connectivity->_entityDimension==dimension) 
@@ -741,13 +725,13 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
            
            if (dimension == 2)
              if (Connectivity->_entityDimension==3) {
-               tmp_faces_count[i]=tmp_cells_count[i] ;
+               tmpFaceCount[i]=tmp_cells_count[i] ;
                tmp_cells_count[i]=0 ;
                numberOfFacesTypes++;
              }
            if (dimension == 1)
              if (Connectivity->_entityDimension>dimension) {
-               tmp_edges_count[i]=tmp_cells_count[i] ;
+               tmpEdgeCount[i]=tmp_cells_count[i] ;
                tmp_cells_count[i]=0;
                numberOfEdgesTypes++ ;
              }
@@ -765,15 +749,16 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
        Connectivity->_count[0]       = 1;
        
        int size = 0 ; 
-       int TypeNumber=1 ;
-       for (int i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)  { // no point1 cell type (?)
+       int typeNumber=1 ;
+        int i;
+       for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)  { // no point1 cell type (?)
          if (tmp_cells_count[i]>0) {
-           Connectivity->_count[TypeNumber]=Connectivity->_count[TypeNumber-1]+tmp_cells_count[i];
+           Connectivity->_count[typeNumber]=Connectivity->_count[typeNumber-1]+tmp_cells_count[i];
 
            CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i]) ;
-           Connectivity->_type[TypeNumber-1]=t ;
+           Connectivity->_type[typeNumber-1]=t ;
            
-           Connectivity->_geometricTypes[TypeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i] ;
+           Connectivity->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i] ;
            
            // probleme avec les mailles de dimension < a dimension du maillage :
            // Il faut oter le zero a la lecture est le remettre a l'ecriture : ce n'est pas fait !!!!! On interdit ce cas pour l'instant !!!
@@ -782,9 +767,9 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
            size+=tmp_cells_count[i]*((MED_MESH_DRIVER::all_cell_type[i])%100) ;
            
            MESSAGE(LOC
-                   << Connectivity->_count[TypeNumber]-1 << " cells of type " 
+                   << Connectivity->_count[typeNumber]-1 << " cells of type " 
                    << all_cell_type_tab[i] ); 
-           TypeNumber++;
+           typeNumber++;
          }
        }
        
@@ -796,7 +781,8 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
        NodalIndex[0]=1 ;
        
        // Fill the MEDSKYLINEARRAY by reading the MED file.
-       for (int i=0;i<Connectivity->_numberOfTypes;i++) {
+        int j=0;
+       for ( i=0;i<Connectivity->_numberOfTypes;i++) {
          int multi = 0 ;
          MED_FR::med_geometrie_element med_type = (MED_FR::med_geometrie_element) Connectivity->_type[i].getType() ;
 //       if ( Connectivity->_type[i].getDimension() < Connectivity->_entityDimension) 
@@ -808,7 +794,7 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
          int NumberOfNodeByCell = Connectivity->_type[i].getNumberOfNodes() ;
          
          // initialise index
-         for (int j=Connectivity->_count[i]; j<Connectivity->_count[i+1];j++)
+         for ( j=Connectivity->_count[i]; j<Connectivity->_count[i+1];j++)
            NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByCell ; 
 
          int tmp_numberOfCells = Connectivity->_count[i+1]-Connectivity->_count[i] ;
@@ -820,16 +806,18 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
          int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
                              _ptrMesh->_spaceDimension,tmp_ConnectivityArray,
                              MED_FR::MED_FULL_INTERLACE,NULL,0,Entity,med_type,MED_FR::MED_NOD);
+
          if ( err != MED_VALID) {
            delete[] tmp_ConnectivityArray;
            delete[] tmp_cells_count;
-           delete[] tmp_faces_count;
-           delete[] tmp_edges_count;
+           delete[] tmpFaceCount;
+           delete[] tmpEdgeCount;
            MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
            return MED_ERROR ;
          }
+
          int * ConnectivityArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ;
-         for (int j=0; j<tmp_numberOfCells; j++)
+         for ( j=0; j<tmp_numberOfCells; j++)
            for (int k=0; k<NumberOfNodeByCell; k++) 
              ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
          delete[] tmp_ConnectivityArray;
@@ -847,28 +835,43 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
 
       delete[] tmp_cells_count; 
 
-      // get Face if any
-      // ===============
 
+
+      // Get Face if any
+      // ===============
+     
       if (numberOfFacesTypes!=0) {
+
+        // Create a CONNECTIVITY constituent to put in the top level CONNECTIVITY recursive class
        CONNECTIVITY * constituent = new CONNECTIVITY(numberOfFacesTypes,MED_EN::MED_FACE) ;
        constituent->_entityDimension = 2 ;
        constituent->_count[0]=1 ;
 
-       int size = 0 ; 
-       int size_more_one = 0 ; 
-       int TypeNumber=1 ;
-       for (int i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)  { // no point1 cell type (?)
-         if (tmp_faces_count[i]>0) {
+        // In order to create the MEDSKYLINEARRAY of the constituent object we need :
+        // 1:
+        // To initialize the _count array of the constituent object (containning cumulated face count by geometric type)
+        // _count[0]=1 and _count[_numberOfTypes] give the size of NodalIndex
+        // 2:
+        // To calculate the total number of face nodes whatever the geometric type is.
+        // The result is the size of the array containning all the nodes : NodalValue
+        // 3 :
+        // To calculate the starting indexes of the different face types in NodalValue, 
+        // this is the NodalIndex array.
+        
+       int size       = 0 ; 
+       int typeNumber = 1 ;
+        int i;
+       for ( i=1; i < MED_NBR_GEOMETRIE_MAILLE; i++)  { // no point1 cell type (?)
+         if (tmpFaceCount[i]>0) {
            
-           constituent->_count[TypeNumber]=constituent->_count[TypeNumber-1]+tmp_faces_count[i];
+           constituent->_count[typeNumber] = constituent->_count[typeNumber-1] + tmpFaceCount[i];
            CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i]) ;
-           constituent->_type[TypeNumber-1]=t ;
+           constituent->_type[typeNumber-1]=t ;
            
-           constituent->_geometricTypes[TypeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i] ;
+           constituent->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i] ;
            
-           size+=tmp_faces_count[i]*((MED_MESH_DRIVER::all_cell_type[i])%100) ;
-           TypeNumber++;
+           size+=tmpFaceCount[i]*((MED_MESH_DRIVER::all_cell_type[i])%100) ;
+           typeNumber++;
          }
        }
        
@@ -880,32 +883,39 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
        NodalIndex[0]=1 ;
        
        // Fill the MEDSKYLINEARRAY by reading the MED file.
-       for (int i=0;i<constituent->_numberOfTypes;i++) {
+       for ( i=0; i<constituent->_numberOfTypes; i++) {
          MED_FR::med_geometrie_element med_type = (MED_FR::med_geometrie_element) constituent->_type[i].getType() ;
 
          int NumberOfNodeByFace = constituent->_type[i].getNumberOfNodes() ;
          
-         // initialise index
+         // initialise NodalIndex
          for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
            NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByFace ; 
          
          int tmp_numberOfFaces = constituent->_count[i+1]-constituent->_count[i] ;
          // Il faut ajouter 1 pour le zero a la lecture !!!
-         int * tmp_constituentArray = new int[(NumberOfNodeByFace+1)*tmp_numberOfFaces] ;
-         
+          // ATTENTION UNIQUEMENT POUR MED < 2.2.x
+          int * tmp_constituentArray = NULL;
+          if (version_med != "2.2") 
+            tmp_constituentArray = new int[(NumberOfNodeByFace+1)*tmp_numberOfFaces] ;
+          else {
+            tmp_constituentArray = new int[NumberOfNodeByFace*tmp_numberOfFaces] ;
+            MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of  tmp_constituentArray !") ;
+         }
          int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
                              Connectivity->_entityDimension,tmp_constituentArray,
                              MED_FR::MED_FULL_INTERLACE,NULL,0,MED_FR::MED_MAILLE,med_type,MED_FR::MED_NOD);
+
          if ( err != MED_VALID) {
            MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
            delete constituent ;
            delete[] tmp_constituentArray;
-           delete[] tmp_faces_count;
-           delete[] tmp_edges_count;
+           delete[] tmpFaceCount;
+           delete[] tmpEdgeCount;
            return MED_ERROR ;
          }
 
-         int * constituentArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ;
+         int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1 ;
          for (int j=0; j<tmp_numberOfFaces; j++)
            for (int k=0; k<NumberOfNodeByFace; k++)
              constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+1)+k] ;
@@ -923,7 +933,7 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
        Connectivity->_constituent = constituent ;
       }
 
-      delete[] tmp_faces_count;
+      delete[] tmpFaceCount;
 
       // get Edge if any
       // ===============
@@ -933,19 +943,23 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
        constituent->_count[0]=1 ;
 
        int size = 0 ; 
-       int size_more_one = 0 ; 
-       int TypeNumber=1 ;
-       for (int i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)  { // no point1 cell type (?)
-         if (tmp_edges_count[i]>0) {
+       int typeNumber=1 ;
+        // if you declare a variable <i> in two <for> initialization statement, 
+        // compiler gcc2.95.3 says nothing but there are two <i> variables in the same block 
+        //and the value you get in the common block seems to be the value of the first variable !
+        int i; 
+
+       for ( i=1; i<MED_NBR_GEOMETRIE_MAILLE; i++)  { // no point1 cell type (?)
+         if (tmpEdgeCount[i]>0) {
            
-           constituent->_count[TypeNumber]=constituent->_count[TypeNumber-1]+tmp_edges_count[i];
+           constituent->_count[typeNumber]=constituent->_count[typeNumber-1]+tmpEdgeCount[i];
            CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i]) ;
-           constituent->_type[TypeNumber-1]=t ;
+           constituent->_type[typeNumber-1]=t ;
            
-           constituent->_geometricTypes[TypeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i] ;
+           constituent->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i] ;
            
-           size+=tmp_edges_count[i]*((MED_MESH_DRIVER::all_cell_type[i])%100) ;
-           TypeNumber++;
+           size+=tmpEdgeCount[i]*((MED_MESH_DRIVER::all_cell_type[i])%100) ;
+           typeNumber++;
          }
        }
        
@@ -957,7 +971,7 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
        NodalIndex[0]=1 ;
        
        // Fill the MEDSKYLINEARRAY by reading the MED file.
-       for (int i=0;i<constituent->_numberOfTypes;i++) {
+       for ( i=0; i<constituent->_numberOfTypes; i++) {
          MED_FR::med_geometrie_element med_type = (MED_FR::med_geometrie_element) constituent->_type[i].getType() ;
 
          int NumberOfNodeByEdge = constituent->_type[i].getNumberOfNodes() ;
@@ -968,7 +982,15 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
          
          int tmp_numberOfEdges = constituent->_count[i+1]-constituent->_count[i] ;
          // Il faut ajouter 1 pour le zero a la lecture !!!
-         int * tmp_constituentArray = new int[(NumberOfNodeByEdge+1)*tmp_numberOfEdges] ;
+
+          // ATTENTION UNIQUEMENT POUR MED < 2.2.x
+          int * tmp_constituentArray = NULL;
+          if (version_med != "2.2") 
+           tmp_constituentArray = new int[(NumberOfNodeByEdge+1)*tmp_numberOfEdges] ;
+          else {
+           tmp_constituentArray = new int[NumberOfNodeByEdge*tmp_numberOfEdges] ;
+            MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of  tmp_constituentArray !") ;
+          }
          
          int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
                              _ptrMesh->_spaceDimension,tmp_constituentArray,
@@ -977,11 +999,11 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
            MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
            delete constituent ;
            delete[] tmp_constituentArray;
-           delete[] tmp_edges_count;
+           delete[] tmpEdgeCount;
            return MED_ERROR ;
          }
 
-         int * constituentArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ;
+         int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1 ;
          for (int j=0; j<tmp_numberOfEdges; j++)
            for (int k=0; k<NumberOfNodeByEdge; k++)
              constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k] ;
@@ -1005,19 +1027,21 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity)
          Connectivity->_constituent = constituent ;
       }
 
-      delete[] tmp_edges_count; 
+      delete[] tmpEdgeCount; 
       
       return MED_VALID;
     }
+
   return MED_ERROR;
 }
 
 int MED_MESH_RDONLY_DRIVER::getDescendingConnectivity(CONNECTIVITY * Connectivity) 
 {
-  const char * LOC = "MED_MESH_RDONLY_DRIVER::getDescendingConnectivity " ;
+  const char * LOC = "MED_MESH_RDONLY_DRIVER::getDescendingConnectivity " ;
   if (_status==MED_OPENED)
     {
-      MESSAGE(LOC<<" Not implemented !");
+      MESSAGE(LOC<<"call on the object " << Connectivity);
+      MESSAGE(LOC<<"Not yet implemented !");
     }
   return MED_ERROR;
 }
@@ -1077,12 +1101,18 @@ int  MED_MESH_RDONLY_DRIVER::getFAMILY()
        MEDArrayNodeFamily = new int[_ptrMesh->getNumberOfNodes()] ;
        err = getNodesFamiliesNumber(MEDArrayNodeFamily) ; // error only if (_status!=MED_OPENED), other case exeception !
        // CELL
+
+       MESSAGE(LOC << "error returned from getNodesFamiliesNumber " << err);
+
        MEDArrayCellFamily = new (int*)[_ptrMesh->getNumberOfTypes(MED_CELL)] ; // ET SI IL N'Y A PAS DE CELLS ?
        const medGeometryElement * myTypes = _ptrMesh->getTypes(MED_CELL);
        for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++)
          MEDArrayCellFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_CELL,myTypes[i])] ;
 
-       getCellsFamiliesNumber(MEDArrayCellFamily,_ptrMesh->_connectivity) ;
+       err = getCellsFamiliesNumber(MEDArrayCellFamily,_ptrMesh->_connectivity) ;
+
+       MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Cells " << err);
+
        if (_ptrMesh->_connectivity->_constituent != NULL) {
          if (_ptrMesh->_connectivity->_constituent->_entity == MED_EN::MED_FACE) {
            // FACE
@@ -1091,14 +1121,20 @@ int  MED_MESH_RDONLY_DRIVER::getFAMILY()
            for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++)
              MEDArrayFaceFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_FACE,myTypes[i])] ;
 
-           getCellsFamiliesNumber(MEDArrayFaceFamily,_ptrMesh->_connectivity->_constituent) ;
+           err = getCellsFamiliesNumber(MEDArrayFaceFamily,_ptrMesh->_connectivity->_constituent) ;
+
+           MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Faces " << err);
+
          } else {
            // EDGE in 2D
            MEDArrayEdgeFamily = new (int*)[_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
            myTypes = _ptrMesh->getTypes(MED_EDGE);
            for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
              MEDArrayEdgeFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes[i])] ;
-           getCellsFamiliesNumber(MEDArrayEdgeFamily,_ptrMesh->_connectivity->_constituent) ;
+           err = getCellsFamiliesNumber(MEDArrayEdgeFamily,_ptrMesh->_connectivity->_constituent) ;
+
+           MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 2D " << err);
+
          }
          // EDGE in 3D
          if (_ptrMesh->_connectivity->_constituent->_constituent != NULL) {
@@ -1106,7 +1142,10 @@ int  MED_MESH_RDONLY_DRIVER::getFAMILY()
            myTypes = _ptrMesh->getTypes(MED_EDGE);
            for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
              MEDArrayEdgeFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes[i])] ;
-           getCellsFamiliesNumber(MEDArrayEdgeFamily,_ptrMesh->_connectivity->_constituent->_constituent) ; // we are in 3D !
+           err = getCellsFamiliesNumber(MEDArrayEdgeFamily,_ptrMesh->_connectivity->_constituent->_constituent) ; // we are in 3D !
+
+           MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 3D " << err);
+
          }
        }
       }
@@ -1129,6 +1168,8 @@ int  MED_MESH_RDONLY_DRIVER::getFAMILY()
     if ( NumberOfFamilies < 1 ) // at least family 0 must exist 
       throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"There is no FAMILY, FAMILY 0 must exists" ));
 
+    SCRUTE(NumberOfFamilies);
+
     vector<FAMILY*> &NodeFamilyVector = _ptrMesh->_familyNode ;
     vector<FAMILY*> &CellFamilyVector = _ptrMesh->_familyCell ;
     vector<FAMILY*> &FaceFamilyVector = _ptrMesh->_familyFace ;
@@ -1162,7 +1203,12 @@ int  MED_MESH_RDONLY_DRIVER::getFAMILY()
                               &NumberOfAttributes,
                               const_cast <char *> (GroupsNames.c_str()),&NumberOfGroups
                       );
-      //SCRUTE(GroupsNames);
+
+      SCRUTE(GroupsNames);
+      SCRUTE(FamilyName);
+      SCRUTE(err);
+      SCRUTE(i);
+
       if (err != MED_VALID)
        throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER::getFAMILY() : ERROR when get FAMILY informations" );
       if (FamilyIdentifier != 0 ) {
@@ -1178,7 +1224,7 @@ int  MED_MESH_RDONLY_DRIVER::getFAMILY()
        // All good ?
        // if nothing found, delete Family
        if (Family->getNumberOfTypes() == 0) {
-         INFOS(LOC<<"Nothing found for family "<<FamilyName<< " : skip");
+         MESSAGE(LOC<<"Nothing found for family "<<FamilyName<< " : skip");
          delete Family;
        } else
          switch (Family->getEntity()) {
@@ -1421,7 +1467,8 @@ void MED_MESH_WRONLY_DRIVER::write(void) const
     // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
     string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/FAMILLE_0/";  
     MESSAGE("|"<<dataGroupFam<<"|");
-    if ( err =_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ) < MED_VALID ) {
+    err =_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) );
+    if ( err < MED_VALID ) {
       SCRUTE(err);
       
       err = MED_FR::MEDfamCr( _medIdt,
@@ -2070,7 +2117,7 @@ int MED_MESH_WRONLY_DRIVER::writeFamilies(vector<FAMILY*> & families ) const {
   
   MESSAGE(LOC<<" families.size() :"<<families.size());
 
-  for (int i=0; i< families.size(); i++) {
+  for (unsigned int i=0; i< families.size(); i++) {
 
     int      numberOfAttributes         = families[i]->getNumberOfAttributes ();
     string   attributesDescriptions     = "";
@@ -2110,7 +2157,8 @@ int MED_MESH_WRONLY_DRIVER::writeFamilies(vector<FAMILY*> & families ) const {
     // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
     string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/"+families[i]->getName()+"/";  
     SCRUTE("|"<<dataGroupFam<<"|");
-    if ( err =_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ) < MED_VALID ) {
+    err =_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ) ;
+    if ( err < MED_VALID ) {
       SCRUTE(err);
 
       MESSAGE(LOC<<"families[i]->getName().c_str() : "<<families[i]->getName().c_str());
index cae5ab8574e13453659bebefafcf55c798ebe287..9762d263c1ba084d540ba0f2af8b47f0c6071213 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_MedMeshDriver.hxx
-//  Module : MED
-
 #ifndef MED_MESH_DRIVER_HXX
 #define MED_MESH_DRIVER_HXX
 
index 0050168db3f8d49946900538690c646e866b0e1a..93d7cfc59ace90a13e438545e84ccf8d07bc1564 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Mesh.cxx
-//  Module : MED
-
 using namespace std;
 /*
  File Mesh.cxx
@@ -45,7 +19,7 @@ using namespace std;
 #include "MEDMEM_Coordinate.hxx"
 #include "MEDMEM_Connectivity.hxx"
 #include "MEDMEM_CellModel.hxx"
-#include "MEDMEM_Grid.hxx"
+//#include "MEDMEM_Grid.hxx" this inclision should have never be here !!!
 
 //update Families with content list
 //int family_count(int family_number, int count, int * entities_number, int * entities_list) ;
@@ -56,11 +30,14 @@ using namespace std;
 //const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med_rdonly , &MESH::inst_med_rdwr } ;
 
 // Add a similar line for your personnal driver (step 3)
+
 MESH::INSTANCE_DE<MED_MESH_RDWR_DRIVER>   MESH::inst_med   ;
 MESH::INSTANCE_DE<GIBI_MESH_RDWR_DRIVER>  MESH::inst_gibi ;
+MESH::INSTANCE_DE<VTK_MESH_DRIVER> MESH::inst_vtk;
+
 // Add your own driver in the driver list       (step 4)
 // Note the list must be coherent with the driver type list defined in MEDMEM_DRIVER.hxx. 
-const MESH::INSTANCE * const MESH::instances[] =   {  &MESH::inst_med, &MESH::inst_gibi } ;
+const MESH::INSTANCE * const MESH::instances[] =   {  &MESH::inst_med, &MESH::inst_gibi, &MESH::inst_vtk } ;
 
 /*! Add a MESH driver of type (MED_DRIVER, ....) associated with file <fileName>. The meshname used in the file
     is  <driverName>. addDriver returns an int handler. */
@@ -71,18 +48,50 @@ int MESH::addDriver(driverTypes driverType,
   
   GENDRIVER * driver;
   int current;
+  int itDriver = (int) NO_DRIVER;
 
   BEGIN_OF(LOC);
   
-  driver = instances[driverType]->run(fileName, this) ;
+  SCRUTE(driverType);
+
+  SCRUTE(instances[driverType]);
+
+  switch(driverType)
+    {
+    case MED_DRIVER : {
+      itDriver = (int) driverType ;
+      break ;
+    }
+
+    case GIBI_DRIVER : {
+      itDriver = (int) driverType ;
+      break ;
+    }
+
+    case VTK_DRIVER : {
+      itDriver = 2 ;
+      break ;
+    }
+
+    case NO_DRIVER : {
+      throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "NO_DRIVER has been specified to the method which is not allowed"));
+    }
+    }
+
+  if (itDriver == ((int) NO_DRIVER))
+    throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "othe driver than MED_DRIVER GIBI_DRIVER and VT_DRIVER has been specified to the method which is not allowed"));
+
+  driver = instances[itDriver]->run(fileName, this) ;
+
   _drivers.push_back(driver);
+
   current = _drivers.size()-1;
   
   _drivers[current]->setMeshName(driverName);  
-  return current;
 
   END_OF(LOC);
 
+  return current;
 }
 
 /*! Add an existing MESH driver. */
@@ -131,8 +140,8 @@ void MESH::init() {
 
   string        _name = "NOT DEFINED"; // A POSITIONNER EN FCT DES IOS ?
 
-  COORDINATE   * _coordinate   = (COORDINATE   *) NULL;
-  CONNECTIVITY * _connectivity = (CONNECTIVITY *) NULL;
+  _coordinate   = (COORDINATE   *) NULL;
+  _connectivity = (CONNECTIVITY *) NULL;
 
   _spaceDimension        =          MED_INVALID; // 0 ?!?
   _meshDimension         =          MED_INVALID;
@@ -149,10 +158,12 @@ void MESH::init() {
   _numberOfEdgesGroups   =          0; 
 
   _isAGrid = false;
+  END_OF(LOC);
 };
 
 /*! Create an empty MESH. */
-MESH::MESH():_coordinate(NULL),_connectivity(NULL) {
+MESH::MESH():_coordinate(NULL),_connectivity(NULL), _isAGrid(false) {
   init();
 };
 
@@ -250,40 +261,32 @@ MESH::~MESH() {
   int size ;
   size = _familyNode.size() ;
   for (int i=0;i<size;i++)
-    ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
-    //delete _familyNode[i] ;
+    delete _familyNode[i] ;
   size = _familyCell.size() ;
   for (int i=0;i<size;i++)
-    ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
-    //delete _familyCell[i] ;
+    delete _familyCell[i] ;
   size = _familyFace.size() ;
   for (int i=0;i<size;i++)
-    ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
-    //delete _familyFace[i] ;
+    delete _familyFace[i] ;
   size = _familyEdge.size() ;
   for (int i=0;i<size;i++)
-    ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
-    //delete _familyEdge[i] ;
+    delete _familyEdge[i] ;
   size = _groupNode.size() ;
   for (int i=0;i<size;i++)
-    ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
-    //delete _groupNode[i] ;
+    delete _groupNode[i] ;
   size = _groupCell.size() ;
   for (int i=0;i<size;i++)
-    ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
-    //delete _groupCell[i] ;
+    delete _groupCell[i] ;
   size = _groupFace.size() ;
   for (int i=0;i<size;i++)
-    ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
-    //delete _groupFace[i] ;
+    delete _groupFace[i] ;
   size = _groupEdge.size() ;
   for (int i=0;i<size;i++)
-    ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
-    //delete _groupEdge[i] ;
+    delete _groupEdge[i] ;
 
   MESSAGE("In this object MESH there is(are) " << _drivers.size() << " driver(s)");
 
-  for (int index=0; index < _drivers.size(); index++ )
+  for (unsigned int index=0; index < _drivers.size(); index++ )
     {
       SCRUTE(_drivers[index]);
       if ( _drivers[index] != NULL) delete _drivers[index];
@@ -293,7 +296,10 @@ MESH::~MESH() {
 
 MESH & MESH::operator=(const MESH &m)
 {
+  const char * LOC = "MESH & MESH::operator=(const MESH &m) : ";
+  BEGIN_OF(LOC);
 
+  MESSAGE(LOC <<"Not yet implemented, operating on the object " << m);
   //  A FAIRE.........
 
   // ATTENTION CET OPERATEUR DE RECOPIE EST DANGEREUX POUR LES
@@ -326,23 +332,44 @@ MESH & MESH::operator=(const MESH &m)
 //        reverse_nodal_connectivity = m.reverse_nodal_connectivity;
 //        reverse_nodal_connectivity_index = m.reverse_nodal_connectivity_index ;
 //      }
+  END_OF(LOC);
+
   return *this;
 }
 
 /*! Create a MESH object using a MESH driver of type (MED_DRIVER, ....) associated with file <fileName>. 
   The meshname <driverName> must already exists in the file.*/
-MESH::MESH(driverTypes driverType, const string &  fileName/*=""*/, const string &  driverName/*=""*/) {
+MESH::MESH(driverTypes driverType, const string &  fileName/*=""*/, const string &  driverName/*=""*/) throw (MEDEXCEPTION)
+{
   const char * LOC ="MESH::MESH(driverTypes driverType, const string &  fileName="", const string &  driverName="") : ";
-  
   int current;
   
   BEGIN_OF(LOC);
 
   init();
-
-  MED_MESH_RDONLY_DRIVER myDriver(fileName,this) ;
-  myDriver.setMeshName(driverName);
-  current = addDriver(myDriver);
+  
+  switch(driverType)
+    {
+    case MED_DRIVER :
+      {
+       MED_MESH_RDONLY_DRIVER myDriver(fileName,this);
+       myDriver.setMeshName(driverName);
+       current = addDriver(myDriver);
+       break;
+      }
+    case GIBI_DRIVER :
+      {
+       GIBI_MESH_RDONLY_DRIVER myDriver(fileName,this);
+       current = addDriver(myDriver);
+       break;
+      }
+    default :
+      {
+       throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Driver type unknown : can't create driver!"));
+       break;
+      }
+    }
+  
 //   current = addDriver(driverType,fileName,driverName);
 //   switch(_drivers[current]->getAccessMode() ) {
 //   case MED_WRONLY : {
@@ -356,8 +383,8 @@ MESH::MESH(driverTypes driverType, const string &  fileName/*=""*/, const string
   _drivers[current]->read();
   _drivers[current]->close();
 
-  if (_isAGrid)
-    ((GRID *) this)->fillMeshAfterRead();
+//   if (_isAGrid)
+//     ((GRID *) this)->fillMeshAfterRead();
 
   END_OF(LOC);
 };
@@ -371,7 +398,7 @@ MESH::MESH(driverTypes driverType, const string &  fileName/*=""*/, const string
 //    return N;
 //  }
 
-ostream & operator<<(ostream &os, MESH &myMesh)
+ostream & operator<<(ostream &os, const MESH &myMesh)
 {
   int spacedimension = myMesh.getSpaceDimension();
   int meshdimension  = myMesh.getMeshDimension();
@@ -404,49 +431,8 @@ ostream & operator<<(ostream &os, MESH &myMesh)
       os << endl;
     }
 
-  const CONNECTIVITY * myConnectivity = myMesh.getConnectivityptr();
-  if (!myConnectivity->existConnectivity(MED_NODAL,MED_CELL) && myConnectivity->existConnectivity(MED_DESCENDING,MED_CELL))
-    {
-      os << endl << "SHOW CONNECTIVITY (DESCENDING) :" << endl;
-      int numberofelements;
-      const int * connectivity;
-      const int * connectivity_index;
-      myMesh.calculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL);
-      try {
-       numberofelements = myMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS);
-       connectivity =  myMesh.getConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS);
-       connectivity_index =  myMesh.getConnectivityIndex(MED_DESCENDING,MED_CELL);
-      }
-      catch (MEDEXCEPTION m) {
-       os << m.what() << endl;
-       exit (-1);
-      }
-      for (int j=0;j<numberofelements;j++) {
-       os << "Element "<<j+1<<" : ";
-       for (int k=connectivity_index[j];k<connectivity_index[j+1];k++)
-         os << connectivity[k-1]<<" ";
-       os << endl;
-      }
-    }
-  else
-    {
-      int numberoftypes = myMesh.getNumberOfTypes(MED_CELL);
-      const medGeometryElement  * types = myMesh.getTypes(MED_CELL);
-      os << endl << "SHOW CONNECTIVITY (NODAL) :" << endl;
-      for (int i=0; i<numberoftypes; i++) {
-       os << "For type " << types[i] << " : " << endl;
-       int numberofelements = myMesh.getNumberOfElements(MED_CELL,types[i]);
-       const int * connectivity =  myMesh.getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,types[i]);
-       int numberofnodespercell = types[i]%100;
-       for (int j=0;j<numberofelements;j++){
-         os << "Element "<< j+1 <<" : ";
-         for (int k=0;k<numberofnodespercell;k++)
-           os << connectivity[j*numberofnodespercell+k]<<" ";
-         os << endl;
-       }
-      }
-    }
-
+  os << endl << "SHOW CONNECTIVITY  :" << endl;
+  os << *myMesh._connectivity << endl;
 
   medEntityMesh entity;
   os << endl << "SHOW FAMILIES :" << endl << endl;
@@ -629,7 +615,7 @@ SUPPORT * MESH::getBoundaryElements(medEntityMesh Entity)
     }
     numberOfGeometricType = theType.size() ;
     geometricType = new medGeometryElement[numberOfGeometricType] ;
-    const medGeometryElement *  allType = getTypes(Entity);
+    //const medGeometryElement *  allType = getTypes(Entity); !! UNUSZED VARIABLE !!
     numberOfGaussPoint = new int[numberOfGeometricType] ;
     geometricTypeNumber = new int[numberOfGeometricType] ; // not use, but initialized to nothing
     numberOfElements = new int[numberOfGeometricType] ;
@@ -1085,6 +1071,8 @@ FIELD<double>* MESH::getVolume(const SUPPORT * Support) const throw (MEDEXCEPTIO
          throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Volumes on it !"));
          break;
        }
+
+      if (!onAll) delete [] global_connectivity ;
     }
 
   return Volume;
@@ -1289,6 +1277,8 @@ FIELD<double>* MESH::getArea(const SUPPORT * Support) const throw (MEDEXCEPTION)
          throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Areas on it !"));
          break;
        }
+
+      if (!onAll) delete [] global_connectivity ;
     }
 
   Area->setValue(MED_FULL_INTERLACE,area);
@@ -1406,6 +1396,8 @@ FIELD<double>* MESH::getLength(const SUPPORT * Support) const throw (MEDEXCEPTIO
          throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Lengths on it !"));
          break;
        }
+
+      if (!onAll) delete [] global_connectivity ;
     }
 
   return Length;
@@ -1523,7 +1515,7 @@ FIELD<double>* MESH::getNormal(const SUPPORT * Support) const throw (MEDEXCEPTIO
                int N2 = global_connectivity[tria_index+1]-1;
                int N3 = global_connectivity[tria_index+2]-1;
 
-               double xarea;
+               //double xarea; !! UNUSED VARIABLE !!
                double x1 = coord[dim_space*N1];
                double x2 = coord[dim_space*N2];
                double x3 = coord[dim_space*N3];
@@ -1639,6 +1631,8 @@ FIELD<double>* MESH::getNormal(const SUPPORT * Support) const throw (MEDEXCEPTIO
          throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Normals on it !"));
          break;
        }
+
+      if (!onAll) delete [] global_connectivity ;
     }
 
   Normal->setValue(MED_FULL_INTERLACE,normal);
@@ -2047,6 +2041,8 @@ FIELD<double>* MESH::getBarycenter(const SUPPORT * Support) const throw (MEDEXCE
          throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get a barycenter on it (in fact unknown type) !"));
          break;
        }
+
+      if (!onAll) delete [] global_connectivity ;
     }
 
   Barycenter->setValue(MED_FULL_INTERLACE,barycenter);
@@ -2063,24 +2059,35 @@ FIELD<double>* MESH::getBarycenter(const SUPPORT * Support) const throw (MEDEXCE
 //purpose  : if this->_isAGrid, assure that _coordinate is filled
 //=======================================================================
 
-inline void MESH::checkGridFillCoords() const
-{
-  if (_isAGrid)
-    ((GRID *) this)->fillCoordinates();
-}
+// inline void MESH::checkGridFillCoords() const
+// {
+//   if (_isAGrid)
+//     ((GRID *) this)->fillCoordinates();
+// }
 
 //=======================================================================
 //function : checkGridFillConnectivity
 //purpose  : if this->_isAGrid, assure that _connectivity is filled
 //=======================================================================
 
-inline void MESH::checkGridFillConnectivity() const
+// inline void MESH::checkGridFillConnectivity() const
+// {
+//   if (_isAGrid)
+//     ((GRID *) this)->fillConnectivity();
+// }
+
+bool MESH::isEmpty() const 
 {
-  if (_isAGrid)
-    ((GRID *) this)->fillConnectivity();
+    bool notempty = _name != ""                || _coordinate != NULL           || _connectivity != NULL ||
+                _spaceDimension !=MED_INVALID || _meshDimension !=MED_INVALID  || 
+                _numberOfNodes !=MED_INVALID  || _numberOfNodesFamilies !=0    || 
+                _familyNode.size() != 0       || _numberOfCellsFamilies != 0   || 
+                _familyCell.size() != 0       || _numberOfFacesFamilies != 0   || 
+                _familyFace.size() != 0       || _numberOfEdgesFamilies !=0    || 
+                _familyEdge.size() != 0       || _isAGrid != 0 ;
+    return !notempty;
 }
 
-
 void MESH::read(int index)  
 { 
   const char * LOC = "MESH::read(int index=0) : ";
@@ -2097,8 +2104,8 @@ void MESH::read(int index)
                                      << _drivers.size() 
                                      )
                           );
-  if (_isAGrid)
-    ((GRID *) this)->fillMeshAfterRead();
+//   if (_isAGrid)
+//     ((GRID *) this)->fillMeshAfterRead();
 
   END_OF(LOC);
 }
@@ -2220,7 +2227,7 @@ SUPPORT * MESH::getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION)
     }
     numberOfGeometricType = theType.size() ;
     geometricType = new medGeometryElement[numberOfGeometricType] ;
-    const medGeometryElement *  allType = getTypes(MED_FACE);
+    //const medGeometryElement *  allType = getTypes(MED_FACE); !! UNUSED VARIABLE !!
     numberOfGaussPoint = new int[numberOfGeometricType] ;
     geometricTypeNumber = new int[numberOfGeometricType] ; // not use, but initialized to nothing
     numberOfEntities = new int[numberOfGeometricType] ;
@@ -2260,3 +2267,257 @@ SUPPORT * MESH::getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION)
   return mySupport ;
  
 }
+
+/*!
+  return a SUPPORT pointer on the union of all SUPPORTs in Supports.
+  You should delete this pointer after use to avoid memory leaks.
+*/
+SUPPORT * MESH::mergeSupports(const vector<SUPPORT *> Supports) const throw (MEDEXCEPTION)
+{
+  const char * LOC = "MESH:::mergeSupports(const vector<SUPPORT *> ) : " ;
+  BEGIN_OF(LOC) ;
+
+  SUPPORT * returnedSupport;
+  string returnedSupportName;
+  string returnedSupportDescription;
+  char * returnedSupportNameChar;
+  char * returnedSupportDescriptionChar;
+  int size = Supports.size();
+
+  if (size == 1)
+    {
+      MESSAGE(LOC <<" there is only one SUPPORT in the argument list, the method return a copy of this object !");
+      SUPPORT * obj = const_cast <SUPPORT *> (Supports[0]);
+
+      returnedSupport = new SUPPORT(*obj);
+
+      int lenName = strlen((Supports[0]->getName()).c_str()) + 8 + 1;
+      int lenDescription = strlen((Supports[0]->getDescription()).c_str()) + 8 + 1;
+
+      returnedSupportNameChar = new char[lenName];
+      returnedSupportDescriptionChar = new char[lenDescription];
+
+      returnedSupportNameChar = strcpy(returnedSupportNameChar,"Copy of ");
+      returnedSupportNameChar = strcat(returnedSupportNameChar,(Supports[0]->getName()).c_str());
+      returnedSupportDescriptionChar = strcpy(returnedSupportDescriptionChar,"Copy of ");
+      returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar,
+                                             (Supports[0]->getDescription()).c_str());
+
+      returnedSupportName = string(returnedSupportNameChar);
+      returnedSupportDescription = string(returnedSupportDescriptionChar);
+
+      returnedSupport->setName(returnedSupportName);
+      returnedSupport->setDescription(returnedSupportDescription);
+
+      delete [] returnedSupportNameChar;
+      delete [] returnedSupportDescriptionChar;
+    }
+  else
+    {
+      SUPPORT * obj = const_cast <SUPPORT *> (Supports[0]);
+      returnedSupport = new SUPPORT(*obj);
+
+      int lenName = strlen((Supports[0]->getName()).c_str()) + 9 + 1;
+      int lenDescription = strlen((Supports[0]->getDescription()).c_str()) + 9 + 1;
+
+      for(int i = 1;i<size;i++)
+       {
+         obj = const_cast <SUPPORT *> (Supports[i]);
+         returnedSupport->blending(obj);
+
+         if (i == (size-1))
+           {
+             lenName = lenName + 5 + strlen((Supports[i]->getName()).c_str());
+             lenDescription = lenDescription + 5 +
+               strlen((Supports[i]->getDescription()).c_str());
+           }
+         else
+           {
+             lenName = lenName + 2 + strlen((Supports[i]->getName()).c_str());
+             lenDescription = lenDescription + 2 +
+               strlen((Supports[i]->getDescription()).c_str());
+           }
+       }
+
+      returnedSupportNameChar = new char[lenName];
+      returnedSupportDescriptionChar = new char[lenDescription];
+
+      returnedSupportNameChar = strcpy(returnedSupportNameChar,"Merge of ");
+      returnedSupportDescriptionChar = strcpy(returnedSupportDescriptionChar,"Merge of ");
+
+      returnedSupportNameChar = strcat(returnedSupportNameChar,(Supports[0]->getName()).c_str());
+      returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar,
+                                             (Supports[0]->getDescription()).c_str());
+
+      for(int i = 1;i<size;i++)
+       {
+         if (i == (size-1))
+           {
+             returnedSupportNameChar = strcat(returnedSupportNameChar," and ");
+             returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar," and ");
+
+             returnedSupportNameChar = strcat(returnedSupportNameChar,
+                                              (Supports[i]->getName()).c_str());
+             returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar,
+                                                     (Supports[i]->getDescription()).c_str());
+           }
+         else
+           {
+             returnedSupportNameChar = strcat(returnedSupportNameChar,", ");
+             returnedSupportNameChar = strcat(returnedSupportNameChar,
+                                              (Supports[i]->getName()).c_str());
+
+             returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar,", ");
+             returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar,
+                                                     (Supports[i]->getDescription()).c_str());
+           }
+       }
+
+      returnedSupportName = string(returnedSupportNameChar);
+      returnedSupport->setName(returnedSupportName);
+
+      returnedSupportDescription = string(returnedSupportDescriptionChar);
+      returnedSupport->setDescription(returnedSupportDescription);
+
+      delete [] returnedSupportNameChar;
+      delete [] returnedSupportDescriptionChar;
+    }
+
+  END_OF(LOC) ;
+  return returnedSupport;
+}
+
+/*!
+  return a SUPPORT pointer on the intersection of all SUPPORTs in Supports.
+  The (SUPPORT *) NULL pointer is returned if the intersection is empty.
+  You should delete this pointer after use to avois memory leaks.
+*/
+SUPPORT * MESH::intersectSupports(const vector<SUPPORT *> Supports) const throw (MEDEXCEPTION)
+{
+  const char * LOC = "MESH:::intersectSupports(const vector<SUPPORT *> ) : " ;
+  BEGIN_OF(LOC) ;
+
+  SUPPORT * returnedSupport;
+  string returnedSupportName;
+  string returnedSupportDescription;
+  char * returnedSupportNameChar;
+  char * returnedSupportDescriptionChar;
+  int size = Supports.size();
+
+  if (size == 1)
+    {
+      MESSAGE(LOC <<" there is only one SUPPORT in the argument list, the method return a copy of this object !");
+      SUPPORT * obj = const_cast <SUPPORT *> (Supports[0]);
+
+      returnedSupport = new SUPPORT(*obj);
+
+      int lenName = strlen((Supports[0]->getName()).c_str()) + 8 + 1;
+      int lenDescription = strlen((Supports[0]->getDescription()).c_str()) + 8 + 1;
+
+      returnedSupportNameChar = new char[lenName];
+      returnedSupportDescriptionChar = new char[lenDescription];
+
+      returnedSupportNameChar = strcpy(returnedSupportNameChar,"Copy of ");
+      returnedSupportNameChar = strcat(returnedSupportNameChar,(Supports[0]->getName()).c_str());
+      returnedSupportDescriptionChar = strcpy(returnedSupportDescriptionChar,"Copy of ");
+      returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar,
+                                             (Supports[0]->getDescription()).c_str());
+
+      returnedSupportName = string(returnedSupportNameChar);
+      returnedSupportDescription = string(returnedSupportDescriptionChar);
+
+      returnedSupport->setName(returnedSupportName);
+      returnedSupport->setDescription(returnedSupportDescription);
+
+      delete [] returnedSupportNameChar;
+      delete [] returnedSupportDescriptionChar;
+    }
+  else
+    {
+      SUPPORT * obj = const_cast <SUPPORT *> (Supports[0]);
+      returnedSupport = new SUPPORT(*obj);
+
+      int lenName = strlen((Supports[0]->getName()).c_str()) + 16 + 1;
+      int lenDescription = strlen((Supports[0]->getDescription()).c_str()) + 16 + 1;
+
+      for(int i = 1;i<size;i++)
+       {
+         obj = const_cast <SUPPORT *> (Supports[i]);
+         returnedSupport->intersecting(obj);
+
+         if (i == (size-1))
+           {
+             lenName = lenName + 5 + strlen((Supports[i]->getName()).c_str());
+             lenDescription = lenDescription + 5 +
+               strlen((Supports[i]->getDescription()).c_str());
+           }
+         else
+           {
+             lenName = lenName + 2 + strlen((Supports[i]->getName()).c_str());
+             lenDescription = lenDescription + 2 +
+               strlen((Supports[i]->getDescription()).c_str());
+           }
+       }
+
+      if(returnedSupport != (SUPPORT *) NULL)
+       {
+         returnedSupportNameChar = new char[lenName];
+         returnedSupportDescriptionChar = new char[lenDescription];
+
+         returnedSupportNameChar = strcpy(returnedSupportNameChar,
+                                          "Intersection of ");
+         returnedSupportDescriptionChar =
+           strcpy(returnedSupportDescriptionChar,"Intersection of ");
+
+         returnedSupportNameChar = strcat(returnedSupportNameChar,
+                                          (Supports[0]->getName()).c_str());
+         returnedSupportDescriptionChar =
+           strcat(returnedSupportDescriptionChar,
+                  (Supports[0]->getDescription()).c_str());
+
+         for(int i = 1;i<size;i++)
+           {
+             if (i == (size-1))
+               {
+                 returnedSupportNameChar = strcat(returnedSupportNameChar,
+                                                  " and ");
+                 returnedSupportDescriptionChar =
+                   strcat(returnedSupportDescriptionChar," and ");
+
+                 returnedSupportNameChar =
+                   strcat(returnedSupportNameChar,
+                          (Supports[i]->getName()).c_str());
+                 returnedSupportDescriptionChar =
+                   strcat(returnedSupportDescriptionChar,
+                          (Supports[i]->getDescription()).c_str());
+               }
+             else
+               {
+                 returnedSupportNameChar = strcat(returnedSupportNameChar,
+                                                  ", ");
+                 returnedSupportNameChar =
+                   strcat(returnedSupportNameChar,
+                          (Supports[i]->getName()).c_str());
+
+                 returnedSupportDescriptionChar =
+                   strcat(returnedSupportDescriptionChar,", ");
+                 returnedSupportDescriptionChar =
+                   strcat(returnedSupportDescriptionChar,
+                          (Supports[i]->getDescription()).c_str());
+               }
+           }
+
+         returnedSupportName = string(returnedSupportNameChar);
+         returnedSupport->setName(returnedSupportName);
+
+         returnedSupportDescription = string(returnedSupportDescriptionChar);
+         returnedSupport->setDescription(returnedSupportDescription);
+
+         delete [] returnedSupportNameChar;
+         delete [] returnedSupportDescriptionChar;
+       }
+    }
+
+  END_OF(LOC) ;
+  return returnedSupport;
+}
index 9fad12dfadba3b9e530d2648f933d2580c8caf44..ac8954cee13bb955092c3c823be50ecd6e18ba20 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Mesh.hxx
-//  Module : MED
-
 #ifndef MESH_HXX
 #define MESH_HXX
 
@@ -44,6 +18,8 @@
 #include "MEDMEM_MedMedDriver.hxx"
 #include "MEDMEM_GibiMeshDriver.hxx"
 
+#include "MEDMEM_VtkMeshDriver.hxx"
+
 class CELLMODEL;
 class FAMILY;
 class GROUP;
@@ -51,9 +27,9 @@ class SUPPORT;
 
 template <class T> class FIELD;
 
-//class GENDRIVER ;
-//class MED_MESH_RDONLY_DRIVER ;
-//class MED_MESH_WRONLY_DRIVER ;
+//class GENDRIVER;
+//class MED_MESH_RDONLY_DRIVER;
+//class MED_MESH_WRONLY_DRIVER;
 
 using namespace MED_EN;
 
@@ -84,8 +60,8 @@ protected:
   //-----------------------//
   {
   public:
-    virtual GENDRIVER * run(const string & fileName, MESH * ptrMesh) const = 0 ;
-  } ;
+    virtual GENDRIVER * run(const string & fileName, MESH * ptrMesh) const = 0;
+  };
 
   //-------------------------------------------------------//
   template <class T> class INSTANCE_DE : public INSTANCE
@@ -93,14 +69,17 @@ protected:
   {
   public :
     GENDRIVER * run(const string & fileName, MESH * ptrMesh) const
-    { return new T(fileName,ptrMesh) ; }
-  } ;
+    { return new T(fileName,ptrMesh); }
+  };
 
   // Add a similar line for your personnal driver (step 3)
-  static INSTANCE_DE<MED_MESH_RDWR_DRIVER>  inst_med ;
-  static INSTANCE_DE<GIBI_MESH_RDWR_DRIVER> inst_gibi ;
-  //static INSTANCE_DE<VTK_DRIVER>   inst_vtk   ;
-  static const INSTANCE * const instances[] ;
+
+  static INSTANCE_DE<MED_MESH_RDWR_DRIVER>  inst_med;
+  static INSTANCE_DE<GIBI_MESH_RDWR_DRIVER> inst_gibi;
+  static INSTANCE_DE<VTK_MESH_DRIVER> inst_vtk;
+
+  //static INSTANCE_DE<VTK_DRIVER>   inst_vtk  ;
+  static const INSTANCE * const instances[];
 
   // ------ End of Drivers Management Part
 
@@ -113,21 +92,21 @@ protected :
 
   string        _name; // A POSITIONNER EN FCT DES IOS ?
 
-  COORDINATE *   _coordinate;
-  CONNECTIVITY * _connectivity;
+  mutable COORDINATE *   _coordinate;
+  mutable CONNECTIVITY * _connectivity;
 
-  int           _spaceDimension;
-  int           _meshDimension ;
-  int           _numberOfNodes    ;
+  int   _spaceDimension;
+  int   _meshDimension;
+  int   _numberOfNodes;
 
   int             _numberOfNodesFamilies;  //INUTILE ? -> _familyNode.size()
-  vector<FAMILY*> _familyNode ;  // array of size _numberOfNodesFamilies;
+  vector<FAMILY*> _familyNode;  // array of size _numberOfNodesFamilies;
   int             _numberOfCellsFamilies;
-  vector<FAMILY*> _familyCell ;  // array of size _numberOfCellsFamilies;
+  vector<FAMILY*> _familyCell;  // array of size _numberOfCellsFamilies;
   int             _numberOfFacesFamilies;
-  vector<FAMILY*> _familyFace ;  // array of size _numberOfFacesFamilies;
+  vector<FAMILY*> _familyFace;  // array of size _numberOfFacesFamilies;
   int             _numberOfEdgesFamilies;
-  vector<FAMILY*> _familyEdge ;  // array of size _numberOfEdgesFamilies;
+  vector<FAMILY*> _familyEdge;  // array of size _numberOfEdgesFamilies;
 
   int           _numberOfNodesGroups; //INUTILE ?
   vector<GROUP*> _groupNode;    // array of size _numberOfNodesGroups;
@@ -147,8 +126,9 @@ protected :
   //   Methods
   //-----------------------//
 
-  inline void checkGridFillCoords() const;
-  inline void checkGridFillConnectivity() const;
+//   inline void checkGridFillCoords() const;
+//   inline void checkGridFillConnectivity() const;
+  bool isEmpty() const;
   // if this->_isAGrid, assure that _coordinate and _connectivity are filled
 
 public :
@@ -165,14 +145,16 @@ public :
   friend class GIBI_MESH_WRONLY_DRIVER;
   friend class GIBI_MESH_RDWR_DRIVER;
 
+  friend class VTK_MESH_DRIVER;
+
   void init();
   MESH();
   MESH(MESH &m);
   MESH & operator=(const MESH &m);
   MESH( driverTypes driverType, const string & fileName="",
-       const string & meshName="");
-  ~MESH();
-  friend ostream & operator<<(ostream &os, MESH &my) ;
+       const string & meshName="") throw (MEDEXCEPTION);
+  virtual ~MESH();
+  friend ostream & operator<<(ostream &os, const MESH &my);
 
   int  addDriver(driverTypes driverType,
                 const string & fileName  ="Default File Name.med",
@@ -180,65 +162,107 @@ public :
   int  addDriver(GENDRIVER & driver);
   void rmDriver(int index=0);
 
-  void read(int index=0);
+  virtual void read(int index=0);
   inline void read(const MED_MED_DRIVER & genDriver);
   inline void write(int index=0, const string & driverName = "");
   inline void write(const MED_MED_DRIVER & genDriver);
 
   //  void calculateReverseConnectivity();
   //  void createFaces();      //Faces creation => full constituent informations
-  //  void buildConstituent() ; // calculate descendent connectivity + face-cell connectivity
+  //  void buildConstituent(); // calculate descendent connectivity + face-cell connectivity
 
 
   inline void        setName(string name);
 
   inline string       getName() const;
-  inline int         getSpaceDimension() const ;
-  inline int         getMeshDimension() const ;
+  inline int         getSpaceDimension() const;
+  inline int         getMeshDimension() const;
   inline bool        getIsAGrid();
 
-  inline int         getNumberOfNodes() const ;
-  inline const COORDINATE * getCoordinateptr() const ;
-  inline string       getCoordinatesSystem() const ;
-  inline const double *     getCoordinates(medModeSwitch Mode) const ;
-  inline const double       getCoordinate(int Number,int Axis) const ;
-  inline const string *     getCoordinatesNames() const ;
-  inline const string *     getCoordinatesUnits() const ;
-  //  inline int *        getNodesNumbers();
-
-  inline int          getNumberOfTypes(medEntityMesh Entity) const ;
-  inline const medGeometryElement *  getTypes(medEntityMesh Entity) const ;
-  inline const CELLMODEL *  getCellsTypes(medEntityMesh Entity) const ;
-  inline const int *        getGlobalNumberingIndex(medEntityMesh Entity) const ;
-  inline int          getNumberOfElements(medEntityMesh Entity,medGeometryElement Type) const ;
-  inline bool         existConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity) const ;
-  inline medGeometryElement getElementType(medEntityMesh Entity,int Number) const ;
-  inline void         calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity) ;
-  inline const int *        getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity, medGeometryElement Type) const ;
-  inline const int *        getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity) const ;
-  int                 getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity) const ;
-  inline const int *        getReverseConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity=MED_CELL) const ;
-  inline const int *        getReverseConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity=MED_CELL) const ;
-
-  inline int          getNumberOfFamilies(medEntityMesh Entity) const ;
-  inline const vector<FAMILY*> getFamilies(medEntityMesh Entity) const ;
-  inline const FAMILY*      getFamily(medEntityMesh Entity,int i) const ;
-  inline int          getNumberOfGroups(medEntityMesh Entity) const ;
-  inline const vector<GROUP*> getGroups(medEntityMesh Entity) const ;
-  inline const GROUP*      getGroup(medEntityMesh Entity,int i) const ;
-  inline const CONNECTIVITY* getConnectivityptr() const ;
-  SUPPORT * getBoundaryElements(medEntityMesh Entity) throw (MEDEXCEPTION) ;
-  //SUPPORT * getBoundaryElements(medEntityMesh Entity) const throw (MEDEXCEPTION) ; // problème avec le maillage dans le support : le pointeur n'est pas const, mais sa valeur oui. A voir !!! PG
-
-  SUPPORT * getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION) ;
+  inline int                       getNumberOfNodes() const;
+  virtual inline const COORDINATE * getCoordinateptr() const;
+  inline string                     getCoordinatesSystem() const;
+  virtual inline const double *     getCoordinates(medModeSwitch Mode) const;
+  virtual inline const double       getCoordinate(int Number,int Axis) const;
+  inline const string *             getCoordinatesNames() const;
+  inline const string *             getCoordinatesUnits() const;
+  //inline int *                    getNodesNumbers();
+
+  virtual inline int             getNumberOfTypes(medEntityMesh Entity) const;
+  virtual inline const medGeometryElement * getTypes(medEntityMesh Entity) const;
+  virtual inline const CELLMODEL * getCellsTypes(medEntityMesh Entity) const;
+  virtual const int * getGlobalNumberingIndex(medEntityMesh Entity) const;
+  virtual inline int getNumberOfElements(medEntityMesh Entity,
+                                        medGeometryElement Type) const;
+  virtual inline bool existConnectivity(medConnectivity ConnectivityType,
+                                       medEntityMesh Entity) const;
+
+  virtual inline medGeometryElement getElementType(medEntityMesh Entity,
+                                                  int Number) const;
+  virtual inline void calculateConnectivity(medModeSwitch Mode,
+                                           medConnectivity ConnectivityType,
+                                           medEntityMesh Entity) const ;
+  virtual inline const int * getConnectivity(medModeSwitch Mode,
+                                            medConnectivity ConnectivityType,
+                                            medEntityMesh Entity, 
+                                            medGeometryElement Type) const;
+  virtual inline const int * getConnectivityIndex(medConnectivity ConnectivityType,
+                                                 medEntityMesh Entity) const;
+  virtual int                 getElementNumber(medConnectivity ConnectivityType, 
+                                               medEntityMesh Entity, 
+                                               medGeometryElement Type, 
+                                               int * connectivity) const;
+
+  virtual inline const int * getReverseConnectivity(medConnectivity ConnectivityType,
+                                                   medEntityMesh Entity=MED_CELL) const;
+  virtual inline const int * getReverseConnectivityIndex(medConnectivity ConnectivityType,
+                                                        medEntityMesh Entity=MED_CELL) const;
+
+  virtual int                          getNumberOfFamilies(medEntityMesh Entity) const;
+  virtual inline const vector<FAMILY*> getFamilies(medEntityMesh Entity) const;
+  virtual inline const FAMILY*         getFamily(medEntityMesh Entity,int i) const;
+  virtual int                                 getNumberOfGroups(medEntityMesh Entity) const;
+  virtual inline const vector<GROUP*>  getGroups(medEntityMesh Entity) const;
+  virtual inline const GROUP*          getGroup(medEntityMesh Entity,int i) const;
+  virtual inline const CONNECTIVITY* getConnectivityptr() const;
+  virtual SUPPORT *                    getBoundaryElements(medEntityMesh Entity) 
+                                               throw (MEDEXCEPTION);
+  // problème avec le maillage dans le support : 
+  //            le pointeur n'est pas const, mais sa valeur oui. A voir !!! PG
+
+  SUPPORT *                            getSkin(const SUPPORT * Support3D) 
+                                               throw (MEDEXCEPTION);
 
   //  Node DonneBarycentre(const Cell &m) const;
-  FIELD<double>* getVolume(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 3D elements
-  FIELD<double>* getArea(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 2D elements
-  FIELD<double>* getLength(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 1D elements
-  FIELD<double>* getNormal(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 2D elements
-  FIELD<double>* getBarycenter(const SUPPORT * Support) const throw (MEDEXCEPTION) ;
-  //  FIELD<int>* getNeighbourhood(SUPPORT * Support) const throw (MEDEXCEPTION) ; // Il faut preciser !
+  virtual FIELD<double>* getVolume (const SUPPORT * Support) const 
+                               throw (MEDEXCEPTION); 
+                               // Support must be on 3D elements
+  virtual FIELD<double>* getArea (const SUPPORT * Support) const 
+                               throw (MEDEXCEPTION); 
+                               // Support must be on 2D elements
+  virtual FIELD<double>* getLength (const SUPPORT * Support) const 
+                               throw (MEDEXCEPTION); 
+                               // Support must be on 1D elements
+  virtual FIELD<double>* getNormal (const SUPPORT * Support) const 
+                               throw (MEDEXCEPTION); 
+                               // Support must be on 2D elements
+  virtual FIELD<double>* getBarycenter (const SUPPORT * Support) const 
+                               throw (MEDEXCEPTION);
+  //  FIELD<int>* getNeighbourhood(SUPPORT * Support) const 
+  //                           throw (MEDEXCEPTION); // Il faut preciser !
+
+  /*!
+    return a SUPPORT pointer on the union of all SUPPORTs in Supports.
+    You should delete this pointer after use to avois memory leaks.
+  */
+  SUPPORT * mergeSupports(const vector<SUPPORT *> Supports) const throw (MEDEXCEPTION) ;
+
+  /*!
+    return a SUPPORT pointer on the intersection of all SUPPORTs in Supports.
+    The (SUPPORT *) NULL pointer is returned if the intersection is empty.
+    You should delete this pointer after use to avois memory leaks.
+   */
+  SUPPORT * intersectSupports(const vector<SUPPORT *> Supports) const throw (MEDEXCEPTION) ;
 };
 
 // ---------------------------------------
@@ -247,6 +271,7 @@ public :
 
 inline const CONNECTIVITY* MESH::getConnectivityptr() const
 {
+//   checkGridFillConnectivity();
   return _connectivity;
 }
 
@@ -297,7 +322,7 @@ inline void MESH::write(const MED_MED_DRIVER & genDriver)
   const char * LOC = "MESH::write(const MED_MED_DRIVER & genDriver): ";
   BEGIN_OF(LOC);
 
-  for (int index=0; index < _drivers.size(); index++ )
+  for (unsigned int index=0; index < _drivers.size(); index++ )
     if ( *_drivers[index] == genDriver ) {
       _drivers[index]->open();
       _drivers[index]->write();
@@ -316,7 +341,7 @@ inline void MESH::read(const MED_MED_DRIVER & genDriver)
   const char * LOC = "MESH::read(const MED_MED_DRIVER & genDriver): ";
   BEGIN_OF(LOC);
 
-  for (int index=0; index < _drivers.size(); index++ )
+  for (unsigned int index=0; index < _drivers.size(); index++ )
     if ( *_drivers[index] == genDriver ) {
       _drivers[index]->open();
       _drivers[index]->read();
@@ -331,13 +356,13 @@ inline void MESH::read(const MED_MED_DRIVER & genDriver)
 /*! Set the MESH name */
 inline void MESH::setName(string name)
 {
-  _name=name ; //NOM interne à la classe
+  _name=name; //NOM interne à la classe
 }
 
 /*! Get the MESH name */
 inline string MESH::getName() const
 {
-  return _name ;
+  return _name;
 }
 
 /*! Get the dimension of the space */
@@ -361,7 +386,7 @@ inline int MESH::getNumberOfNodes() const
 /*! Get the COORDINATES object. Use it only if you need COORDINATES informations not provided by the MESH class.*/
 inline const COORDINATE * MESH::getCoordinateptr() const
 {
-  checkGridFillCoords();
+//   checkGridFillCoords();
   return _coordinate;
 }
 
@@ -377,14 +402,14 @@ inline string MESH::getCoordinatesSystem() const
  */
 inline const double * MESH::getCoordinates(medModeSwitch Mode) const
 {
-  checkGridFillCoords();
+//   checkGridFillCoords();
   return _coordinate->getCoordinates(Mode);
 }
 
 /*! Get the coordinate n° number on axis n°axis*/
 inline const double MESH::getCoordinate(int number, int axis) const
 {
-  checkGridFillCoords();
+//   checkGridFillCoords();
   return _coordinate->getCoordinate(number,axis);
 }
 
@@ -410,7 +435,7 @@ inline const string * MESH::getCoordinatesUnits() const
 
 /*! Get the number of different geometric types for a given entity type.
 
-    For exemple getNumberOfTypes(MED_CELL) would return 3 is the MESH
+    For exemple getNumberOfTypes(MED_CELL) would return 3 if the MESH
     have some MED_TETRA4, MED_PYRA5 and MED_HEXA6 in it.
 
     medEntityMesh entity : MED_CELL, MED_FACE, MED_EDGE, MED_NODE, MED_ALL_ENTITIES
@@ -423,10 +448,10 @@ inline int MESH::getNumberOfTypes(medEntityMesh entity) const
 {
   MESSAGE("MESH::getNumberOfTypes(medEntityMesh entity) : "<<entity);
   if (entity == MED_NODE)
-    return 1 ;
-  checkGridFillConnectivity();
+    return 1;
+//   checkGridFillConnectivity();
   if (_connectivity != NULL)
-    return _connectivity->getNumberOfTypes(entity) ;
+    return _connectivity->getNumberOfTypes(entity);
   throw MEDEXCEPTION(LOCALIZED("MESH::getNumberOfTypes( medEntityMesh ) : Connectivity not defined !"));
 }
 
@@ -444,9 +469,9 @@ inline const medGeometryElement * MESH::getTypes(medEntityMesh entity) const
     throw MEDEXCEPTION(LOCALIZED("MESH::getTypes( medEntityMesh ) : No medGeometryElement with MED_NODE entity !"));
   // return un tableau de taille 1 contenant MED_NONE, comme les supports pour etre coherent avec getNumberOfTypes ???? PG
 
-  checkGridFillConnectivity();
+//   checkGridFillConnectivity();
   if (_connectivity != NULL)
-    return _connectivity->getGeometricTypes(entity) ;
+    return _connectivity->getGeometricTypes(entity);
   throw MEDEXCEPTION(LOCALIZED("MESH::getTypes( medEntityMesh ) : Connectivity not defined !"));
 }
 
@@ -457,9 +482,9 @@ inline const medGeometryElement * MESH::getTypes(medEntityMesh entity) const
 */
 inline const CELLMODEL * MESH::getCellsTypes(medEntityMesh Entity) const
 {
-  checkGridFillConnectivity();
+  //  checkGridFillConnectivity();
   if (_connectivity != NULL)
-    return _connectivity->getCellsTypes(Entity) ;
+    return _connectivity->getCellsTypes(Entity);
   throw MEDEXCEPTION(LOCALIZED("MESH::getCellsTypes( medEntityMesh ) : Connectivity not defined !"));
 }
 
@@ -475,7 +500,7 @@ inline const CELLMODEL * MESH::getCellsTypes(medEntityMesh Entity) const
 */
 inline const int * MESH::getGlobalNumberingIndex(medEntityMesh entity) const
 {
-  checkGridFillConnectivity();
+  //  checkGridFillConnectivity();
   if (_connectivity != NULL)
     return _connectivity->getGlobalNumberingIndex(entity);
   throw MEDEXCEPTION(LOCALIZED("MESH::getNumberOfTypes( medEntityMesh ) : Connectivity not defined !"));
@@ -493,20 +518,20 @@ inline const int * MESH::getGlobalNumberingIndex(medEntityMesh entity) const
  */
 inline int MESH::getNumberOfElements(medEntityMesh entity, medGeometryElement Type) const
 {
-  const char * LOC = "MESH::getNumberOfElements(medEntityMesh,medGeometryElement) : " ;
+  //  const char * LOC = "MESH::getNumberOfElements(medEntityMesh,medGeometryElement) : ";
   if (entity==MED_NODE)
     if ((Type==MED_NONE)|(Type==MED_ALL_ELEMENTS))
-      return _numberOfNodes ;
+      return _numberOfNodes;
     else
-      return 0 ;
+      return 0;
   //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"wrong medGeometryElement with MED_NODE"));
   else
     {
-      checkGridFillConnectivity();
+//       checkGridFillConnectivity();
       if (_connectivity != (CONNECTIVITY*)NULL)
-       return _connectivity->getNumberOf(entity,Type) ;
+       return _connectivity->getNumberOf(entity,Type);
       else
-       return 0 ;
+       return 0;
       //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"connectivity not defined !"));
     }
 }
@@ -516,10 +541,10 @@ inline int MESH::getNumberOfElements(medEntityMesh entity, medGeometryElement Ty
  */
 inline bool MESH::existConnectivity(medConnectivity connectivityType, medEntityMesh entity) const
 {
-  checkGridFillConnectivity();
+//   checkGridFillConnectivity();
   if (_connectivity==(CONNECTIVITY*)NULL)
     throw MEDEXCEPTION("MESH::existConnectivity(medConnectivity,medEntityMesh) : no connectivity defined !");
-  return _connectivity->existConnectivity(connectivityType,entity) ;
+  return _connectivity->existConnectivity(connectivityType,entity);
 }
 /*!
   Return the geometric type of global element Number of entity Entity.
@@ -528,21 +553,21 @@ inline bool MESH::existConnectivity(medConnectivity connectivityType, medEntityM
  */
 inline medGeometryElement MESH::getElementType(medEntityMesh Entity,int Number) const
 {
-  checkGridFillConnectivity();
+  //  checkGridFillConnectivity();
   if (_connectivity==(CONNECTIVITY*)NULL)
     throw MEDEXCEPTION("MESH::getElementType(medEntityMesh,int) : no connectivity defined !");
-  return _connectivity->getElementType(Entity,Number) ;
+  return _connectivity->getElementType(Entity,Number);
 }
 /*!
   Calculate the ask connectivity. Return an exception if this could not be
   done. Do nothing if connectivity already exist.
  */
 
-inline void MESH::calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity)
+inline void MESH::calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity) const
 {
-  checkGridFillConnectivity();
+  //  checkGridFillConnectivity();
   if (Mode==MED_FULL_INTERLACE)
-    _connectivity->calculateConnectivity(ConnectivityType,entity) ;
+    _connectivity->calculateConnectivity(ConnectivityType,entity);
   else
     throw MEDEXCEPTION(LOCALIZED("MESH::calculateConnectivity : only for MED_FULL_INTERLACE mode"));
 }
@@ -556,9 +581,9 @@ inline void MESH::calculateConnectivity(medModeSwitch Mode,medConnectivity Conne
  */
 inline const int * MESH::getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity, medGeometryElement Type) const
 {
-  checkGridFillConnectivity();
+  //  checkGridFillConnectivity();
   if (Mode==MED_FULL_INTERLACE)
-    return _connectivity->getConnectivity(ConnectivityType,entity,Type) ;
+    return _connectivity->getConnectivity(ConnectivityType,entity,Type);
   throw MEDEXCEPTION(LOCALIZED("MESH::getConnectivity : only for MED_FULL_INTERLACE mode"));
 }
 /*!
@@ -574,8 +599,8 @@ inline const int * MESH::getConnectivity(medModeSwitch Mode,medConnectivity Conn
  */
 inline const int * MESH::getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh entity) const
 {
-  checkGridFillConnectivity();
-  return _connectivity->getConnectivityIndex(ConnectivityType, entity) ;
+  //  checkGridFillConnectivity();
+  return _connectivity->getConnectivityIndex(ConnectivityType, entity);
 }
 /*!
   Return the reverse connectivity required by ConnectivityType :
@@ -586,11 +611,11 @@ inline const int * MESH::getConnectivityIndex(medConnectivity ConnectivityType,m
  */
 inline const int * MESH::getReverseConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity/*=MED_CELL*/) const
 {
-  checkGridFillConnectivity();
+  //  checkGridFillConnectivity();
   if (NULL==_connectivity)
     throw MEDEXCEPTION("MESH::getReverseConnectivity : no connectivity defined in MESH !");
 
-  return _connectivity->getReverseConnectivity(ConnectivityType,Entity) ;
+  return _connectivity->getReverseConnectivity(ConnectivityType,Entity);
 }
 /*!
   Return the index array required by ConnectivityType.
@@ -606,11 +631,11 @@ inline const int * MESH::getReverseConnectivity(medConnectivity ConnectivityType
  */
 inline const int * MESH::getReverseConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity/*=MED_CELL*/) const
 {
-  checkGridFillConnectivity();
+  //  checkGridFillConnectivity();
   if (NULL==_connectivity)
     throw MEDEXCEPTION("MESH::getReverseConnectivityIndex : no connectivity defined in MESH !");
 
-  return _connectivity->getReverseConnectivityIndex(ConnectivityType,Entity) ;
+  return _connectivity->getReverseConnectivityIndex(ConnectivityType,Entity);
 }
 
 
@@ -618,13 +643,13 @@ inline int MESH::getNumberOfFamilies (medEntityMesh entity) const
 {
   switch (entity) {
   case MED_NODE :
-    return _numberOfNodesFamilies ;
+    return _numberOfNodesFamilies;
   case MED_CELL :
-    return _numberOfCellsFamilies ;
+    return _numberOfCellsFamilies;
   case MED_FACE :
-    return _numberOfFacesFamilies ;
+    return _numberOfFacesFamilies;
   case MED_EDGE :
-    return _numberOfEdgesFamilies ;
+    return _numberOfEdgesFamilies;
   default :
     throw MEDEXCEPTION("MESH::getNumberOfFamilies : Unknown entity");
   }
@@ -633,13 +658,13 @@ inline int MESH::getNumberOfGroups (medEntityMesh entity) const
 {
   switch (entity) {
   case MED_NODE :
-    return _numberOfNodesGroups ;
+    return _numberOfNodesGroups;
   case MED_CELL :
-    return _numberOfCellsGroups ;
+    return _numberOfCellsGroups;
   case MED_FACE :
-    return _numberOfFacesGroups ;
+    return _numberOfFacesGroups;
   case MED_EDGE :
-    return _numberOfEdgesGroups ;
+    return _numberOfEdgesGroups;
   default :
     throw MEDEXCEPTION("MESH::getNumberOfGroups : Unknown entity");
   }
@@ -648,13 +673,13 @@ const vector<FAMILY*> MESH::getFamilies(medEntityMesh entity) const
 {
   switch (entity) {
   case MED_NODE :
-    return _familyNode ;
+    return _familyNode;
   case MED_CELL :
-    return _familyCell ;
+    return _familyCell;
   case MED_FACE :
-    return _familyFace ;
+    return _familyFace;
   case MED_EDGE :
-    return _familyEdge ;
+    return _familyEdge;
   default :
     throw MEDEXCEPTION("MESH::getFamilies : Unknown entity");
   }
@@ -664,13 +689,13 @@ const vector<GROUP*> MESH::getGroups(medEntityMesh entity) const
 {
   switch (entity) {
   case MED_NODE :
-    return _groupNode ;
+    return _groupNode;
   case MED_CELL :
-    return _groupCell ;
+    return _groupCell;
   case MED_FACE :
-    return _groupFace ;
+    return _groupFace;
   case MED_EDGE :
-    return _groupEdge ;
+    return _groupEdge;
   default :
     throw MEDEXCEPTION("MESH::getGroups : Unknown entity");
   }
@@ -680,28 +705,28 @@ const FAMILY* MESH::getFamily(medEntityMesh entity, int i) const
 {
   if (i<=0)
     throw MEDEXCEPTION("MESH::getFamily(i) : argument i must be > 0");
-  int NumberOfFamilies = 0 ;
-  vector<FAMILY*> Family ;
+  int NumberOfFamilies = 0;
+  vector<FAMILY*> Family;
   switch (entity) {
   case MED_NODE : {
-    NumberOfFamilies = _numberOfNodesFamilies ;
-    Family = _familyNode ;
-    break ;
+    NumberOfFamilies = _numberOfNodesFamilies;
+    Family = _familyNode;
+    break;
   }
   case MED_CELL : {
-    NumberOfFamilies = _numberOfCellsFamilies ;
-    Family = _familyCell ;
-    break ;
+    NumberOfFamilies = _numberOfCellsFamilies;
+    Family = _familyCell;
+    break;
   }
   case MED_FACE : {
-    NumberOfFamilies = _numberOfFacesFamilies ;
-    Family = _familyFace ;
-    break ;
+    NumberOfFamilies = _numberOfFacesFamilies;
+    Family = _familyFace;
+    break;
   }
   case MED_EDGE : {
-    NumberOfFamilies = _numberOfEdgesFamilies ;
-    Family = _familyEdge ;
-    break ;
+    NumberOfFamilies = _numberOfEdgesFamilies;
+    Family = _familyEdge;
+    break;
   }
   default :
     throw MEDEXCEPTION("MESH::getFamilies : Unknown entity");
@@ -713,31 +738,31 @@ const FAMILY* MESH::getFamily(medEntityMesh entity, int i) const
 
 const GROUP* MESH::getGroup(medEntityMesh entity, int i) const
 {
-  const char * LOC = "MESH::getGroup(medEntityMesh entity, int i) : " ;
+  const char * LOC = "MESH::getGroup(medEntityMesh entity, int i) : ";
   if (i<=0)
     throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"argument i must be > 0"));
-  int NumberOfGroups = 0 ;
-  vector<GROUP*> Group ;
+  int NumberOfGroups = 0;
+  vector<GROUP*> Group;
   switch (entity) {
   case MED_NODE : {
-    NumberOfGroups = _numberOfNodesGroups ;
-    Group = _groupNode ;
-    break ;
+    NumberOfGroups = _numberOfNodesGroups;
+    Group = _groupNode;
+    break;
   }
   case MED_CELL : {
-    NumberOfGroups = _numberOfCellsGroups ;
-    Group = _groupCell ;
-    break ;
+    NumberOfGroups = _numberOfCellsGroups;
+    Group = _groupCell;
+    break;
   }
   case MED_FACE : {
-    NumberOfGroups = _numberOfFacesGroups ;
-    Group = _groupFace ;
-    break ;
+    NumberOfGroups = _numberOfFacesGroups;
+    Group = _groupFace;
+    break;
   }
   case MED_EDGE : {
-    NumberOfGroups = _numberOfEdgesGroups ;
-    Group = _groupEdge ;
-    break ;
+    NumberOfGroups = _numberOfEdgesGroups;
+    Group = _groupEdge;
+    break;
   }
   default :
     throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Unknown entity"));
@@ -749,7 +774,7 @@ const GROUP* MESH::getGroup(medEntityMesh entity, int i) const
 
 
 //    int * get_() {
-//      return  ;
+//      return ;
 //    }
 
 //inline void MESH::write(const string & driverName)  {
@@ -758,6 +783,8 @@ const GROUP* MESH::getGroup(medEntityMesh entity, int i) const
 
 inline bool MESH::getIsAGrid()
 {
+  SCRUTE(_isAGrid);
+
   return _isAGrid;
 }
 
index a966be3874fe117c3b5c7980df0b742889a4fa12..2f90a5df3571195b95539a738b8be3261cb39a8f 100644 (file)
@@ -1,12 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  CEA/DEN, EDF R&D
-//
-//
-//
-//  File   : MEDMEM_Meshing.cxx
-//  Module : MED
-
 using namespace std;
 /*
   File MEDMEM_Meshing.cxx
@@ -262,6 +253,10 @@ void MESHING::setConnectivities (const int * ConnectivityIndex,
   throw (MEDEXCEPTION)
 {
   const char * LOC = "MESHING::setConnectivities : " ;
+  SCRUTE(Entity);
+  SCRUTE(ConnectivityType);
+  SCRUTE(ConnectivityValue);
+  SCRUTE(ConnectivityIndex);
 
   throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not Yet Implemented :: Warning !"));
 }
index 0b1b955f8949f8f4de95d05091b56503147143e4..cb68c546617397159c4efd182c1298a3d816b150 100644 (file)
@@ -1,12 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  CEA/DEN, EDF R&D
-//
-//
-//
-//  File   : MEDMEM_Meshing.hxx
-//  Module : MED
-
 /*
   File MEDMEM_Meshing.hxx
   $Header$
index 469d5b78a355285e71770b43a7d5b16856a36f3f..956c1d69c4d1b1aec7717201825e6ba8e19a418b 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_ModulusArray.hxx
-//  Module : MED
-
 #ifndef __MEDMODULUSARRAY_H__
 #define __MEDMODULUSARRAY_H__
 
index cc68738cf345777e1ee3b87ca575d7886c2d3664..1b7b6ede25a37f98f406a01134c061776d24ed2f 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_PointerOf.hxx
-//  Module : MED
-
 # if ! defined( __PointerOf_HXX__ )
 # define __PointerOf_HXX__
 
@@ -82,8 +56,8 @@ template <typename T> PointerOf<T>::PointerOf() : _pointer(0), _done(false)
     - The "old" PointerOf always has propriety of the pointed memory. \n
     - If the "old" PointerOf is detroyed, the "new" PointerOf points
       a desallocated memory zone. */
-template <typename T> PointerOf<T>::PointerOf(const PointerOf<T> & pointerOf) : _done(false),
-                                                                               _pointer((T*)(const T* const)pointerOf)
+template <typename T> PointerOf<T>::PointerOf(const PointerOf<T> & pointerOf) :
+  _pointer((T*)(const T* const)pointerOf), _done(false)
 {
        BEGIN_OF("PointerOf<T>::PointerOf(const PointerOf<T> & pointerOf)");
        MESSAGE("Warning ! No Propriety Transfer");
index be06dc2ab72ebde4f5d9283ad1057f8580160398..fde1ee0953e29169b3620b80991d600aa21c3146 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_STRING.hxx
-//  Module : MED
-
 # ifndef MEDMEM_STRING_HXX
 # define MEDMEM_STRING_HXX
 
index f2b2a54b08bfef0f90761b96dfd77b97eda8a1f0..13f24e3bef62bc05b01c3f4506c329b0c2b47f69 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_SkyLineArray.cxx
-//  Module : MED
-
 using namespace std;
 #include "MEDMEM_SkyLineArray.hxx"
 #include "utilities.h"
index 2b979f3a77e36052bd18cff3d59cb25142494672..5440f6fdf997c432784a1a0f553017257863ba99 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_SkyLineArray.hxx
-//  Module : MED
-
 # ifndef __MEDSKYLINEARRAY_H__
 # define __MEDSKYLINEARRAY_H__
 
index 197f8b148fa6603c188f51c8a9b9a3a038bb8a70..0cdfe01920beddef9c0b512adf76f7fd51ffdef8 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Support.cxx
-//  Module : MED
-
 using namespace std;
 /*
  File Support.cxx
@@ -31,6 +5,7 @@ using namespace std;
 */
 
 #include <set>
+#include <algorithm>
 #include <list>
 
 //#include "utilities.h"
@@ -164,10 +139,10 @@ SUPPORT::~SUPPORT()
 ostream & operator<<(ostream &os, const SUPPORT &my)
 //--------------------------------------------------
 {
-  os << "Name : "<< my._name << endl ;
-  os << "Description : "<< my._description << endl ;
+  os << "Name : "<< my.getName() << endl ;
+  os << "Description : "<< my.getDescription() << endl ;
   os << "Mesh name : ";
-  if (my._mesh==NULL)
+  if (my.getMesh() == NULL)
     os << "ERROR : Mesh not defined !" << endl ;
   else
     os << my._mesh->getName() << endl ;
@@ -178,9 +153,10 @@ ostream & operator<<(ostream &os, const SUPPORT &my)
     os << "NumberOfTypes : "<<numberoftypes<<endl;
     medGeometryElement * types = my._geometricType;
     for (int j=0;j<numberoftypes;j++) {
-      os << "    * Type "<<types[j]<<" : ";
       int numberOfElements = my._numberOfElements[j];
-      const int * number = my._number->getI(j+1);
+      os << "    * Type "<<types[j]<<" : there is(are) "<<numberOfElements<<" element(s) : ";
+      const int * number = my.getNumber(types[j]);
+      SCRUTE(number);
       for (int k=0; k<numberOfElements;k++)
        os << number[k] << " ";
       os << endl ;
@@ -236,10 +212,10 @@ void SUPPORT::update()
 };
 
 /*!
-  Blend the given SUPPORT into it.
+  Blend the given SUPPORT mySupport into the calling object SUPPORT.
 */
 //-------------------
-void SUPPORT::blending(SUPPORT * mySupport) 
+void SUPPORT::blending(SUPPORT * mySupport) throw (MEDEXCEPTION)
 //-------------------
 {
   const char * LOC = "SUPPORT::blending() : " ;
@@ -257,33 +233,39 @@ void SUPPORT::blending(SUPPORT * mySupport)
   //MESH_ENTITIES myMeshEntities() ;
   list<MED_FR::med_geometrie_element>::const_iterator listIt ;
   int it=0 ;
-  for(listIt=(MED_FR::meshEntities[(MED_FR::med_entite_maillage)_entity]).begin();listIt!=(MED_FR::meshEntities[(MED_FR::med_entite_maillage)_entity]).end();listIt++){
+  for(listIt=(MED_FR::meshEntities[(MED_FR::med_entite_maillage)_entity]).begin();listIt!=(MED_FR::meshEntities[(MED_FR::med_entite_maillage)_entity]).end();listIt++) {
     tmp_NumberOfElementsInType[it]=0;
     whereIsType[it]=0 ;
     try {
-      tmp_NumberOfElementsInType[it]+=getNumberOfElements((medGeometryElement)(*listIt)) ;
+      int tmp_int = 0;
+      tmp_int = getNumberOfElements((medGeometryElement)(*listIt)) ;
+      tmp_NumberOfElementsInType[it]+=tmp_int ;
       whereIsType[it]+=1 ;
     }
-    catch (const MEDEXCEPTION & ex) {};
+    catch (MEDEXCEPTION & ex) { SCRUTE(sizeof(ex)); };
     try {
-      tmp_NumberOfElementsInType[it]+=mySupport->getNumberOfElements((medGeometryElement)(*listIt)) ;
+      int tmp_int = 0;
+      tmp_int = mySupport->getNumberOfElements((medGeometryElement)(*listIt)) ;
+      tmp_NumberOfElementsInType[it]+=tmp_int ;
       whereIsType[it]+=2 ;
     }
     catch (const MEDEXCEPTION & ex) {};
     if (whereIsType[it]!=0) {
       myType[it]=(medGeometryElement)(*listIt) ;
+      SCRUTE(myType[it]);SCRUTE(it);SCRUTE((*listIt));
       it++;
     }
   }
   // set new value :
-  int * numberOfElements=_numberOfElements ;
-  _numberOfElements = new int[it] ;
+//   int * numberOfElements=_numberOfElements ;
+//   _numberOfElements = new int[it] ;
+  int * numberOfElements= new int[it];
   _totalNumberOfElements = 0 ;
   //int totalSize = 0 ;
   int ** tmp_array = new (int*)[it];
   for (int i=0;i<it;i++) {
     int numberOfElementsInType = tmp_NumberOfElementsInType[i] ;
-    _numberOfElements[i] = numberOfElementsInType ;
+    numberOfElements[i] = numberOfElementsInType ;
     tmp_array[i] = new int[numberOfElementsInType] ;
     //totalSize+=numberOfElementsInType*(myType[i]%100) ;
     _totalNumberOfElements+=numberOfElementsInType ;
@@ -293,8 +275,8 @@ void SUPPORT::blending(SUPPORT * mySupport)
       memcpy(tmp_array[i],mySupport->getNumber(myType[i]),sizeof(int)*numberOfElementsInType);
     } else if (whereIsType[i] == 3) { // more difficult :-)
       set<int> elementList ;
-      int i1 = 0 ;
-      int i2 = 0 ;
+      //int i1 = 0 ; !! UNUSED VARIABLE !!
+      //int i2 = 0 ; !!UNUSED VARIABLE !!
       int ii = 0 ;
       const int * number1 = getNumber(myType[i]) ;
       const int * number2 = mySupport->getNumber(myType[i]) ;
@@ -302,24 +284,28 @@ void SUPPORT::blending(SUPPORT * mySupport)
       SCRUTE(number1);
       SCRUTE(number2);
 
-      int numberOfElements1 = numberOfElements[i] ;
+      int numberOfElements1 = getNumberOfElements(myType[i]) ;
       int numberOfElements2 = mySupport->getNumberOfElements(myType[i]) ;
 
       SCRUTE(numberOfElements1);
       SCRUTE(numberOfElements2);
 
+      MESSAGE(LOC << " Type : " << myType[i] << " " << i);
+
       for(int j=0;j<numberOfElements1;j++){
        elementList.insert(number1[j]) ;
       }
 
       for(int j=0;j<numberOfElements2;j++){
-       SCRUTE(number2[j]);
        elementList.insert(number2[j]) ;
       }
 
       //create the array !
       int newNumberOfElements = elementList.size() ;
-      _numberOfElements[i] = newNumberOfElements ;
+
+      SCRUTE(newNumberOfElements);
+
+      numberOfElements[i] = newNumberOfElements ;
       int * tmp_arrayNew = new int[newNumberOfElements];
 
       set<int>::iterator its ;
@@ -337,6 +323,9 @@ void SUPPORT::blending(SUPPORT * mySupport)
   }
   delete[] whereIsType ;
   delete[] tmp_NumberOfElementsInType ;
+  delete [] _numberOfElements;
+
+  _numberOfElements = numberOfElements;
 
   _numberOfGeometricType = it ;
   medGeometryElement * geometricType=_geometricType ;
@@ -375,7 +364,15 @@ void SUPPORT::blending(SUPPORT * mySupport)
   delete[] geometricType ;
   delete[] numberOfGaussPoint ;
 //    delete[] geometricTypeNumber ;
-  delete[] numberOfElements ;
+//  delete[] numberOfElements ;
+
+
+
+
+  MESSAGE(LOC<<"Printing of the object SUPPORT blended "<< *this);
+
+
+
 
   END_OF(LOC);
 };
@@ -514,7 +511,7 @@ void SUPPORT::getBoundaryElements() throw (MEDEXCEPTION)
     }
     numberOfGeometricType = theType.size() ;
     geometricType = new medGeometryElement[numberOfGeometricType] ;
-    const medGeometryElement *  allType = _mesh->getTypes(_entity);
+    //const medGeometryElement *  allType = _mesh->getTypes(_entity); !! UNUSED VARIABLE !!
     numberOfGaussPoint = new int[numberOfGeometricType] ;
     geometricTypeNumber = new int[numberOfGeometricType] ; // not use, but initialized to nothing
     numberOfElements = new int[numberOfGeometricType] ;
@@ -566,3 +563,162 @@ void SUPPORT::getBoundaryElements() throw (MEDEXCEPTION)
 
   END_OF(LOC) ;
 }
+
+/*!
+  intersect the given SUPPORT mySupport into the calling SUPPORT object.
+*/
+//-------------------
+void SUPPORT::intersecting(SUPPORT * mySupport) throw (MEDEXCEPTION)
+//-------------------
+{
+  const char * LOC = "SUPPORT::intersecting(SUPPORT *) : " ;
+  BEGIN_OF(LOC) ;
+
+  MESSAGE(LOC<< "SUPPORT entry : " << *mySupport) ;
+
+  MESSAGE(LOC<< "SUPPORT (calling object) : " << *this) ;
+
+  // on same entity :
+  if ( _entity != mySupport->getEntity() )
+    throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Entities are different !"));
+
+  int * tmp_NumberOfElementsInType = new int[MED_NBR_GEOMETRIE_MAILLE];
+  medGeometryElement * myType = new medGeometryElement[MED_NBR_GEOMETRIE_MAILLE];
+  int * whereIsType = new int[MED_NBR_GEOMETRIE_MAILLE];
+  //MESH_ENTITIES myMeshEntities() ;
+  list<MED_FR::med_geometrie_element>::const_iterator listIt ;
+  int it=0 ;
+  for(listIt=(MED_FR::meshEntities[(MED_FR::med_entite_maillage)_entity]).begin();listIt!=(MED_FR::meshEntities[(MED_FR::med_entite_maillage)_entity]).end();listIt++) {
+    tmp_NumberOfElementsInType[it]=0;
+    whereIsType[it]=0 ;
+    myType[it]= MED_NONE;
+    try {
+      tmp_NumberOfElementsInType[it]+=getNumberOfElements((medGeometryElement)(*listIt)) ;
+      whereIsType[it]+=1 ;
+    }
+    catch (const MEDEXCEPTION & ex) {};
+    try {
+      tmp_NumberOfElementsInType[it]+=mySupport->getNumberOfElements((medGeometryElement)(*listIt)) ;
+      whereIsType[it]+=2 ;
+    }
+    catch (const MEDEXCEPTION & ex) {};
+    if (whereIsType[it]==3) {
+      myType[it]=(medGeometryElement)(*listIt) ;
+      it++;
+    }
+  }
+
+  MESSAGE("it = "<< it);
+
+  // set new value :
+  int * numberOfElements=_numberOfElements ;
+  _numberOfElements = new int[it] ;
+  _totalNumberOfElements = 0 ;
+  //int totalSize = 0 ;
+  int ** tmp_array = new (int*)[it];
+  for (int i=0;i<it;i++) {
+    int numberOfElementsInType = tmp_NumberOfElementsInType[i] ;
+    _numberOfElements[i] = numberOfElementsInType ;
+    tmp_array[i] = new int[numberOfElementsInType] ;
+    _totalNumberOfElements+=numberOfElementsInType ;
+    if (whereIsType[i] == 3) {
+      const int * number1 = getNumber(myType[i]) ;
+      const int * number2 = mySupport->getNumber(myType[i]) ;
+
+      SCRUTE(number1);
+      SCRUTE(number2);
+
+      int numberOfElements1 = numberOfElements[i] ;
+      int numberOfElements2 = mySupport->getNumberOfElements(myType[i]) ;
+
+      SCRUTE(numberOfElements1);
+      SCRUTE(numberOfElements2);
+
+      set<int> setList1(number1,number1+numberOfElements1);
+      set<int> setList2(number2,number2+numberOfElements2);
+
+      for(set<int>::iterator its=setList1.begin();its!=setList1.end(); its++)
+       {
+         MESSAGE("Number1 " << *its);
+       }
+
+      for(set<int>::iterator its=setList2.begin();its!=setList2.end(); its++)
+       {
+         MESSAGE("Number2 " << *its);
+       }
+
+      set<int> setListIntersect;
+
+      set_intersection(setList1.begin(),setList1.end(),setList2.begin(),
+                      setList2.end(),inserter(setListIntersect,
+                                              setListIntersect.begin()));
+
+      for(set<int>::iterator its=setListIntersect.begin();
+         its!=setListIntersect.end(); its++)
+       {
+         MESSAGE("Number1 intersect Number2 " << *its);
+       }
+
+      int newNumberOfElements = setListIntersect.size() ;
+
+      SCRUTE(newNumberOfElements);
+
+      _numberOfElements[i] = newNumberOfElements ;
+      int * tmp_arrayNew = new int[newNumberOfElements];
+
+      int ii = 0 ;
+
+      for(set<int>::iterator its=setListIntersect.begin();
+         its!=setListIntersect.end(); its++) {
+       tmp_arrayNew[ii]=*its ;
+       SCRUTE(tmp_arrayNew[ii]);
+       ii++;
+      }
+
+      delete[] tmp_array[i] ;
+      tmp_array[i] = tmp_arrayNew ;
+      _totalNumberOfElements-=(numberOfElementsInType-newNumberOfElements) ;
+
+    } else
+      throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"ERROR")) ;
+  }
+  delete[] whereIsType ;
+  delete[] tmp_NumberOfElementsInType ;
+
+  _numberOfGeometricType = it ;
+  medGeometryElement * geometricType=_geometricType ;
+  _geometricType = new medGeometryElement[it] ;
+  int * numberOfGaussPoint=_numberOfGaussPoint ;
+  _numberOfGaussPoint= new int[it] ;
+
+  int size = _mesh->getNumberOfElements(_entity,MED_ALL_ELEMENTS);
+  if (_totalNumberOfElements == size) _isOnAllElts = true;
+
+  int * numberValue = new int[_totalNumberOfElements] ;
+  int * numberIndex = new int[it+1] ;
+  numberIndex[0]=1;
+  for (int i=0;i<it;i++) {
+    memcpy(numberValue+numberIndex[i]-1,tmp_array[i],sizeof(int)*_numberOfElements[i]) ;
+    delete[] tmp_array[i] ;
+    numberIndex[i+1]=numberIndex[i]+_numberOfElements[i] ;
+
+    _geometricType[i]=myType[i] ;
+    _numberOfGaussPoint[i]=1 ;
+  }
+  if ( _number != (MEDSKYLINEARRAY *) NULL) delete _number ;
+
+  _number = new MEDSKYLINEARRAY(it,_totalNumberOfElements,numberIndex,numberValue);
+  delete[] numberIndex;
+
+  delete[] numberValue;
+
+  delete[] myType ;
+  delete[] tmp_array ;
+
+  delete[] geometricType ;
+  delete[] numberOfGaussPoint ;
+//    delete[] geometricTypeNumber ;
+  delete[] numberOfElements ;
+
+  END_OF(LOC);
+};
index ce3b2ebbbf9671cb881483adc67119a3501a301e..378df16d8892173b5bfdf3cf17cf387c8940d56e 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Support.hxx
-//  Module : MED
-
 /*
   File Support.hxx
   $Header$
@@ -78,7 +52,7 @@ protected:
     Reference to the mesh on which the support is defined.
     \endif
   */
-  MESH *                   _mesh;
+  mutable MESH *                   _mesh;
 
   /*!
     \if developper
@@ -109,7 +83,7 @@ protected:
     (not yet implemented).
     \endif
   */
-  int *                    _numberOfGaussPoint ;
+  mutable int *                    _numberOfGaussPoint ;
 
    /*
     \if developper
@@ -167,13 +141,13 @@ protected:
     Defined only if _isOnAllElts is false.
     \endif
   */
-  MEDSKYLINEARRAY * _number;
+  mutable MEDSKYLINEARRAY * _number;
 
 public:
   SUPPORT();
   SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL);
   SUPPORT(const SUPPORT & m);
-  ~SUPPORT();
+  virtual ~SUPPORT();
   friend ostream & operator<<(ostream &os,const SUPPORT &my);
 
   // function to set all value when SUPPORT was created by MedMedDriver without all MESH information !!! Change with new API !
@@ -195,7 +169,7 @@ public:
 
   inline string getName() const;
   inline string getDescription() const;
-  inline MESH * getMesh() const;
+  virtual inline MESH * getMesh() const;
   inline medEntityMesh getEntity() const;
 
   inline bool   isOnAllElements() const;
@@ -206,31 +180,36 @@ public:
   //inline int *  getGeometricTypeNumber() const;
   //inline int    getTotalNumberOfElement() const;
   inline int    getNumberOfElements(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
-  inline MEDSKYLINEARRAY *  getnumber() const throw (MEDEXCEPTION);
-  inline const int *  getNumber(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
-  inline const int *  getNumberIndex() const throw (MEDEXCEPTION);
+  virtual inline MEDSKYLINEARRAY *  getnumber() const throw (MEDEXCEPTION);
+  virtual inline const int *  getNumber(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
+  virtual inline const int *  getNumberIndex() const throw (MEDEXCEPTION);
 
-  void blending(SUPPORT * mySupport);
+  void blending(SUPPORT * mySupport) throw (MEDEXCEPTION) ;
 
   void setpartial(string Description, int NumberOfGeometricType,
                  int TotalNumberOfEntity, medGeometryElement *GeometricType,
                  int *NumberOfEntity, int *NumberValue);
 
   void getBoundaryElements() throw (MEDEXCEPTION);
+
+  void intersecting(SUPPORT * mySupport) throw (MEDEXCEPTION) ;
 };
 // _____________________
 // Methodes Inline
 // _____________________
 
 /*!
-  If isOnAllElements is false, returns number of elements in the
-  support else returns number of nodes.
+  This method returns the number of all elements of the type GeometricType.
+
+  If isOnAllElements is false, it returns the number of elements in the
+  support else it returns number of elements in the whole mesh.
 
   Example : number of MED_TRIA3 or MED_ALL_ELEMENTS elements
   in entity of support.
 
-  Note : If SUPPORT is defined on MED_NODE, use MED_NONE
-  medGeometryElement type.
+  Note : If SUPPORT is defined on MED_NODE, use MED_ALL_ELEMENTS as
+         medGeometryElement GeometricType and it will returns the number
+        of nodes in the support (or in the whole mesh).
 */
 //-----------------------------------------------------------------------------
 inline int SUPPORT::getNumberOfElements(medGeometryElement GeometricType) const
index 413436daa007d104900e6c5e90369f06f53d603e..721d616928e3d638d16062a2cd580bcebcb6fd2e 100644 (file)
@@ -1,12 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  CEA/DEN, EDF R&D
-//
-//
-//
-//  File   : MEDMEM_TypeMeshDriver.cxx
-//  Module : MED
-
 #include "MEDMEM_TypeMeshDriver.hxx"
 
 #include "MEDMEM_DriversDef.hxx"
index 5e9fe230d3f3048ceb01c0d0490e31c30e2023da..1354d3ef3391f8e2b22e90c7dad0d99fbea1ce0b 100644 (file)
@@ -1,12 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  CEA/DEN, EDF R&D
-//
-//
-//
-//  File   : MEDMEM_TypeMeshDriver.hxx
-//  Module : MED
-
 #ifndef TYPE_MESH_DRIVER_HXX
 #define TYPE_MESH_DRIVER_HXX
 
index 7cd49a7e4815d435910514b619c0ccd533314571..8648722bb841d7b1eba141d3ce917faff1ff7d79 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Unit.cxx
-//  Module : MED
-
 using namespace std;
 /*
  File MEDMEM_Unit.cxx
index 62f885760fcacf2f4620ead682b10e38f45d777b..81a24f8603c930a2876f7f890c93d1ce09d51af9 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_Unit.hxx
-//  Module : MED
-
 /*
  File Unit.hxx
  $Header$
diff --git a/src/MEDMEM/MEDMEM_Utilities.hxx b/src/MEDMEM/MEDMEM_Utilities.hxx
new file mode 100644 (file)
index 0000000..8c28132
--- /dev/null
@@ -0,0 +1,81 @@
+#ifdef _SALOME
+
+#  include <utilities.h>
+
+#else
+
+#  include <cstdlib>
+#  include <iostream>
+using namespace std;
+
+/* ---  INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */
+
+# define HEREWEARE {cout<<flush ; cerr << __FILE__ << " [" << __LINE__ << "] : " << flush ;}
+# define INFOS(chain) {HEREWEARE ; cerr << chain << endl ;}
+# define PYSCRIPT(chain) {cout<<flush ; cerr << "---PYSCRIPT--- " << chain << endl ;}
+
+
+/* --- To print date and time of compilation of current source on stdout --- */
+
+# if defined ( __GNUC__ )
+# define COMPILER              "g++" ;
+# elif defined ( __sun )
+# define COMPILER              "CC" ;
+# elif defined ( __KCC )
+# define COMPILER              "KCC" ;
+# elif defined ( __PGI )
+# define COMPILER              "pgCC" ;
+# else
+# define COMPILER              "undefined" ;
+# endif
+
+# ifdef INFOS_COMPILATION
+# error INFOS_COMPILATION already defined
+# endif
+# define INFOS_COMPILATION     {\
+                                       cerr << flush;\
+                                       cout << __FILE__ ;\
+                                       cout << " [" << __LINE__ << "] : " ;\
+                                       cout << "COMPILED with " << COMPILER ;\
+                                       cout << ", " << __DATE__ ; \
+                                       cout << " at " << __TIME__ << endl ;\
+                                       cout << "\n\n" ;\
+                                       cout << flush ;\
+                               }
+
+# ifdef _DEBUG_
+
+/* --- the following MACROS are useful at debug time --- */
+
+# define HERE {cout<<flush ; cerr << "- Trace " << __FILE__ << " [" << __LINE__ << "] : " << flush ;}
+# define SCRUTE(var) {HERE ; cerr << #var << "=" << var << endl ;}
+# define MESSAGE(chain) {HERE ; cerr << chain << endl ;}
+# define INTERRUPTION(code) {HERE ; cerr << "INTERRUPTION return code= " << code << endl ; exit(code) ;}
+
+# ifndef ASSERT
+# define ASSERT(condition) if (!(condition)){ HERE ; cerr << "CONDITION " << #condition << " NOT VERIFIED"<< endl ; INTERRUPTION(1) ;}
+# endif /* ASSERT */
+
+#define REPERE {cout<<flush ; cerr << "   --------------" << endl << flush ;}
+#define BEGIN_OF(chain) {REPERE ; HERE ; cerr << "Begin of: " << chain << endl ; REPERE ; }
+#define END_OF(chain) {REPERE ; HERE ; cerr << "Normal end of: " << chain << endl ; REPERE ; }
+
+
+
+# else /* ifdef _DEBUG_*/
+
+# define HERE
+# define SCRUTE(var) {}
+# define MESSAGE(chain) {}
+# define INTERRUPTION(code) {}
+
+# ifndef ASSERT
+# define ASSERT(condition) {}
+# endif /* ASSERT */
+
+#define REPERE
+#define BEGIN_OF(chain) {}
+#define END_OF(chain) {}
+
+#endif
+
diff --git a/src/MEDMEM/MEDMEM_VtkFieldDriver.hxx b/src/MEDMEM/MEDMEM_VtkFieldDriver.hxx
new file mode 100644 (file)
index 0000000..b5afc5c
--- /dev/null
@@ -0,0 +1,720 @@
+#ifndef VTK_FIELD_DRIVER_HXX
+#define VTK_FIELD_DRIVER_HXX
+
+#include <string>
+
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_GenDriver.hxx"
+#include "utilities.h"
+
+#include "MEDMEM_STRING.hxx"
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_Unit.hxx"
+#include "MEDMEM_Array.hxx"
+#include "MEDMEM_Support.hxx"
+//#include "MEDMEM_Field.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_CellModel.hxx"
+
+//using namespace MED_FR ;
+
+template <class T> class FIELD;
+
+/*!
+
+  Driver Med for FIELD.
+
+  Generic part : implement open and close methods.
+
+*/
+
+template <class T> class VTK_FIELD_DRIVER : public GENDRIVER
+{
+protected:
+  
+  FIELD<T> *     _ptrField;
+  mutable ofstream *        _vtkFile ;
+  string         _fieldName;
+  int            _fieldNum;
+
+public :
+
+  // all MED cell type ?? Classe de Définition ??
+  //   static const medGeometryElement all_cell_type[MED_NBR_GEOMETRIE_MAILLE];
+  
+  //   static const char * const all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE];
+  
+  /*!
+    Constructor.
+  */
+  VTK_FIELD_DRIVER():GENDRIVER(),
+                     _ptrField((FIELD<T> *)MED_NULL), _fieldName(""),
+                    _fieldNum(MED_INVALID)
+  {
+    const char * LOC = "VTK_FIELD_DRIVER::VTK_FIELD_DRIVER() ";
+    BEGIN_OF(LOC);
+
+    _vtkFile = new ofstream();
+
+    END_OF(LOC);
+  }
+  /*!
+    Constructor.
+  */
+  VTK_FIELD_DRIVER(const string & fileName, FIELD<T> * ptrField)
+    : GENDRIVER(fileName,MED_WRONLY),
+      _ptrField((FIELD<T> *) ptrField),
+      _fieldName(fileName),_fieldNum(MED_INVALID) 
+  {
+    const char * LOC = "VTK_FIELD_DRIVER::VTK_FIELD_DRIVER(const string & fileName, FIELD<T> * ptrField) ";
+    BEGIN_OF(LOC);
+
+    _vtkFile = new ofstream();
+
+    END_OF(LOC);
+  }
+
+  /*!
+    Copy constructor.
+  */
+  VTK_FIELD_DRIVER(const VTK_FIELD_DRIVER & fieldDriver):
+    GENDRIVER(fieldDriver),
+    _ptrField(fieldDriver._ptrField),
+    _fieldName(fieldDriver._fieldName),
+    _fieldNum(fieldDriver._fieldNum) 
+  {
+    _ptrField->addDriver(*this);
+    _vtkFile = new ofstream();
+  }
+
+  /*!
+    Destructor.
+  */
+  ~VTK_FIELD_DRIVER()
+  {
+  const char * LOC ="VTK_FIELD_DRIVER::~VTK_FIELD_DRIVER()";
+  BEGIN_OF(LOC);
+
+  close();
+
+  SCRUTE(_vtkFile);
+
+  delete _vtkFile ;
+
+  SCRUTE(_vtkFile);
+
+  END_OF(LOC);
+  }
+
+  void openConst() const throw (MEDEXCEPTION)
+  {
+    const char * LOC = "VTK_FIELD_DRIVER::openConst()" ;
+    BEGIN_OF(LOC);
+
+    MESSAGE(LOC<<" : _fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
+
+    if ( _fileName == "" )
+      throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) 
+                                      << "_fileName is |\"\"|, please set a correct fileName before calling open()"
+                                      )
+                           );
+
+    if (!(*_vtkFile).is_open())
+      (*_vtkFile).open(_fileName.c_str()) ; 
+//    if (*_vtkFile)
+//      _status = MED_OPENED ;
+//    else
+
+
+    SCRUTE((*_vtkFile).is_open());
+    SCRUTE(_vtkFile);
+
+
+
+    if (!(*_vtkFile))
+      throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Could not open file "
+                                      << _fileName)
+                           );
+    END_OF(LOC);
+  }
+
+  void openConstAppend() const throw (MEDEXCEPTION)
+  {
+    const char * LOC = "VTK_FIELD_DRIVER::openConstAppend()" ;
+    BEGIN_OF(LOC);
+
+    MESSAGE(LOC<<" : _fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
+
+    if ( _fileName == "" )
+      throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) 
+                                      << "_fileName is |\"\"|, please set a correct fileName before calling open()"
+                                      )
+                           );
+
+    SCRUTE((*_vtkFile).is_open());
+
+    if (!(*_vtkFile).is_open())
+      {
+       MESSAGE(LOC<<"The file is already close and it is opened with the right option");
+       (*_vtkFile).open(_fileName.c_str(), ofstream::out | ofstream::app) ; 
+      }
+    else
+      {
+       MESSAGE(LOC<<"The file is still open, it is closed to make sure that it will be opened with the right option");
+       //      closeConst();
+
+
+       (*_vtkFile).close() ;
+
+       _vtkFile->open(_fileName.c_str(), ofstream::out | ofstream::app) ; 
+      }
+//    if (*_vtkFile)
+//      _status = MED_OPENED ;
+//    else
+
+
+    SCRUTE((*_vtkFile).is_open());
+    SCRUTE(_vtkFile);
+
+
+
+    if (!(*_vtkFile))
+      throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Could not open file "
+                                      << _fileName)
+                           );
+    END_OF(LOC);
+  }
+
+  void open() throw (MEDEXCEPTION)
+  {
+    openConst() ;
+  }
+
+  void openAppend() throw (MEDEXCEPTION)
+  {
+    openConstAppend() ;
+  }
+
+  void closeConst() const throw (MEDEXCEPTION)
+  {
+    const char * LOC = "VTK_FIELD_DRIVER::closeConst() " ;
+    BEGIN_OF(LOC);
+
+    SCRUTE(_vtkFile);
+    SCRUTE(*_vtkFile);
+
+
+    if ((*_vtkFile).is_open())
+      (*_vtkFile).close();
+  
+//    if (*_vtkFile)
+//      _status = MED_CLOSED ;
+//    else
+
+    SCRUTE(_vtkFile);
+    SCRUTE(*_vtkFile);
+
+    if (!(*_vtkFile))
+      throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Could not close file "
+                                      << _fileName)
+                           );
+
+    END_OF(LOC);
+  }
+
+  void close() {
+    closeConst() ;
+  }
+
+  /*!
+    Set the name of the FIELD asked in file.
+
+    It could be different than the name of the FIELD object.
+  */
+  void   setFieldName(const string & fieldName) ;
+
+  /*!
+    Get the name of the FIELD asked in file.
+  */
+  string getFieldName() const ;
+
+  /*!
+    Return a MEDEXCEPTION : it is the write-only driver.
+  */
+  void read ( void ) throw (MEDEXCEPTION) ;
+
+  /*!
+    Write FIELD in the specified file, with its mesh through its support
+    which has to be on all entities (excluding the faces in 3d and edges
+    in 2d).
+  */
+  void write( void ) const throw (MEDEXCEPTION) ;
+
+  /*!
+    Write FIELD in the specified file, the mesh is supposed to be
+    written in this file. The field support has to be on all entities
+    (excluding the faces in 3d and edges in 2d).
+  */
+  void writeAppend( void ) const throw (MEDEXCEPTION);
+
+private:
+  GENDRIVER * copy ( void ) const ;
+
+};
+
+/*-------------------------*/
+/* template implementation */
+/*-------------------------*/
+
+/*--------------------- DRIVER PART -------------------------------*/
+
+template <class T> void VTK_FIELD_DRIVER<T>::setFieldName(const string & fieldName)
+{
+  _fieldName = fieldName; 
+}
+
+template <class T> string  VTK_FIELD_DRIVER<T>::getFieldName() const
+{
+  return _fieldName;
+}
+
+template <class T> GENDRIVER * VTK_FIELD_DRIVER<T>::copy(void) const
+{
+  VTK_FIELD_DRIVER<T> * myDriver = new VTK_FIELD_DRIVER<T>(*this);
+
+  return myDriver ;
+}
+
+template <class T> void VTK_FIELD_DRIVER<T>::read (void)
+  throw (MEDEXCEPTION)
+{
+  throw MEDEXCEPTION("VTK_FIELD_DRIVER::read : Can't read with a VTK driver because it is write only driver !");
+}
+
+template <class T> void VTK_FIELD_DRIVER<T>::write(void) const
+  throw (MEDEXCEPTION)
+{
+  const char * LOC = "VTK_FIELD_DRIVER::write(void) const " ;
+  BEGIN_OF(LOC);
+
+  // we get the Support and its associated Mesh
+
+  const SUPPORT * supportField = _ptrField->getSupport();
+  MESH * meshField = supportField->getMesh();
+
+  // Well we must open vtk file first, because there are
+  // no other driver than MED for VTK that do it !
+  openConst() ;
+
+  // could we put more than one Mesh ?????
+  (*_vtkFile) << "# vtk DataFile Version 2.0" << endl 
+          << "maillage from MedMemory"  << endl ;
+  // only ASCII for the moment (binary came later :-)
+  (*_vtkFile) << "ASCII" << endl ;
+
+  (*_vtkFile) << "DATASET UNSTRUCTURED_GRID" << endl ;
+  // put points (all point are in 3D, so if we are in 1D or 2D, we complete by zero !
+  int SpaceDimension = meshField->getSpaceDimension() ;
+  int NumberOfNodes = meshField->getNumberOfNodes() ;
+  (*_vtkFile) << "POINTS " << NumberOfNodes << " float" << endl ;
+  const double *coordinate = meshField->getCoordinates(MED_FULL_INTERLACE) ;
+  for (int i=0;i<NumberOfNodes;i++) {
+    for (int j=0;j<SpaceDimension;j++)
+      (*_vtkFile) << coordinate[i*SpaceDimension+j] << " " ;
+    if (SpaceDimension==1) 
+      (*_vtkFile) << "0 0" ;
+    if (SpaceDimension==2) 
+      (*_vtkFile) << "0" ;
+    (*_vtkFile) << endl ;
+  }
+
+  // we put connectivity
+  // how many cells and how many value in connectivity :
+  int cells_types_count = meshField->getNumberOfTypes(MED_CELL) ;
+  //  int * cells_count = meshField->get_cells_count() ;
+  //  int cells_sum = cells_count[cells_types_count] ;
+  int cells_sum = meshField->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) ;
+  const CELLMODEL * cells_type = meshField->getCellsTypes(MED_CELL) ;
+  //  int connectivity_sum = 0 ;
+
+  //const int * connectivity = meshField->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,MED_ALL_ELEMENTS) ; !! UNUSED VARIABLE !!
+  const int * connectivityIndex = meshField->getConnectivityIndex(MED_NODAL,MED_CELL) ;
+
+  int connectivity_sum =  connectivityIndex[cells_sum]-1 ;
+
+  (*_vtkFile) << "CELLS " << cells_sum << " " << connectivity_sum+cells_sum << endl ;
+  // we put connectivity
+  for (int i=0;i<cells_types_count;i++) {
+    int *filter = (int*) NULL ; // index in vtk connectivity
+    switch (cells_type[i].getType())
+      {
+      case MED_POINT1  : {
+       filter = new int[1] ;
+       filter[0] = 0 ;
+        break ;
+      }
+      case MED_SEG2    : {
+        filter = new int[2] ;
+       filter[0] = 0 ;
+        filter[1] = 1 ;
+        break ;
+      }
+      case MED_SEG3    : {  
+        break ;
+      }
+      case MED_TRIA3   : {
+        filter = new int[3] ;
+        filter[0] = 0 ;
+        filter[1] = 1 ;
+       filter[2] = 2 ;
+        break ;
+      }
+      case MED_QUAD4   : {
+        filter = new int[4] ;
+        filter[0] = 0 ;
+        filter[1] = 1 ;
+        filter[2] = 2 ;
+       filter[3] = 3 ;
+        break ;
+      }
+      case MED_TRIA6   : {
+        break ;
+      }
+      case MED_QUAD8   : {
+        break ;
+      }
+      case MED_TETRA4  : {
+        filter = new int[4] ;
+        filter[0] = 0 ;
+        filter[1] = 1 ;
+        filter[2] = 3 ;  // 3td element in med are 4th in vtk (array begin at 0 !)
+        filter[3] = 2 ;  // 4th element in med are 3rd in vtk (array begin at 0 !)
+        break ;
+      }
+      case MED_PYRA5   : {
+        filter = new int[5] ;
+        filter[0] = 0 ;
+        filter[1] = 3 ;  // 2nd element in med are 4th in vtk (array begin at 0 !)
+        filter[2] = 2 ;
+        filter[3] = 1 ;  // 4th element in med are 2nd in vtk (array begin at 0 !)
+       filter[4] = 4 ;
+        break ;
+      }
+      case MED_PENTA6  : {
+        filter = new int[6] ;
+        filter[0] = 0 ;
+        filter[1] = 1 ;
+        filter[2] = 2 ;
+        filter[3] = 3 ;
+        filter[4] = 4 ;
+       filter[5] = 5 ;
+       break ;
+      }
+      case MED_HEXA8   : {
+        filter = new int[8] ;
+        filter[0] = 0 ;
+        filter[1] = 3 ;
+        filter[2] = 2 ;
+        filter[3] = 1 ;
+        filter[4] = 4 ;
+        filter[5] = 7 ;
+       filter[6] = 6 ;
+       filter[7] = 5 ;
+        break ;
+      }
+      case MED_TETRA10 : {
+        break ;
+      }
+      case MED_PYRA13  : {
+        break ;
+      }
+      case MED_PENTA15 : {
+        break ;
+      }
+      case MED_HEXA20  : {
+        break ;
+      }
+      default : { 
+        break ;
+      }
+      }
+    if (filter==NULL) 
+      throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": MED element type not supported yet : " << cells_type[i].getName() ) ) ;
+    int nodes_cell = cells_type[i].getNumberOfNodes();
+    int numberOfCell = meshField->getNumberOfElements(MED_CELL,cells_type[i].getType()) ;
+    const int * connectivityArray = meshField->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,cells_type[i].getType());
+    for (int j=0;j<numberOfCell;j++) {
+      (*_vtkFile) << nodes_cell << " " ;
+      for (int k=0;k<nodes_cell;k++)
+       (*_vtkFile) << connectivityArray[j*nodes_cell+filter[k]] - 1 << " " ;
+      (*_vtkFile) << endl ;
+    }
+    if (filter != NULL)
+      delete[] filter ;
+  }
+  (*_vtkFile) << endl ;
+  // we put cells type
+  (*_vtkFile) << "CELL_TYPES " << cells_sum << endl ;
+  for (int i=0;i<cells_types_count;i++) {
+    int vtkType = 0 ;
+    switch (cells_type[i].getType())
+      {
+      case MED_POINT1  : {
+       vtkType = 1 ;
+        break ;
+      }
+      case MED_SEG2    : {
+       vtkType = 3 ;
+        break ;
+      }
+      case MED_SEG3    : {  
+       vtkType = 0 ;
+        break ;
+      }
+      case MED_TRIA3   : {
+       vtkType = 5 ;
+        break ;
+      }
+      case MED_QUAD4   : {
+       vtkType = 9 ;
+        break ;
+      }
+      case MED_TRIA6   : {
+       vtkType = 0 ;
+        break ;
+      }
+      case MED_QUAD8   : {
+       vtkType = 0 ;
+        break ;
+      }
+      case MED_TETRA4  : {
+       vtkType = 10 ;
+        break ;
+      }
+      case MED_PYRA5   : {
+       vtkType = 14 ;
+        break ;
+      }
+      case MED_PENTA6  : {
+       vtkType = 13 ;
+       break ;
+      }
+      case MED_HEXA8   : {
+       vtkType = 12 ;
+        break ;
+      }
+      case MED_TETRA10 : {
+       vtkType = 0 ;
+        break ;
+      }
+      case MED_PYRA13  : {
+       vtkType = 0 ;
+        break ;
+      }
+      case MED_PENTA15 : {
+       vtkType = 0 ;
+        break ;
+      }
+      case MED_HEXA20  : {
+       vtkType = 0 ;
+        break ;
+      }
+      default : { 
+       vtkType = 0 ;
+        break ;
+      }
+      }
+    if (vtkType == 0)
+      throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": MED element type not supported yet : " << cells_type[i].getType() ) ) ;
+    int numberOfCell = meshField->getNumberOfElements(MED_CELL,cells_type[i].getType()) ;
+    for (int j=0;j<numberOfCell;j++)
+      (*_vtkFile) << vtkType << endl ;
+  }
+
+  // first : field on node
+  // fields is on all node !
+
+  // second : field on cell
+  // fields is on all cell !
+
+  int dt = _ptrField->getIterationNumber();
+  int it = _ptrField->getOrderNumber();
+
+  ostringstream name ;
+  string nameField = _ptrField->getName();
+  medEntityMesh entitySupport = supportField->getEntity();
+  name << nameField << "_" << dt << "_" << it ;
+
+  if (!(supportField->isOnAllElements()))
+    throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which is not on all entities of the mesh !" << entitySupport));
+
+  if (entitySupport == MED_NODE)
+    (*_vtkFile) << "POINT_DATA " << meshField->getNumberOfNodes() << endl ;
+  else if (entitySupport == MED_CELL)
+    (*_vtkFile) << "CELL_DATA " << meshField->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) << endl ;
+  else
+    throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which is not on all nodes or cells but it's on !" << entitySupport));
+
+  int NomberOfValue = supportField->getNumberOfElements(MED_ALL_ELEMENTS) ;
+  int NomberOfComponents =  _ptrField->getNumberOfComponents() ;
+
+  med_type_champ fieldType = _ptrField->getValueType() ;
+
+  SCRUTE(name.str());
+  SCRUTE(fieldType);
+
+  switch (fieldType)
+    {
+    case MED_INT32 : {
+      MESSAGE("MED_INT32");
+      if (NomberOfComponents==3)
+       (*_vtkFile) << "VECTORS " << name.str() << " int" << endl ;
+      else if (NomberOfComponents<=4)
+       {
+         (*_vtkFile) << "SCALARS " << name.str() << " int " << NomberOfComponents << endl ;
+         (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
+       }
+      else
+       throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !"));
+      //const int * value = ((FIELD<int>*)myField)->getValue(MED_NO_INTERLACE) ;
+      const int * value = ((FIELD<int>*)_ptrField)->getValue(MED_NO_INTERLACE) ;
+      for (int i=0; i<NomberOfValue; i++)
+       {
+         for(int j=0; j<NomberOfComponents; j++)
+           (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
+         (*_vtkFile) << endl ;
+       }
+      break ;
+    }
+    case MED_REEL64 : {
+      MESSAGE("MED_REEL64");
+      if (NomberOfComponents==3)
+       (*_vtkFile) << "VECTORS " << name.str() << " float" << endl ;
+      else if (NomberOfComponents<=4)
+       {
+         (*_vtkFile) << "SCALARS " << name.str() << " float " << NomberOfComponents << endl ;
+         (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
+       }
+      else
+       throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !"));
+
+      const double * value = ((FIELD<double>*)_ptrField)->getValue(MED_NO_INTERLACE) ;
+      for (int i=0; i<NomberOfValue; i++)
+       {
+         for(int j=0; j<NomberOfComponents; j++)
+           (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
+         (*_vtkFile) << endl ;
+       }
+      break ;
+    }
+    default : { 
+       throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<< name.str() <<" the type is not int or double !"));
+    }
+    }
+
+  END_OF(LOC);
+}
+
+template <class T> void VTK_FIELD_DRIVER<T>::writeAppend(void) const
+  throw (MEDEXCEPTION)
+{
+  const char * LOC = "VTK_FIELD_DRIVER::writeAppend(void) const " ;
+  BEGIN_OF(LOC);
+
+  // we get the Support and its associated Mesh
+
+  const SUPPORT * supportField = _ptrField->getSupport();
+  MESH * meshField = supportField->getMesh();
+
+  // Well we must open vtk file first, because there are
+  // no other driver than MED for VTK that do it !
+  openConstAppend() ;
+
+  // first : field on node
+  // fields is on all node !
+
+  // second : field on cell
+  // fields is on all cell !
+
+  int dt = _ptrField->getIterationNumber();
+  int it = _ptrField->getOrderNumber();
+
+  ostringstream name ;
+  string nameField = _ptrField->getName();
+  medEntityMesh entitySupport = supportField->getEntity();
+  name << nameField << "_" << dt << "_" << it ;
+
+  if (!(supportField->isOnAllElements()))
+    throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which is not on all entities of the mesh !" << entitySupport));
+
+  if (entitySupport == MED_NODE)
+    (*_vtkFile) << "POINT_DATA " << meshField->getNumberOfNodes() << endl ;
+  else if (entitySupport == MED_CELL)
+    (*_vtkFile) << "CELL_DATA " << meshField->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) << endl ;
+  else
+    throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which is not on all nodes or cells but it's on !" << entitySupport));
+
+  int NomberOfValue = supportField->getNumberOfElements(MED_ALL_ELEMENTS) ;
+  int NomberOfComponents =  _ptrField->getNumberOfComponents() ;
+
+  med_type_champ fieldType = _ptrField->getValueType() ;
+
+  SCRUTE(name.str());
+  SCRUTE(fieldType);
+
+  switch (fieldType)
+    {
+    case MED_INT32 : {
+      MESSAGE("MED_INT32");
+      if (NomberOfComponents==3)
+       (*_vtkFile) << "VECTORS " << name.str() << " int" << endl ;
+      else if (NomberOfComponents<=4)
+       {
+         (*_vtkFile) << "SCALARS " << name.str() << " int " << NomberOfComponents << endl ;
+         (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
+       }
+      else
+       throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !"));
+      //const int * value = ((FIELD<int>*)myField)->getValue(MED_NO_INTERLACE) ;
+      const int * value = ((FIELD<int>*)_ptrField)->getValue(MED_NO_INTERLACE) ;
+      for (int i=0; i<NomberOfValue; i++)
+       {
+         for(int j=0; j<NomberOfComponents; j++)
+           (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
+         (*_vtkFile) << endl ;
+       }
+      break ;
+    }
+    case MED_REEL64 : {
+      MESSAGE("MED_REEL64");
+      if (NomberOfComponents==3)
+       (*_vtkFile) << "VECTORS " << name.str() << " float" << endl ;
+      else if (NomberOfComponents<=4)
+       {
+         (*_vtkFile) << "SCALARS " << name.str() << " float " << NomberOfComponents << endl ;
+         (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
+       }
+      else
+       throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !"));
+
+      const double * value = ((FIELD<double>*)_ptrField)->getValue(MED_NO_INTERLACE) ;
+      for (int i=0; i<NomberOfValue; i++)
+       {
+         for(int j=0; j<NomberOfComponents; j++)
+           (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
+         (*_vtkFile) << endl ;
+       }
+      break ;
+    }
+    default : { 
+       throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<< name.str() <<" the type is not int or double !"));
+    }
+    }
+
+  END_OF(LOC);
+}
+
+#endif /* VTK_FIELD_DRIVER_HXX */
index 70df3ee59c9ad0680d8502234dbf74fd18da2c61..78e3e982b8b3c4bf45267c0e64013b0c8429f760 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_VtkMedDriver.cxx
-//  Module : MED
-
 using namespace std;
 #include "MEDMEM_VtkMedDriver.hxx"
 
@@ -66,8 +40,13 @@ VTK_MED_DRIVER::VTK_MED_DRIVER(const VTK_MED_DRIVER & driver):
 
 VTK_MED_DRIVER::~VTK_MED_DRIVER()
 {
+  const char * LOC ="VTK_MED_DRIVER::~VTK_MED_DRIVER()";
+  BEGIN_OF(LOC);
+
   close();
   delete _vtkFile ;
+
+  END_OF(LOC);
 }
 
 GENDRIVER * VTK_MED_DRIVER::copy() const
@@ -143,13 +122,13 @@ void VTK_MED_DRIVER::write() const {
 
   int NumberOfMeshes = _ptrMed->getNumberOfMeshes() ;
   deque<string> MeshNames = _ptrMed->getMeshNames() ;
-  deque<string>::const_iterator  currentMesh ;
+  //deque<string>::const_iterator  currentMesh ; !! UNUSED VARIABLE !!
   // In fact, we must take care of all supports 
   // We restrict Field on all nodes or cells
 
   int NumberOfFields = _ptrMed->getNumberOfFields() ;
   deque<string> FieldNames = _ptrMed->getFieldNames() ;
-  deque<string>::const_iterator  currentField ;
+  //deque<string>::const_iterator  currentField ; !! UNUSED VARIABLE !!
 
   //  for ( currentMesh=MeshName.begin();currentMesh != MeshName.end(); currentMesh++) {
   for (int i=0; i<NumberOfMeshes; i++) {
@@ -174,7 +153,7 @@ void VTK_MED_DRIVER::write() const {
              name << myField->getName() << "_" << dt << "_" << it ;
              writeField(myField,name.str()) ;
            } else
-             INFOS("Could not write field "<<myField->getName()<<" which is not on all nodes !");
+             MESSAGE(LOC << "Could not write field "<<myField->getName()<<" which is not on all nodes !");
        }
       }
     }
@@ -196,7 +175,7 @@ void VTK_MED_DRIVER::write() const {
              name << myField->getName() << "_" << dt << "_" << it ;
              writeField(myField,name.str()) ;
            } else
-             INFOS("Could not write field "<<myField->getName()<<" which is not on all cells !");
+             MESSAGE(LOC << "Could not write field "<<myField->getName()<<" which is not on all cells !");
        }
       }
     }
@@ -205,7 +184,7 @@ void VTK_MED_DRIVER::write() const {
 
   // Well we must close vtk file first, because there are
   // no other driver than MED for VTK that do it !
-  closeConst() ;
+  //  closeConst() ;
   
   END_OF(LOC);
 }
@@ -240,7 +219,7 @@ void VTK_MED_DRIVER::writeMesh(MESH * myMesh) const {
   const CELLMODEL * cells_type = myMesh->getCellsTypes(MED_CELL) ;
   //  int connectivity_sum = 0 ;
 
-  const int * connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,MED_ALL_ELEMENTS) ;
+  //const int * connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,MED_ALL_ELEMENTS) ; !! UNUSED VARIABLE !!
   const int * connectivityIndex = myMesh->getConnectivityIndex(MED_NODAL,MED_CELL) ;
 
   int connectivity_sum =  connectivityIndex[cells_sum]-1 ;
@@ -468,7 +447,7 @@ void VTK_MED_DRIVER::writeField(FIELD_ * myField,string name) const {
        (*_vtkFile) << "SCALARS " << name << " int " << NomberOfComponents << endl ;
        (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
       } else {
-       INFOS("Could not write field "<<myField->getName()<<" there are more than 4 components !");
+       MESSAGE(LOC << "Could not write field "<<myField->getName()<<" there are more than 4 components !");
        return ;
       }
  
@@ -489,7 +468,7 @@ void VTK_MED_DRIVER::writeField(FIELD_ * myField,string name) const {
        (*_vtkFile) << "SCALARS " << name << " float " << NomberOfComponents << endl ;
        (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
       } else {
-       INFOS("Could not write field "<<myField->getName()<<" there are more than 4 components !");
+       MESSAGE(LOC << "Could not write field "<<myField->getName()<<" there are more than 4 components !");
        return ;
       }
       const double * value = ((FIELD<double>*)myField)->getValue(MED_NO_INTERLACE) ;
@@ -501,7 +480,7 @@ void VTK_MED_DRIVER::writeField(FIELD_ * myField,string name) const {
       break ;
     }
     default : { 
-             INFOS("Could not write field "<<name<<" the type is not int or double !");
+      MESSAGE(LOC << "Could not write field "<<name<<" the type is not int or double !");
     }
     }
   
@@ -509,7 +488,8 @@ void VTK_MED_DRIVER::writeField(FIELD_ * myField,string name) const {
 }
 
 void VTK_MED_DRIVER::writeSupport(SUPPORT * mySupport) const {
-  const char * LOC = "VTK_MED_DRIVER::writeSupport(SUPPORT *)" ;
+  const char * LOC = "VTK_MED_DRIVER::writeSupport(SUPPORT *) : " ;
   BEGIN_OF(LOC) ;
+  MESSAGE(LOC << "Not yet implemented, acting on the object " << *mySupport);
   END_OF(LOC) ;
 }
index 9e3cdf5538bfb3213d1af6a0623f9caeca1cabca..72ee1d0a75f5983fab356877c0c8ebe854b433bb 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_VtkMedDriver.hxx
-//  Module : MED
-
 #ifndef VTK_MED_DRIVER_HXX
 #define VTK_MED_DRIVER_HXX
 
diff --git a/src/MEDMEM/MEDMEM_VtkMeshDriver.cxx b/src/MEDMEM/MEDMEM_VtkMeshDriver.cxx
new file mode 100644 (file)
index 0000000..b991bcd
--- /dev/null
@@ -0,0 +1,393 @@
+using namespace std;
+#include "MEDMEM_VtkMeshDriver.hxx"
+
+#include "MEDMEM_DriversDef.hxx"
+
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Group.hxx"
+#include "MEDMEM_Coordinate.hxx"
+#include "MEDMEM_Connectivity.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_CellModel.hxx"
+#include "MEDMEM_Grid.hxx"
+
+#include <sstream>
+
+VTK_MESH_DRIVER::VTK_MESH_DRIVER(): GENDRIVER(), 
+                                   _ptrMesh((MESH * const)MED_NULL)
+{
+  _vtkFile = new ofstream();
+  // What about _id in Gendriver ?
+  // _driverType ???
+}
+
+VTK_MESH_DRIVER::VTK_MESH_DRIVER(const string & fileName,
+                                MESH * ptrMesh) :
+  GENDRIVER(fileName,MED_WRONLY),
+  _ptrMesh(ptrMesh)
+{
+  const char * LOC = "VTK_MESH_DRIVER::VTK_MESH_DRIVER(const string & fileName, MESH * ptrMesh) : " ;
+
+  // Send an exception because a VTK_MESH_DRIVER object cannot be instantied
+  // from a file and there is no read for that kind of driver
+
+  //  throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "This driver is only used to write in VTK format So thie object can not be instantied using a file!"));
+
+  //  _ptrMesh->addDriver(*this); // OU RECUPERER L'ID.
+  MESSAGE(LOC << "WARNING this driver is only used to write in VTK format So the object can not be instantied using a file!");
+
+  _vtkFile = new ofstream(); 
+}
+
+VTK_MESH_DRIVER::VTK_MESH_DRIVER(const VTK_MESH_DRIVER & driver): 
+  GENDRIVER(driver),
+  _ptrMesh(driver._ptrMesh),
+  _meshName(driver._meshName)
+{
+  _ptrMesh->addDriver(*this);
+  _vtkFile = new ofstream();
+}
+
+VTK_MESH_DRIVER::~VTK_MESH_DRIVER()
+{
+  const char * LOC ="VTK_MESH_DRIVER::~VTK_MESH_DRIVER()";
+  BEGIN_OF(LOC);
+
+  close();
+
+  SCRUTE(_vtkFile);
+
+  delete _vtkFile ;
+
+  SCRUTE(_vtkFile);
+
+  END_OF(LOC);
+}
+
+void VTK_MESH_DRIVER::openConst() const throw (MEDEXCEPTION)
+{
+  const char * LOC = "VTK_MESH_DRIVER::openConst()" ;
+  BEGIN_OF(LOC);
+
+  MESSAGE(LOC<<" : _fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
+
+  if ( _fileName == "" )
+    throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) 
+                                     << "_fileName is |\"\"|, please set a correct fileName before calling open()"
+                                     )
+                          );
+
+  if (!(*_vtkFile).is_open())
+    (*_vtkFile).open(_fileName.c_str()) ; 
+//    if (*_vtkFile)
+//      _status = MED_OPENED ;
+//    else
+
+
+  SCRUTE((*_vtkFile).is_open());
+  SCRUTE(_vtkFile);
+
+
+
+  if (!(*_vtkFile))
+    throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Could not open file "
+                                    << _fileName)
+                         );
+  END_OF(LOC);
+}
+
+void VTK_MESH_DRIVER::open() {
+  openConst() ;
+}
+
+void VTK_MESH_DRIVER::closeConst() const throw (MEDEXCEPTION)
+{
+  const char * LOC = "VTK_MESH_DRIVER::closeConst() " ;
+  BEGIN_OF(LOC);
+
+  SCRUTE(_vtkFile);
+  SCRUTE(*_vtkFile);
+
+
+  if ((*_vtkFile).is_open())
+    (*_vtkFile).close();
+  
+//    if (*_vtkFile)
+//      _status = MED_CLOSED ;
+//    else
+
+  SCRUTE(_vtkFile);
+  SCRUTE(*_vtkFile);
+
+  if (!(*_vtkFile))
+    throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Could not close file "
+                                    << _fileName)
+                         );
+
+  END_OF(LOC);
+}
+
+void VTK_MESH_DRIVER::close() {
+  closeConst() ;
+}
+
+void    VTK_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; };
+string  VTK_MESH_DRIVER::getMeshName() const { return _meshName; };
+
+void VTK_MESH_DRIVER::read(void) throw (MEDEXCEPTION)
+{
+  const char * LOC = "VTK_MESH_DRIVER::read() : " ;
+  BEGIN_OF(LOC);
+
+  // Send an exception
+
+  throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "This driver is only used to write in VTK format !"));
+
+  END_OF(LOC);
+}
+
+
+void VTK_MESH_DRIVER::write(void) const
+  throw (MEDEXCEPTION)
+{ 
+  const char * LOC = "void VTK_MESH_DRIVER::write(void) const : ";
+  BEGIN_OF(LOC);
+
+  // Well we must open vtk file first, because there are
+  // no other driver than MED for VTK that do it !
+
+  openConst();
+
+  (*_vtkFile) << "# vtk DataFile Version 2.0" << endl 
+          << "maillage from MedMemory"  << endl ;
+  // only ASCII for the moment (binary came later :-)
+  (*_vtkFile) << "ASCII" << endl ;
+
+
+  (*_vtkFile) << "DATASET UNSTRUCTURED_GRID" << endl ;
+  // put points (all point are in 3D, so if we are in 1D or 2D, we complete by zero !
+  int SpaceDimension = _ptrMesh->getSpaceDimension() ;
+  int NumberOfNodes = _ptrMesh->getNumberOfNodes() ;
+  (*_vtkFile) << "POINTS " << NumberOfNodes << " float" << endl ;
+  const double *coordinate = _ptrMesh->getCoordinates(MED_FULL_INTERLACE) ;
+  for (int i=0;i<NumberOfNodes;i++) {
+    for (int j=0;j<SpaceDimension;j++)
+      (*_vtkFile) << coordinate[i*SpaceDimension+j] << " " ;
+    if (SpaceDimension==1) 
+      (*_vtkFile) << "0 0" ;
+    if (SpaceDimension==2) 
+      (*_vtkFile) << "0" ;
+    (*_vtkFile) << endl ;
+  }
+
+  // we put connectivity
+  // how many cells and how many value in connectivity :
+  int cells_types_count = _ptrMesh->getNumberOfTypes(MED_CELL) ;
+  //  int * cells_count = _ptrMesh->get_cells_count() ;
+  //  int cells_sum = cells_count[cells_types_count] ;
+  int cells_sum = _ptrMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) ;
+  const CELLMODEL * cells_type = _ptrMesh->getCellsTypes(MED_CELL) ;
+  //  int connectivity_sum = 0 ;
+
+  //const int * connectivity = _ptrMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,MED_ALL_ELEMENTS) ; !! UNUSED VARIABLE !!
+  const int * connectivityIndex = _ptrMesh->getConnectivityIndex(MED_NODAL,MED_CELL) ;
+
+  int connectivity_sum =  connectivityIndex[cells_sum]-1 ;
+
+  (*_vtkFile) << "CELLS " << cells_sum << " " << connectivity_sum+cells_sum << endl ;
+  // we put connectivity
+  for (int i=0;i<cells_types_count;i++) {
+    int *filter = (int*) NULL ; // index in vtk connectivity
+    switch (cells_type[i].getType())
+      {
+      case MED_POINT1  : {
+       filter = new int[1] ;
+       filter[0] = 0 ;
+        break ;
+      }
+      case MED_SEG2    : {
+        filter = new int[2] ;
+       filter[0] = 0 ;
+        filter[1] = 1 ;
+        break ;
+      }
+      case MED_SEG3    : {  
+        break ;
+      }
+      case MED_TRIA3   : {
+        filter = new int[3] ;
+        filter[0] = 0 ;
+        filter[1] = 1 ;
+       filter[2] = 2 ;
+        break ;
+      }
+      case MED_QUAD4   : {
+        filter = new int[4] ;
+        filter[0] = 0 ;
+        filter[1] = 1 ;
+        filter[2] = 2 ;
+       filter[3] = 3 ;
+        break ;
+      }
+      case MED_TRIA6   : {
+        break ;
+      }
+      case MED_QUAD8   : {
+        break ;
+      }
+      case MED_TETRA4  : {
+        filter = new int[4] ;
+        filter[0] = 0 ;
+        filter[1] = 1 ;
+        filter[2] = 3 ;  // 3td element in med are 4th in vtk (array begin at 0 !)
+        filter[3] = 2 ;  // 4th element in med are 3rd in vtk (array begin at 0 !)
+        break ;
+      }
+      case MED_PYRA5   : {
+        filter = new int[5] ;
+        filter[0] = 0 ;
+        filter[1] = 3 ;  // 2nd element in med are 4th in vtk (array begin at 0 !)
+        filter[2] = 2 ;
+        filter[3] = 1 ;  // 4th element in med are 2nd in vtk (array begin at 0 !)
+       filter[4] = 4 ;
+        break ;
+      }
+      case MED_PENTA6  : {
+        filter = new int[6] ;
+        filter[0] = 0 ;
+        filter[1] = 1 ;
+        filter[2] = 2 ;
+        filter[3] = 3 ;
+        filter[4] = 4 ;
+       filter[5] = 5 ;
+       break ;
+      }
+      case MED_HEXA8   : {
+        filter = new int[8] ;
+        filter[0] = 0 ;
+        filter[1] = 3 ;
+        filter[2] = 2 ;
+        filter[3] = 1 ;
+        filter[4] = 4 ;
+        filter[5] = 7 ;
+       filter[6] = 6 ;
+       filter[7] = 5 ;
+        break ;
+      }
+      case MED_TETRA10 : {
+        break ;
+      }
+      case MED_PYRA13  : {
+        break ;
+      }
+      case MED_PENTA15 : {
+        break ;
+      }
+      case MED_HEXA20  : {
+        break ;
+      }
+      default : { 
+        break ;
+      }
+      }
+    if (filter==NULL) 
+      throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": MED element type not supported yet : " << cells_type[i].getName() ) ) ;
+    int nodes_cell = cells_type[i].getNumberOfNodes();
+    int numberOfCell = _ptrMesh->getNumberOfElements(MED_CELL,cells_type[i].getType()) ;
+    const int * connectivityArray = _ptrMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,cells_type[i].getType());
+    for (int j=0;j<numberOfCell;j++) {
+      (*_vtkFile) << nodes_cell << " " ;
+      for (int k=0;k<nodes_cell;k++)
+       (*_vtkFile) << connectivityArray[j*nodes_cell+filter[k]] - 1 << " " ;
+      (*_vtkFile) << endl ;
+    }
+    if (filter != NULL)
+      delete[] filter ;
+  }
+  (*_vtkFile) << endl ;
+  // we put cells type
+  (*_vtkFile) << "CELL_TYPES " << cells_sum << endl ;
+  for (int i=0;i<cells_types_count;i++) {
+    int vtkType = 0 ;
+    switch (cells_type[i].getType())
+      {
+      case MED_POINT1  : {
+       vtkType = 1 ;
+        break ;
+      }
+      case MED_SEG2    : {
+       vtkType = 3 ;
+        break ;
+      }
+      case MED_SEG3    : {  
+       vtkType = 0 ;
+        break ;
+      }
+      case MED_TRIA3   : {
+       vtkType = 5 ;
+        break ;
+      }
+      case MED_QUAD4   : {
+       vtkType = 9 ;
+        break ;
+      }
+      case MED_TRIA6   : {
+       vtkType = 0 ;
+        break ;
+      }
+      case MED_QUAD8   : {
+       vtkType = 0 ;
+        break ;
+      }
+      case MED_TETRA4  : {
+       vtkType = 10 ;
+        break ;
+      }
+      case MED_PYRA5   : {
+       vtkType = 14 ;
+        break ;
+      }
+      case MED_PENTA6  : {
+       vtkType = 13 ;
+       break ;
+      }
+      case MED_HEXA8   : {
+       vtkType = 12 ;
+        break ;
+      }
+      case MED_TETRA10 : {
+       vtkType = 0 ;
+        break ;
+      }
+      case MED_PYRA13  : {
+       vtkType = 0 ;
+        break ;
+      }
+      case MED_PENTA15 : {
+       vtkType = 0 ;
+        break ;
+      }
+      case MED_HEXA20  : {
+       vtkType = 0 ;
+        break ;
+      }
+      default : { 
+       vtkType = 0 ;
+        break ;
+      }
+      }
+    if (vtkType == 0)
+      throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": MED element type not supported yet : " << cells_type[i].getType() ) ) ;
+    int numberOfCell = _ptrMesh->getNumberOfElements(MED_CELL,cells_type[i].getType()) ;
+    for (int j=0;j<numberOfCell;j++)
+      (*_vtkFile) << vtkType << endl ;
+  }
+
+
+  END_OF(LOC);
+} 
+
+GENDRIVER * VTK_MESH_DRIVER::copy(void) const
+{
+  return new VTK_MESH_DRIVER(*this);
+}
diff --git a/src/MEDMEM/MEDMEM_VtkMeshDriver.hxx b/src/MEDMEM/MEDMEM_VtkMeshDriver.hxx
new file mode 100644 (file)
index 0000000..dd795f4
--- /dev/null
@@ -0,0 +1,80 @@
+#ifndef VTK_MESH_DRIVER_HXX
+#define VTK_MESH_DRIVER_HXX
+
+#include <string>
+#include <vector>
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_GenDriver.hxx"
+
+#include "MEDMEM_STRING.hxx"
+#include "MEDMEM_Exception.hxx"
+#include "utilities.h"
+
+#include <fstream>
+
+class MESH;
+class FAMILY;
+class GROUP;
+class CONNECTIVITY;
+
+/*!
+
+  Driver Vtk for MESH (only for writing).
+
+  Generic part : implement open and close methods.
+
+*/
+class VTK_MESH_DRIVER : public GENDRIVER
+{
+protected:
+
+  MESH *   _ptrMesh;
+  ofstream *        _vtkFile ;     // The _vtkFile used to write Meshes and Fields to _filename
+  string         _meshName;
+
+public :
+
+  /*!
+    Constructor.
+  */
+  VTK_MESH_DRIVER() ;
+  /*!
+    Constructor.
+  */
+  VTK_MESH_DRIVER(const string & fileName,  MESH * ptrMesh) ;
+  /*!
+    Copy constructor.
+  */
+  VTK_MESH_DRIVER(const VTK_MESH_DRIVER & driver) ;
+
+  /*!
+    Destructor.
+  */
+  ~VTK_MESH_DRIVER() ;
+
+  void open() ;
+  void close() ;
+
+  void openConst() const throw (MEDEXCEPTION);
+  void closeConst() const throw (MEDEXCEPTION);
+
+  void write( void ) const throw (MEDEXCEPTION) ;
+  void read ( void ) throw (MEDEXCEPTION) ;
+
+  /*!
+    Set the name of the MESH asked in file.
+
+    It could be different than the name of the MESH object.
+  */
+  void   setMeshName(const string & meshName) ;
+  /*!
+    Get the name of the MESH asked in file.
+  */
+  string getMeshName() const ;
+
+private:
+  GENDRIVER * copy ( void ) const;
+
+};
+
+#endif /* VTK_MESH_DRIVER_HXX */
index 92d578b0f7362b69e876f07c13baed28ea31b538..bbc2be34590d105907c1520ebf73b98a4f18d666 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_define.hxx
-//  Module : MED
-
 #ifndef DEFINE_HXX
 #define DEFINE_HXX     
 
@@ -55,29 +29,52 @@ namespace MED_EN {
 #define MED_TAILLE_LNOM  80    
 #define MED_TAILLE_PNOM   8 
 
-typedef enum {MED_CARTESIAN, MED_POLAR, MED_BODY_FITTED} med_grid_type;
-
-typedef enum {MED_FULL_INTERLACE,
-             MED_NO_INTERLACE}  medModeSwitch; 
-
-typedef enum {MED_LECT,MED_ECRI,MED_REMP} med_mode_acces; 
 
-typedef enum {MED_CELL, MED_FACE, MED_EDGE, MED_NODE, MED_ALL_ENTITIES} medEntityMesh; 
-
-typedef enum {MED_COOR, MED_CONN, MED_NOM, MED_NUM, MED_FAM} med_table;
-
-typedef enum {MED_REEL64=6, MED_INT32=24,MED_INT64=26, MED_INT} med_type_champ;
+    typedef long medGeometryElement;
+    const medGeometryElement MED_NONE = 0;
+    const medGeometryElement MED_POINT1 = 1;
+    const medGeometryElement MED_SEG2 = 102;
+    const medGeometryElement MED_SEG3 = 103;
+    const medGeometryElement MED_TRIA3 = 203;
+    const medGeometryElement MED_QUAD4 = 204;
+    const medGeometryElement MED_TRIA6 = 206;
+    const medGeometryElement MED_QUAD8 = 208;
+    const medGeometryElement MED_TETRA4 = 304;
+    const medGeometryElement MED_PYRA5 = 305;
+    const medGeometryElement MED_PENTA6 = 306;
+    const medGeometryElement MED_HEXA8 = 308;
+    const medGeometryElement MED_TETRA10 = 310;
+    const medGeometryElement MED_PYRA13 = 313;
+    const medGeometryElement MED_PENTA15 = 315;
+    const medGeometryElement MED_HEXA20 = 320;
+    const medGeometryElement MED_ALL_ELEMENTS = 999;
+
+    typedef long medEntityMesh;
+    const medEntityMesh MED_CELL = 0;
+    const medEntityMesh MED_FACE = 1;
+    const medEntityMesh MED_EDGE = 2;
+    const medEntityMesh MED_NODE = 3;
+    const medEntityMesh MED_ALL_ENTITIES = 4;
+    
+    typedef long medModeSwitch;
+    const medModeSwitch MED_FULL_INTERLACE = 0;
+    const medModeSwitch MED_NO_INTERLACE = 1;
+    
+    typedef long medConnectivity;
+    const medConnectivity MED_NODAL = 0;
+    const medConnectivity MED_DESCENDING = 1;
+    
+    typedef enum {MED_CARTESIAN, MED_POLAR, MED_BODY_FITTED} med_grid_type;
+    
+    typedef enum {MED_LECT,MED_ECRI,MED_REMP} med_mode_acces; 
+    
+    typedef enum {MED_COOR, MED_CONN, MED_NOM, MED_NUM, MED_FAM} med_table;
+    
+    typedef enum {MED_REEL64=6, MED_INT32=24,MED_INT64=26, MED_INT} med_type_champ;
 
 #define MED_NBR_GEOMETRIE_MAILLE 15
 #define MED_NBR_GEOMETRIE_FACE 4
 #define MED_NBR_GEOMETRIE_ARETE 2
-typedef enum {MED_NONE=0, MED_POINT1=1, MED_SEG2=102, MED_SEG3=103, MED_TRIA3=203,
-             MED_QUAD4=204, MED_TRIA6=206,MED_QUAD8=208, MED_TETRA4=304,
-             MED_PYRA5=305, MED_PENTA6=306, MED_HEXA8=308, MED_TETRA10=310, 
-             MED_PYRA13=313, MED_PENTA15=315, MED_HEXA20=320, MED_ALL_ELEMENTS=999}
-medGeometryElement;
-
-typedef enum {MED_NODAL, MED_DESCENDING} medConnectivity ; 
 
 typedef enum {MED_CART, MED_CYL, MED_SPHER} med_repere; 
 
index f1000048e95801298296eb30c489a2cfd2e38315..99295e1043206cb7c2b90d85c6dabe1c1b797afe 100644 (file)
@@ -56,9 +56,12 @@ MEDMEM_Med.hxx \
 MEDMEM_MedMedDriver.hxx \
 MEDMEM_MedMeshDriver.hxx \
 MEDMEM_GibiMeshDriver.hxx \
+MEDMEM_DriverTools.hxx \
 MEDMEM_ModulusArray.hxx \
 MEDMEM_SkyLineArray.hxx \
 MEDMEM_VtkMedDriver.hxx \
+MEDMEM_VtkMeshDriver.hxx \
+MEDMEM_VtkFieldDriver.hxx \
 MEDMEM_Mesh.hxx \
 MEDMEM_Meshing.hxx \
 MEDMEM_STRING.hxx \
@@ -84,12 +87,14 @@ MEDMEM_Exception.cxx \
 MEDMEM_MedMedDriver.cxx \
 MEDMEM_MedMeshDriver.cxx \
 MEDMEM_GibiMeshDriver.cxx \
+MEDMEM_DriverTools.cxx \
 MEDMEM_SkyLineArray.cxx \
 MEDMEM_Mesh.cxx \
 MEDMEM_Meshing.cxx \
 MEDMEM_Support.cxx \
 MEDMEM_Unit.cxx \
 MEDMEM_VtkMedDriver.cxx \
+MEDMEM_VtkMeshDriver.cxx \
 MEDMEM_Grid.cxx
 
 
@@ -99,7 +104,7 @@ BIN_SRC =
 BIN_SERVER_IDL = 
 BIN_CLIENT_IDL = 
 
-TEST_PROGS = test_MEDMEM_ModulusArray test_MEDMEM_Array test_MEDMEM_SkyLineArray test_MEDMEM_CellModel testUPointerOf testUCoordinate testUUnit testUGeoNameMeshEntities testUMedException testUModulusArray testUSkyLineArray testUArray testUCellModel readEntete readCoordinate test_copie_field_ test_copie_fieldT test_copie_coordinate test_copie_medarray test_copie_connectivity test_copie_support test_copie_family test_copie_group test_copie_mesh test_affect_medarray test_MEDMEM_Meshing
+TEST_PROGS = test_MEDMEM_ModulusArray test_MEDMEM_Array test_MEDMEM_SkyLineArray test_MEDMEM_CellModel testUPointerOf testUCoordinate testUUnit testUGeoNameMeshEntities testUMedException testUModulusArray testUSkyLineArray testUArray testUCellModel readEntete readCoordinate test_copie_field_ test_copie_fieldT test_copie_coordinate test_copie_medarray test_copie_connectivity test_copie_support test_copie_family test_copie_group test_copie_mesh test_affect_medarray test_MEDMEM_Meshing test_operation_fielddouble test_operation_fieldint test_gibi_driver
 
 # testUCellModel -> a revoir car l'API a changee (plus de vector)
 
@@ -108,9 +113,9 @@ CXXFLAGS+=-ftemplate-depth-42 -I${KERNEL_ROOT_DIR}/include/salome
 LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -lSalomeLoggerServer -L${KERNEL_ROOT_DIR}/lib/salome
 
 # build create_mesh :
-bin: create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_mesh_c3h8q4_wrong create_mesh_c2q4s2_wrong create_grid
+bin: create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_mesh_c3h8q4_wrong create_mesh_c2q4s2_wrong create_grid create_mesh_c2q4 create_mesh_c3h8
 
-create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_grid: %: %.c
+create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_grid create_mesh_c2q4 create_mesh_c3h8: %: %.c
        $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(MED2_LIBS) $(HDF5_LIBS) $(LDFLAGS) $< 
 
 @CONCLUDE@
index 8e0446897dccacf82b80f68349e64dbdcf5117d2..2dbedc1e1603cf7a92def97871e1ff5db1cb2e93 100644 (file)
@@ -1,31 +1,3 @@
-/*----------------------------------------------------------------------------
-MED MEDMEM : MED files in memory
-
- Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-
-
-
-  File   : create_mesh.c
-Module : MED
-----------------------------------------------------------------------------*/
-
 #include <med.h>
 #include <string.h>
 
diff --git a/src/MEDMEM/create_mesh_c2q4.c b/src/MEDMEM/create_mesh_c2q4.c
new file mode 100644 (file)
index 0000000..2d85f4c
--- /dev/null
@@ -0,0 +1,226 @@
+/*
+  creation d'une geometrie 2d : un cube [0,1]^2
+  maillé uniformement en quadrangle reguliers;
+  avec en plus une partie des aretes (une partie
+  des arretes de la frontiere) du maillage.
+  ATTENTION : 3 noeuds dans chaque direction
+*/
+
+#include <med.h>
+#include <string.h>
+
+int main (int argc, char **argv)
+{
+  med_err ret;
+  med_idt fid;
+  char maa[MED_TAILLE_NOM+1] = "carre_en_quad4";
+  med_int mdim = 2;
+  med_int nnoe = 9;
+  /*
+    les noeuds:
+  */
+  med_float coo[18] = {
+    0.0, 0.0,
+    0.5, 0.0,
+    1.0, 0.0,
+    0.0, 0.5,
+    0.5, 0.5,
+    1.0, 0.5,
+    0.0, 1.0,
+    0.5, 1.0,
+    1.0, 1.0
+  };
+  char nomcoo[2*MED_TAILLE_PNOM+1] = "x       y       ";
+  char unicoo[2*MED_TAILLE_PNOM+1] = "cm      cm      ";
+  /*  char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1    nom2    nom3    nom4";*/
+  char *nomnoe ;
+  med_int numnoe[9] = {1,2,3,4,5,6,7,8,9};
+  med_int nufano[9] = {0,0,0,0,0,0,0,0,0};
+  /*
+    les elements:
+  */
+  med_int nquad4 = 4;
+  med_int quad4[16] = {
+    4, 5, 2, 1,
+    5, 6, 3, 2,
+    7, 8, 5, 4,
+    8, 9, 6, 5
+  };
+  char nomquad4[MED_TAILLE_PNOM*4+1] = "quad1   quad2   quad3   quad4   ";
+  med_int numquad4[4] = {1,2,3,4};
+  med_int nufaquad4[4] = {-1,-1,0,0};
+
+  char nomfam[MED_TAILLE_NOM+1];
+  med_int numfam;
+  char attdes[MED_TAILLE_DESC+1];
+  med_int natt;
+  med_int attide;
+  med_int attval;
+  med_int ngro;
+  char gro[MED_TAILLE_LNOM+1];
+  int i;
+  int nfame = 1; 
+  int nfamn = 1;
+
+  /*
+    Some fields : 2 on nodes : one int and one double , one on cells : double
+   */
+  char champ1[MED_TAILLE_NOM+1]="fieldnodeint" ;
+  char champ1_comp[MED_TAILLE_PNOM+1]="comp1   " ;
+  char champ1_unit[MED_TAILLE_PNOM+1]="M       " ;
+  med_int     fieldnodeint[9]    = {1,1,3,2,2,3,4,4,5};
+
+  char champ2[MED_TAILLE_NOM+1]="fieldnodedouble" ;
+  char champ2_comp[MED_TAILLE_PNOM+1]="comp1   " ;
+  char champ2_unit[MED_TAILLE_PNOM+1]="J       " ;
+  med_float   fieldnodedouble1[9] = {1.,3.,4.,1.,3.,4.,3.,2.,5.};
+  med_float   fieldnodedouble2[9] = {1.,2.,2.,3.,3.,3.,4.,4.,5.};
+
+  char champ3[MED_TAILLE_NOM+1]="fieldcelldouble" ;
+  char champ3_comp[MED_TAILLE_PNOM*2+1]="comp1   comp2   " ;
+  char champ3_unit[MED_TAILLE_PNOM*2+1]="M/S     m/s     " ;
+  med_float   fieldcelldouble[4*2] = {0.,1.,1.,1.,1.,2.,2.,3.};
+
+  /***************************************************************************/
+  fid = MEDouvrir("carre_en_quad4.med",MED_REMP);
+  if (fid < 0)
+    ret = -1;
+  else
+    ret = 0;
+  printf("%d\n",ret);
+
+  /***************************************************************************/
+  if (ret == 0)
+    ret = MEDmaaCr(fid,maa,mdim);
+  printf("%d\n",ret);
+  if (ret == 0)
+    ret = MEDunvCr(fid,maa);
+  printf("%d\n",ret);
+
+  /***************************************************************************/
+  if (ret == 0)
+    ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
+                      nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
+                      nufano,nnoe,MED_ECRI);
+  printf("%d\n",ret);
+
+  /* ecriture des mailles MED_QUAD4 :
+     - connectivite
+     - noms (optionnel) 
+     - numeros (optionnel)
+     - numeros des familles */
+  if (ret == 0) 
+    ret = MEDelementsEcr(fid,maa,mdim,quad4,MED_FULL_INTERLACE,
+                        nomquad4,MED_FAUX,numquad4,MED_VRAI,nufaquad4,nquad4,
+                        MED_MAILLE,MED_QUAD4,MED_NOD,MED_ECRI);
+  printf("%d \n",ret);
+
+  /***************************************************************************/
+  /* ecriture des familles */
+  /* Conventions :
+     - toujours creer une famille de numero 0 ne comportant aucun attribut
+       ni groupe (famille de reference pour les noeuds ou les elements
+       qui ne sont rattaches a aucun groupe ni attribut)
+     - les numeros de familles de noeuds sont > 0
+     - les numeros de familles des elements sont < 0
+     - rien d'imposer sur les noms de familles
+   */ 
+
+  /* la famille 0 */
+  if (ret == 0)
+    {
+      strcpy(nomfam,"FAMILLE_0");
+      numfam = 0;
+      ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
+                    gro,0);
+    }
+  printf("%d \n",ret);
+
+  /* on cree :
+      - 1 familles d'elements de dimension (d)
+        en fait de face (-10)
+  */
+
+  if (ret == 0)
+    {
+      numfam = -1;
+      strcpy(nomfam,"FAMILLE_CELL_");
+      sprintf(nomfam,"%s%d",nomfam,-numfam);
+      attide = 1;
+      attval = numfam*100;
+      natt = 1;
+      strcpy(attdes,"description attribut");
+      strcpy(gro,"groupe0");
+      ngro = 1;
+
+      ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+                    natt,gro,ngro);
+      printf("MEDfamCr : %d\n",ret);
+    }
+  /***************************************************************************/
+  /*
+    Les champs
+  */
+  if (ret == 0)
+    {
+      ret = MEDchampCr(fid,champ1,MED_INT32,champ1_comp,champ1_unit,1);
+      printf("MEDchampCr : %d \n",ret);
+      if (ret == 0) {
+       ret = MEDchampEcr(fid, maa, champ1, (unsigned char *)fieldnodeint,
+                         MED_NO_INTERLACE, nnoe,
+                         MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD, 
+                         0, MED_NOPDT,"        ", 0., MED_NONOR);
+       
+       printf("MEDchampEcr : %d \n",ret);
+      }
+    }
+  
+  if (ret == 0)
+    {
+      ret = MEDchampCr(fid,champ2,MED_REEL64,champ2_comp,champ2_unit,1);
+      printf("MEDchampCr : %d \n",ret);
+      if (ret == 0) {
+       ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
+                         MED_NO_INTERLACE, nnoe,
+                         MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD, 
+                         0, 1,"S       ", 1.1 , MED_NONOR);
+       printf("MEDchampEcr1 : %d \n",ret);
+       ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble2,
+                         MED_NO_INTERLACE, nnoe,
+                         MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD, 
+                         0, 2,"S       ", 1.2 , MED_NONOR);
+       printf("MEDchampEcr2 : %d \n",ret);
+      }
+    }
+  
+  // on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut !
+  if (ret == 0)
+    {
+      ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
+                       MED_NO_INTERLACE, nnoe,
+                       MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD, 
+                       0, MED_NOPDT,"        ", 0. , MED_NONOR);
+      printf("MEDchampEcr : %d \n",ret); 
+    }
+
+  if (ret == 0)
+    {
+      ret = MEDchampCr(fid,champ3,MED_REEL64,champ3_comp,champ3_unit,2);
+      printf("MEDchampCr : %d \n",ret);
+      if (ret == 0) {
+       ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble,
+                         MED_NO_INTERLACE, nquad4,
+                         MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE, 
+                         MED_QUAD4, MED_NOPDT,"        ", 0., MED_NONOR);
+       printf("MEDchampEcr : %d \n",ret);
+      }
+    }
+  
+  /***************************************************************************/
+
+  ret = MEDfermer(fid);
+  printf("%d\n",ret);
+  
+  return 0;
+}
+
index ceb89f4bbd3837b1b2e1403fe231f5c19159a124..3896ae7e2348a2243174cee5d650fbd8de971b86 100644 (file)
@@ -1,31 +1,3 @@
-/*----------------------------------------------------------------------------
-MED MEDMEM : MED files in memory
-
- Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-
-
-
-  File   : create_mesh_c2q4s2.c
-Module : MED
-----------------------------------------------------------------------------*/
-
 /*
   creation d'une geometrie 2d : un cube [0,1]^2
   maillé uniformement en quadrangle reguliers;
index 07dcf2a01f57ac9d6b6cdf0bab4fb44efbd7e31e..a4d020de744f0ab93a1bbee7e3ef1efbe67b27fe 100644 (file)
@@ -1,31 +1,3 @@
-/*----------------------------------------------------------------------------
-MED MEDMEM : MED files in memory
-
- Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-
-
-
-  File   : create_mesh_c2q4s2_wrong.c
-Module : MED
-----------------------------------------------------------------------------*/
-
 /*
   creation d'une geometrie 2d : un cube [0,1]^2
   maillé uniformement en quadrangle reguliers;
diff --git a/src/MEDMEM/create_mesh_c3h8.c b/src/MEDMEM/create_mesh_c3h8.c
new file mode 100644 (file)
index 0000000..1153597
--- /dev/null
@@ -0,0 +1,283 @@
+/*
+  creation d'une geometrie 3d : un cube [0,1]^3
+  maillé uniformement en hexahedres reguliers;
+  avec en plus une partie des faces (une partie
+  des faces de la frontiere) du maillage.
+  ATTENTION : 3 noeuds dans chaque direction
+*/
+
+#include <med.h>
+#include <string.h>
+
+int main (int argc, char **argv)
+{
+  med_err ret;
+  med_idt fid;
+  char maa[MED_TAILLE_NOM+1] = "CUBE_EN_HEXA8";
+  med_int mdim = 3;
+  med_int nnoe = 27;
+  /*
+    les noeuds:
+  */
+  med_float coo[81] = {
+    0.0, 0.0, 0.0, 
+    0.5, 0.0, 0.0, 
+    1.0, 0.0, 0.0, 
+    0.0, 0.5, 0.0, 
+    0.5, 0.5, 0.0, 
+    1.0, 0.5, 0.0, 
+    0.0, 1.0, 0.0, 
+    0.5, 1.0, 0.0, 
+    1.0, 1.0, 0.0, 
+    0.0, 0.0, 0.5, 
+    0.5, 0.0, 0.5, 
+    1.0, 0.0, 0.5, 
+    0.0, 0.5, 0.5, 
+    0.5, 0.5, 0.5, 
+    1.0, 0.5, 0.5, 
+    0.0, 1.0, 0.5, 
+    0.5, 1.0, 0.5, 
+    1.0, 1.0, 0.5, 
+    0.0, 0.0, 1.0, 
+    0.5, 0.0, 1.0, 
+    1.0, 0.0, 1.0, 
+    0.0, 0.5, 1.0, 
+    0.5, 0.5, 1.0, 
+    1.0, 0.5, 1.0, 
+    0.0, 1.0, 1.0, 
+    0.5, 1.0, 1.0, 
+    1.0, 1.0, 1.0
+  };
+  char nomcoo[3*MED_TAILLE_PNOM+1] = "x       y       z       ";
+  char unicoo[3*MED_TAILLE_PNOM+1] = "cm      cm      cm      ";
+  /*  char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1    nom2    nom3    nom4";*/
+  char *nomnoe ;
+  med_int numnoe[27] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27};
+  med_int nufano[27] = {1,1,1,1,1,1,1,1,1,3,3,3,3,0,3,3,3,3,2,2,2,2,2,2,2,2,2};
+  /*
+    les elements:
+  */
+  med_int nhexa8 = 8;
+  med_int hexa8[64] = {
+    4, 13, 14, 5, 1, 10, 11, 2,
+    5, 14, 15, 6, 2, 11, 12, 3,
+    7, 16, 17, 8, 4, 13, 14, 5,
+    8, 17, 18, 9, 5, 14, 15, 6,
+    13, 22, 23, 14, 10, 19, 20, 11,
+    14, 23, 24, 15, 11, 20, 21, 12,
+    16, 25, 26, 17, 13, 22, 23, 14,
+    17, 26, 27, 18, 14, 23, 24, 15
+  };
+  char nomhexa8[MED_TAILLE_PNOM*8+1] = "hexa1   hexa2   hexa3   hexa4   hexa5   hexa6   hexa7   hexa8   ";
+  med_int numhexa8[8] = {1,2,3,4,5,6,7,8};
+  med_int nufahexa8[8] = {-1,-1,-1,-1,-2,-2,-2,-2};
+
+  char nomfam[MED_TAILLE_NOM+1];
+  med_int numfam;
+  char attdes[MED_TAILLE_DESC+1];
+  med_int natt;
+  med_int attide;
+  med_int attval;
+  med_int ngro;
+  char gro[MED_TAILLE_LNOM+1];
+  int i;
+  int nfame = 1; 
+  int nfamn = 1;
+  int nfamf = 1;
+
+  /*
+    Some fields : 2 on nodes : one int and one double , one on cells : double
+  */
+
+  char champ1[MED_TAILLE_NOM+1]="fieldnodeint" ;
+  char champ1_comp[MED_TAILLE_PNOM+1]="comp1   " ;
+  char champ1_unit[MED_TAILLE_PNOM+1]="M       " ;
+  med_int fieldnodeint[27] = {1,1,3,2,2,3,4,4,5,1,1,3,2,2,3,4,4,5,1,1,3,2,2,3,4,4,5};
+
+  char champ2[MED_TAILLE_NOM+1]="fieldnodedouble" ;
+  char champ2_comp[MED_TAILLE_PNOM+1]="comp1   " ;
+  char champ2_unit[MED_TAILLE_PNOM+1]="J       " ;
+  med_float fieldnodedouble1[27] = {1.,3.,4.,1.,3.,4.,3.,2.,5.,1.,3.,4.,1.,3.,4.,3.,2.,5.,1.,3.,4.,1.,3.,4.,3.,2.,5.};
+  med_float fieldnodedouble2[27] = {1.,2.,2.,3.,3.,3.,4.,4.,5.,1.,2.,2.,3.,3.,3.,4.,4.,5.,1.,2.,2.,3.,3.,3.,4.,4.,5.};
+
+  char champ3[MED_TAILLE_NOM+1]="fieldcelldouble" ;
+  char champ3_comp[MED_TAILLE_PNOM*3+1]="comp1   comp2   comp3   " ;
+  char champ3_unit[MED_TAILLE_PNOM*3+1]="M/S     m/s     m/s     " ;
+  med_float fieldcelldouble[8*3] = {0.,1.,1.,1.,1.,2.,2.,3.,0.,1.,1.,1.,1.,2.,2.,3.,0.,1.,1.,1.,1.,2.,2.,3.};
+
+  /***************************************************************************/
+  fid = MEDouvrir("cube_hexa8.med",MED_REMP);
+  if (fid < 0)
+    ret = -1;
+  else
+    ret = 0;
+  printf("%d\n",ret);
+
+  /***************************************************************************/
+  if (ret == 0)
+    ret = MEDmaaCr(fid,maa,mdim);
+  printf("%d\n",ret);
+  if (ret == 0)
+    ret = MEDunvCr(fid,maa);
+  printf("%d\n",ret);
+
+  /***************************************************************************/
+  if (ret == 0)
+    ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
+                      nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
+                      nufano,nnoe,MED_ECRI);
+  printf("%d\n",ret);
+
+  /* ecriture des mailles MED_HEXA8 :
+     - connectivite
+     - noms (optionnel) 
+     - numeros (optionnel)
+     - numeros des familles */
+  if (ret == 0) 
+    ret = MEDelementsEcr(fid,maa,mdim,hexa8,MED_FULL_INTERLACE,
+                        nomhexa8,MED_FAUX,numhexa8,MED_VRAI,nufahexa8,nhexa8,
+                        MED_MAILLE,MED_HEXA8,MED_NOD,MED_ECRI);
+  printf("%d \n",ret);
+
+  /***************************************************************************/
+  /* ecriture des familles */
+  /* Conventions :
+     - toujours creer une famille de numero 0 ne comportant aucun attribut
+       ni groupe (famille de reference pour les noeuds ou les elements
+       qui ne sont rattaches a aucun groupe ni attribut)
+     - les numeros de familles de noeuds sont > 0
+     - les numeros de familles des elements sont < 0
+     - rien d'imposer sur les noms de familles
+   */ 
+
+  /* la famille 0 */
+  if (ret == 0)
+    {
+      strcpy(nomfam,"FAMILLE_0");
+      numfam = 0;
+      ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
+                    gro,0);
+    }
+  printf("%d \n",ret);
+
+  /* on cree :
+      - 2 familles d'elements (-1,-2) et 
+      - 3 familles de noeuds (1,2,3) 
+  */
+
+  if (ret == 0)
+    {
+      nfame = 2;
+      for (i=0;i<nfame;i++)
+       {
+         if (ret == 0)
+           {
+             strcpy(nomfam,"FAMILLE_ELEMENT_");
+             numfam = -(i+1);
+             sprintf(nomfam,"%s%d",nomfam,-numfam);
+             attide = 1;
+             attval = numfam*100;
+              natt = 1;
+             strcpy(attdes,"description attribut");
+              strcpy(gro,"groupe1");
+             ngro = 1;
+
+              /*printf("nomfam : %s - numfam : %d - attide : %d - attval : %d - ngro : %d \n",nomfam,numfam,attide,attval,ngro);*/
+
+             ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+                            natt,gro,ngro);
+              printf("MEDfamCr : %d\n",ret);
+           }
+       }
+    }
+  
+  if (ret == 0)
+    {
+      nfamn = 3;
+      for (i=0;i<nfamn;i++)
+       {
+         if(ret == 0)
+           {
+             strcpy(nomfam,"FAMILLE_NOEUD_");
+             numfam = i+1;
+             sprintf(nomfam,"%s%d",nomfam,numfam);
+             attide = 1;
+             attval = numfam*100;
+              natt = 1;
+             strcpy(attdes,"description attribut");
+              strcpy(gro,"groupe2");
+             ngro = 1;
+             ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+                            natt,gro,ngro);
+              printf("MEDfamCr : %d\n",ret);
+           }
+       }
+    }
+
+  /***************************************************************************/
+  /*
+    Les champs
+  */
+  if (ret == 0)
+    {
+      ret = MEDchampCr(fid,champ1,MED_INT32,champ1_comp,champ1_unit,1);
+      printf("MEDchampCr : %d \n",ret);
+      if (ret == 0) {
+       ret = MEDchampEcr(fid, maa, champ1, (unsigned char *)fieldnodeint,
+                         MED_FULL_INTERLACE, nnoe,
+                         MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD, 
+                         0, MED_NOPDT,"        ", 0., MED_NONOR);
+       
+       printf("MEDchampEcr : %d \n",ret);
+      }
+    }
+  
+  if (ret == 0)
+    {
+      ret = MEDchampCr(fid,champ2,MED_REEL64,champ2_comp,champ2_unit,1);
+      printf("MEDchampCr : %d \n",ret);
+      if (ret == 0) {
+       ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
+                         MED_FULL_INTERLACE, nnoe,
+                         MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD, 
+                         0, 1,"S       ", 1.1 , MED_NONOR);
+       printf("MEDchampEcr1 : %d \n",ret);
+       ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble2,
+                         MED_FULL_INTERLACE, nnoe,
+                         MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD, 
+                         0, 2,"S       ", 1.2 , MED_NONOR);
+       printf("MEDchampEcr2 : %d \n",ret);
+      }
+    }
+  
+  // on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut !
+  if (ret == 0)
+    {
+      ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
+                       MED_FULL_INTERLACE, nnoe,
+                       MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD, 
+                       0, MED_NOPDT,"        ", 0. , MED_NONOR);
+      printf("MEDchampEcr : %d \n",ret); 
+    }
+
+  if (ret == 0)
+    {
+      ret = MEDchampCr(fid,champ3,MED_REEL64,champ3_comp,champ3_unit,3);
+      printf("MEDchampCr : %d \n",ret);
+      if (ret == 0) {
+       ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble,
+                         MED_FULL_INTERLACE, nhexa8,
+                         MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE, 
+                         MED_HEXA8, MED_NOPDT,"        ", 0., MED_NONOR);
+       printf("MEDchampEcr : %d \n",ret);
+      }
+    }
+
+  /***************************************************************************/
+
+  ret = MEDfermer(fid);
+  printf("%d\n",ret);
+  
+  return 0;
+}
+
index afc5a0a8a31a779699ec0f60c81c9e64a714c6c1..19c3675c4f2d604ab74758a7f2e31ea275564296 100644 (file)
@@ -1,31 +1,3 @@
-/*----------------------------------------------------------------------------
-MED MEDMEM : MED files in memory
-
- Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-
-
-
-  File   : create_mesh_c3h8q4.c
-Module : MED
-----------------------------------------------------------------------------*/
-
 /*
   creation d'une geometrie 3d : un cube [0,1]^3
   maillé uniformement en hexahedres reguliers;
index 9e2404543f3e36dd3ae8e3d9462e21605ac4d4be..77db282f19a32639ec361af4a2912fb9d43fb97c 100644 (file)
@@ -1,31 +1,3 @@
-/*----------------------------------------------------------------------------
-MED MEDMEM : MED files in memory
-
- Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-
-
-
-  File   : create_mesh_c3h8q4_wrong.c
-Module : MED
-----------------------------------------------------------------------------*/
-
 /*
   creation d'une geometrie 3d : un cube [0,1]^3
   maillé uniformement en hexahedres reguliers;
index ccbb810afb8414d1a45f12e4fd91a53754da08a5..75a3e23e9f19eaaaf433b6113dabe7504a9e0b3b 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : duplicateMED.cxx
-//  Module : MED
-
 using namespace std;
 #include<string>
 
index c2615b0996f21f7ab12ab05829e5a04c2385acfc..94f207b3f8e9e6030fa917c867976f8bd1d74481 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : duplicateMEDMESH.cxx
-//  Module : MED
-
 using namespace std;
 #include<string>
 #include<deque>
@@ -51,7 +25,7 @@ int main (int argc, char ** argv) {
   // we read all meshes in filenameIN 
   try {
     
-    int read ;
+    //int read ; !! UNUSED VARIABLE !!
     myMedDriver.open();
     myMedDriver.readFileStruct();
     myMedDriver.close();
index 877459412ac47db06f76e0f352a893051ad45ee9..39dd5c8715acd2a63466c3188f0567dd087d00be 100644 (file)
@@ -1,12 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  CEA/DEN, EDF R&D
-//
-//
-//
-//  File   : med2vtk.cxx
-//  Module : MED
-
 using namespace std;
 #include<string>
 #include<deque>
index 5090890bc14075ec595cab29f399781a9e5d4e9f..01bf6ea8f44454e0fd2a64d24179c1ddcefaeb94 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : med_test.cxx
-//  Module : MED
-
 using namespace std;
 #include<string>
 
index 418824c4a67c758ebdd2a46669b4f26490516358..be5040b3e8686c523d3165227374df676494d89e 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : test_MEDMEM_Array.cxx
-//  Module : MED
-
 using namespace std;
 #include "utilities.h"
 #include "MEDMEM_Array.hxx"
index e733843d374225c72da8717839eadcb0fac66aee..c125aed14083e31d65f300c423a3b5ef23735dc9 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : test_MEDMEM_CellModel.cxx
-//  Module : MED
-
 using namespace std;
 #include "utilities.h"
 #include "MEDMEM_CellModel.hxx"
index 087ecf343b117cfcac6dbc04a59ba5765aa8c777..feea08dea842b5c320f06a6d2e8c979b72d2e3dc 100644 (file)
@@ -1,14 +1,6 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  CEA/DEN, EDF R&D
-//
-//
-//
-//  File   : test_MEDMEM_Meshing.cxx
-//  Module : MED
-
 #include "MEDMEM_Meshing.hxx"
 #include "MEDMEM_Group.hxx"
+#include "MEDMEM_Field.hxx"
 
 using namespace std;
 
@@ -16,12 +8,17 @@ int main (int argc, char ** argv) {
 
   if (argc <2) {
     cerr << "Usage : " << argv[0] 
-        << " filename" << endl << endl;
+        << " filenameRoot" << endl;
+    cerr << "        where filenameRoot is a root filename, the program will produce" << endl;
+    cerr << "        2 files filenameRoot.med and filenameRoot.vtk" << endl << endl;
     exit(-1);
   }
 
   // filename to save the generated MESH
-  string filename = argv[1] ;
+  string filenameRoot = argv[1] ;
+
+  string filenameMed = filenameRoot+".med";
+  string filenameVtk = filenameRoot+".vtk";
 
   MESHING myMeshing ;
   myMeshing.setName("meshing") ;
@@ -210,7 +207,7 @@ int main (int argc, char ** argv) {
     myGroup.setGeometricType(myTypes);
     const int myNumberOfElements[] = {4,1} ;
     myGroup.setNumberOfElements(myNumberOfElements);
-    const int index[3+1] = {1,5,6} ;
+    const int index[2+1] = {1,5,6} ;
     const int value[4+1]=
     {
       3,4,5,9,
@@ -264,7 +261,245 @@ int main (int argc, char ** argv) {
 
   // all rigtht, we save it !
 
-  int id = myMeshing.addDriver(MED_DRIVER,filename,myMeshing.getName());
-  myMeshing.write(id) ;
+  int idMed = myMeshing.addDriver(MED_DRIVER,filenameMed,myMeshing.getName());
+  myMeshing.write(idMed) ;
+
+  int idVtk = myMeshing.addDriver(VTK_DRIVER,filenameVtk,myMeshing.getName());
+  myMeshing.write(idVtk) ;
+
+  // we build now 8 fields : 4 fields double (integer) :
+  //                         2 fields on nodes (cells) :
+  //                         1 scalar (vector)
+
+  SUPPORT * supportOnNodes = new SUPPORT(&myMeshing,"On_All_Nodes",MED_NODE);
+  int numberOfNodes = supportOnNodes->getNumberOfElements(MED_ALL_ELEMENTS);
+
+  SUPPORT * supportOnCells = new SUPPORT(&myMeshing,"On_All_Cells",MED_CELL);
+  int numberOfCells = supportOnCells->getNumberOfElements(MED_ALL_ELEMENTS);
+
+  FIELD<double> * fieldDoubleScalarOnNodes = new FIELD<double>(supportOnNodes,1);
+  fieldDoubleScalarOnNodes->setName("fieldScalarDoubleNode");
+  fieldDoubleScalarOnNodes->setIterationNumber(-1);
+  fieldDoubleScalarOnNodes->setOrderNumber(-1);
+  fieldDoubleScalarOnNodes->setTime(0.0);
+
+  fieldDoubleScalarOnNodes->setComponentName(1,"Vx");
+  fieldDoubleScalarOnNodes->setComponentDescription(1,"comp1");
+  fieldDoubleScalarOnNodes->setMEDComponentUnit(1,"unit1");
+
+  fieldDoubleScalarOnNodes->setValueType(MED_REEL64);
+
+  FIELD<double> * fieldDoubleVectorOnNodes = new FIELD<double>(supportOnNodes,SpaceDimension);
+  fieldDoubleVectorOnNodes->setName("fieldVectorDoubleNode");
+  fieldDoubleVectorOnNodes->setIterationNumber(-1);
+  fieldDoubleVectorOnNodes->setOrderNumber(-1);
+  fieldDoubleVectorOnNodes->setTime(0.0);
+
+  fieldDoubleVectorOnNodes->setComponentName(1,"Vx");
+  fieldDoubleVectorOnNodes->setComponentDescription(1,"comp1");
+  fieldDoubleVectorOnNodes->setMEDComponentUnit(1,"unit1");
+  fieldDoubleVectorOnNodes->setComponentName(2,"Vy");
+  fieldDoubleVectorOnNodes->setComponentDescription(2,"comp2");
+  fieldDoubleVectorOnNodes->setMEDComponentUnit(2,"unit2");
+  fieldDoubleVectorOnNodes->setComponentName(3,"Vz");
+  fieldDoubleVectorOnNodes->setComponentDescription(3,"comp3");
+  fieldDoubleVectorOnNodes->setMEDComponentUnit(3,"unit3");
+
+  fieldDoubleVectorOnNodes->setValueType(MED_REEL64);
+
+  FIELD<double> * fieldDoubleScalarOnCells = new FIELD<double>(supportOnCells,1);
+  fieldDoubleScalarOnCells->setName("fieldScalarDoubleCell");
+  fieldDoubleScalarOnCells->setIterationNumber(-1);
+  fieldDoubleScalarOnCells->setOrderNumber(-1);
+  fieldDoubleScalarOnCells->setTime(0.0);
+
+  fieldDoubleScalarOnCells->setComponentName(1,"Vx");
+  fieldDoubleScalarOnCells->setComponentDescription(1,"comp1");
+  fieldDoubleScalarOnCells->setMEDComponentUnit(1,"unit1");
+
+  fieldDoubleScalarOnCells->setValueType(MED_REEL64);
+
+  FIELD<double> * fieldDoubleVectorOnCells = new FIELD<double>(supportOnCells,SpaceDimension);
+  fieldDoubleVectorOnCells->setName("fieldVectorrDoubleCell");
+  fieldDoubleVectorOnCells->setIterationNumber(-1);
+  fieldDoubleVectorOnCells->setOrderNumber(-1);
+  fieldDoubleVectorOnCells->setTime(0.0);
+
+  fieldDoubleVectorOnCells->setComponentName(1,"Vx");
+  fieldDoubleVectorOnCells->setComponentDescription(1,"comp1");
+  fieldDoubleVectorOnCells->setMEDComponentUnit(1,"unit1");
+  fieldDoubleVectorOnCells->setComponentName(2,"Vy");
+  fieldDoubleVectorOnCells->setComponentDescription(2,"comp2");
+  fieldDoubleVectorOnCells->setMEDComponentUnit(2,"unit2");
+  fieldDoubleVectorOnCells->setComponentName(3,"Vz");
+  fieldDoubleVectorOnCells->setComponentDescription(3,"comp3");
+  fieldDoubleVectorOnCells->setMEDComponentUnit(3,"unit3");
+
+  fieldDoubleVectorOnCells->setValueType(MED_REEL64);
+
+  FIELD<int> * fieldIntScalarOnNodes = new FIELD<int>(supportOnNodes,1);
+  fieldIntScalarOnNodes->setName("fieldScalarIntNode");
+  fieldIntScalarOnNodes->setIterationNumber(-1);
+  fieldIntScalarOnNodes->setOrderNumber(-1);
+  fieldIntScalarOnNodes->setTime(0.0);
+
+  fieldIntScalarOnNodes->setComponentName(1,"Vx");
+  fieldIntScalarOnNodes->setComponentDescription(1,"comp1");
+  fieldIntScalarOnNodes->setMEDComponentUnit(1,"unit1");
+
+  fieldIntScalarOnNodes->setValueType(MED_INT32);
+
+  FIELD<int> * fieldIntVectorOnNodes = new FIELD<int>(supportOnNodes,SpaceDimension);
+  fieldIntVectorOnNodes->setName("fieldVectorIntNode");
+  fieldIntVectorOnNodes->setIterationNumber(-1);
+  fieldIntVectorOnNodes->setOrderNumber(-1);
+  fieldIntVectorOnNodes->setTime(0.0);
+
+  fieldIntVectorOnNodes->setComponentName(1,"Vx");
+  fieldIntVectorOnNodes->setComponentDescription(1,"comp1");
+  fieldIntVectorOnNodes->setMEDComponentUnit(1,"unit1");
+  fieldIntVectorOnNodes->setComponentName(2,"Vy");
+  fieldIntVectorOnNodes->setComponentDescription(2,"comp2");
+  fieldIntVectorOnNodes->setMEDComponentUnit(2,"unit2");
+  fieldIntVectorOnNodes->setComponentName(3,"Vz");
+  fieldIntVectorOnNodes->setComponentDescription(3,"comp3");
+  fieldIntVectorOnNodes->setMEDComponentUnit(3,"unit3");
+
+  fieldIntVectorOnNodes->setValueType(MED_INT32);
+
+  FIELD<int> * fieldIntScalarOnCells = new FIELD<int>(supportOnCells,1);
+  fieldIntScalarOnCells->setName("fieldScalarIntCell");
+  fieldIntScalarOnCells->setIterationNumber(-1);
+  fieldIntScalarOnCells->setOrderNumber(-1);
+  fieldIntScalarOnCells->setTime(0.0);
+
+  fieldIntScalarOnCells->setComponentName(1,"Vx");
+  fieldIntScalarOnCells->setComponentDescription(1,"comp1");
+  fieldIntScalarOnCells->setMEDComponentUnit(1,"unit1");
+
+  fieldIntScalarOnCells->setValueType(MED_INT32);
+
+  FIELD<int> * fieldIntVectorOnCells = new FIELD<int>(supportOnCells,SpaceDimension);
+  fieldIntVectorOnCells->setName("fieldVectorrIntCell");
+  fieldIntVectorOnCells->setIterationNumber(-1);
+  fieldIntVectorOnCells->setOrderNumber(-1);
+  fieldIntVectorOnCells->setTime(0.0);
+
+  fieldIntVectorOnCells->setComponentName(1,"Vx");
+  fieldIntVectorOnCells->setComponentDescription(1,"comp1");
+  fieldIntVectorOnCells->setMEDComponentUnit(1,"unit1");
+  fieldIntVectorOnCells->setComponentName(2,"Vy");
+  fieldIntVectorOnCells->setComponentDescription(2,"comp2");
+  fieldIntVectorOnCells->setMEDComponentUnit(2,"unit2");
+  fieldIntVectorOnCells->setComponentName(3,"Vz");
+  fieldIntVectorOnCells->setComponentDescription(3,"comp3");
+  fieldIntVectorOnCells->setMEDComponentUnit(3,"unit3");
+
+  fieldIntVectorOnCells->setValueType(MED_INT32);
+
+  for (int i = 0; i<numberOfNodes; i++)
+    {
+      double valueDbl1, valueDbl2, valueDbl3;
+      int valueInt1, valueInt2, valueInt3;
+      valueInt1 = i+1;
+      valueInt2 = i+2;
+      valueInt3 = i+3;
+      valueDbl1 = valueInt1*0.1;
+      valueDbl2 = valueInt2*0.1;
+      valueDbl3 = valueInt3*0.1;
+      fieldDoubleScalarOnNodes->setValueIJ(i+1,1,valueDbl1);
+
+      fieldIntScalarOnNodes->setValueIJ(i+1,1,valueInt1);
+
+      fieldDoubleVectorOnNodes->setValueIJ(i+1,1,valueDbl1);
+      fieldDoubleVectorOnNodes->setValueIJ(i+1,2,valueDbl2);
+      fieldDoubleVectorOnNodes->setValueIJ(i+1,3,valueDbl3);
+
+      fieldIntVectorOnNodes->setValueIJ(i+1,1,valueInt1);
+      fieldIntVectorOnNodes->setValueIJ(i+1,2,valueInt2);
+      fieldIntVectorOnNodes->setValueIJ(i+1,3,valueInt3);
+    }
+
+  for (int i = 0; i<numberOfCells; i++)
+    {
+      double valueDbl1, valueDbl2, valueDbl3;
+      int valueInt1, valueInt2, valueInt3;
+      valueInt1 = i+1;
+      valueInt2 = i+2;
+      valueInt3 = i+3;
+      valueDbl1 = valueInt1*0.1;
+      valueDbl2 = valueInt2*0.1;
+      valueDbl3 = valueInt3*0.1;
+      fieldDoubleScalarOnCells->setValueIJ(i+1,1,valueDbl1);
+
+      fieldIntScalarOnCells->setValueIJ(i+1,1,valueInt1);
+
+      fieldDoubleVectorOnCells->setValueIJ(i+1,1,valueDbl1);
+      fieldDoubleVectorOnCells->setValueIJ(i+1,2,valueDbl2);
+      fieldDoubleVectorOnCells->setValueIJ(i+1,3,valueDbl3);
+
+      fieldIntVectorOnCells->setValueIJ(i+1,1,valueInt1);
+      fieldIntVectorOnCells->setValueIJ(i+1,2,valueInt2);
+      fieldIntVectorOnCells->setValueIJ(i+1,3,valueInt3);
+    }
+
+  idMed = fieldDoubleScalarOnNodes->addDriver(MED_DRIVER,filenameMed,fieldDoubleScalarOnNodes->getName());
+  fieldDoubleScalarOnNodes->write(idMed) ;
+
+  idMed = fieldIntScalarOnNodes->addDriver(MED_DRIVER,filenameMed,fieldIntScalarOnNodes->getName());
+  fieldIntScalarOnNodes->write(idMed) ;
+
+  idMed = fieldDoubleVectorOnNodes->addDriver(MED_DRIVER,filenameMed,fieldDoubleVectorOnNodes->getName());
+  fieldDoubleVectorOnNodes->write(idMed) ;
+
+  idMed = fieldIntVectorOnNodes->addDriver(MED_DRIVER,filenameMed,fieldIntVectorOnNodes->getName());
+  fieldIntVectorOnNodes->write(idMed) ;
+
+  idMed = fieldDoubleScalarOnCells->addDriver(MED_DRIVER,filenameMed,fieldDoubleScalarOnCells->getName());
+  fieldDoubleScalarOnCells->write(idMed) ;
+
+  idMed = fieldIntScalarOnCells->addDriver(MED_DRIVER,filenameMed,fieldIntScalarOnCells->getName());
+  fieldIntScalarOnCells->write(idMed) ;
+
+  idMed = fieldDoubleVectorOnCells->addDriver(MED_DRIVER,filenameMed,fieldDoubleVectorOnCells->getName());
+  fieldDoubleVectorOnCells->write(idMed) ;
+
+  idMed = fieldIntVectorOnCells->addDriver(MED_DRIVER,filenameMed,fieldIntVectorOnCells->getName());
+  fieldIntVectorOnCells->write(idMed) ;
+
+  idVtk = fieldDoubleScalarOnNodes->addDriver(VTK_DRIVER,filenameVtk,fieldDoubleScalarOnNodes->getName());
+  fieldDoubleScalarOnNodes->writeAppend(idVtk) ;
+
+  idVtk = fieldIntScalarOnNodes->addDriver(VTK_DRIVER,filenameVtk,fieldIntScalarOnNodes->getName());
+  fieldIntScalarOnNodes->writeAppend(idVtk) ;
+
+  idVtk = fieldDoubleVectorOnNodes->addDriver(VTK_DRIVER,filenameVtk,fieldDoubleVectorOnNodes->getName());
+  fieldDoubleVectorOnNodes->writeAppend(idVtk) ;
+
+  idVtk = fieldIntVectorOnNodes->addDriver(VTK_DRIVER,filenameVtk,fieldIntVectorOnNodes->getName());
+  fieldIntVectorOnNodes->writeAppend(idVtk) ;
+
+  idVtk = fieldDoubleScalarOnCells->addDriver(VTK_DRIVER,filenameVtk,fieldDoubleScalarOnCells->getName());
+  fieldDoubleScalarOnCells->writeAppend(idVtk) ;
+
+  idVtk = fieldIntScalarOnCells->addDriver(VTK_DRIVER,filenameVtk,fieldIntScalarOnCells->getName());
+  fieldIntScalarOnCells->writeAppend(idVtk) ;
+
+  idVtk = fieldDoubleVectorOnCells->addDriver(VTK_DRIVER,filenameVtk,fieldDoubleVectorOnCells->getName());
+  fieldDoubleVectorOnCells->writeAppend(idVtk) ;
+
+  idVtk = fieldIntVectorOnCells->addDriver(VTK_DRIVER,filenameVtk,fieldIntVectorOnCells->getName());
+  fieldIntVectorOnCells->writeAppend(idVtk) ;
+
+  delete fieldDoubleScalarOnNodes;
+  delete fieldIntScalarOnNodes;
+  delete fieldDoubleVectorOnNodes;
+  delete fieldIntVectorOnNodes;
+  delete fieldDoubleScalarOnCells;
+  delete fieldIntScalarOnCells;
+  delete fieldDoubleVectorOnCells;
+  delete fieldIntVectorOnCells;
 
+  delete supportOnNodes;
+  delete supportOnCells;
 }
index bdb7fa51af13e9cd8c46c4f7436578b7ac8a88f8..97f6bf30284836f7d832ec41eea3e933115d9f10 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : test_MEDMEM_ModulusArray.cxx
-//  Module : MED
-
 using namespace std;
 #include "utilities.h"
 
index ba1fef4bd2b86907aa34a496c7079ea1a636bde3..6d7dc268e5ee7d9f8b325e2efe1749f1c7953bd8 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : test_MEDMEM_SkyLineArray.cxx
-//  Module : MED
-
 using namespace std;
 #include "utilities.h"
 #include "MEDMEM_SkyLineArray.hxx"
index cc9a7948562c7e1cddbfb6578cbce74bc86831c0..eb72d86d3a27d285c96efc47a3956ad8702f99a5 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : test_affect_medarray.cxx
-//  Module : MED
-
 using namespace std;
 /* Programme de test du constructeur de copies de la classe MEDARRAY de MEDMEM
    jroy - 16/12/2002 */
index b3442471a819022a039b7deb7995d97f9692bc95..962de06409f620ed38e95b1b601868548843687f 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : test_copie_connectivity.cxx
-//  Module : MED
-
 using namespace std;
 /* Programme de test du constructeur de copies de la classe CONNECTIVITY de MEDMEM
    jroy - 19/12/2002 */
index 385b8ab0ebb7817208e81b9ff817dd3207a55997..4a40c89df601468b8259c6ea12c3330f4193f494 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : test_copie_coordinate.cxx
-//  Module : MED
-
 using namespace std;
 /* Programme de test du constructeur de copies de la classe COORDINATE de MEDMEM
    jroy - 17/12/2002 */
index 29fbcab8a3f469bad540007a850b5ba6e4748933..34633dc271a37e34767726704ec3afd4b064c8d5 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : test_copie_family.cxx
-//  Module : MED
-
 using namespace std;
 #include<string>
 
index 7d6109bd4ceb15f4f6275cb2766c38c05fb02c4c..fc9ad2142a4bbbb3aa62f3633ca573e43add21dc 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : test_copie_fieldT.cxx
-//  Module : MED
-
 using namespace std;
 /* Programme de test du constructeur de copies de la classe FIELD_ de MEDMEM
    jroy - 12/12/2002 */
@@ -84,7 +58,7 @@ void affiche_fieldT(FIELD<double> * myField, const SUPPORT * mySupport)
 
 int main (int argc, char ** argv) {
 
-  int read;
+  // int read; !! UNUSED VARIABLE !!
 
   if ((argc !=3) && (argc != 4)) {
     cerr << "Usage : " << argv[0] 
index 08f8c9e9344d50d572d7999de8e8fc055e85f1cb..0598a26b1c3e51d78a0567c20f91c73e292161c8 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : test_copie_field_.cxx
-//  Module : MED
-
 /* Programme de test du constructeur de copies de la classe FIELD_ de MEDMEM
    jroy - 12/12/2002 */
 
@@ -78,7 +52,7 @@ void affiche_field(FIELD_ * myField, const SUPPORT * mySupport)
 
 int main (int argc, char ** argv) {
 
-  int read;
+  // int read; !! UNUSED VARIABLE !!
 
   if ((argc !=3) && (argc != 4)) {
     cerr << "Usage : " << argv[0] 
index 7bf53c8e245f79e84ea9c43647ec0cbe55e90652..96e464f7dcbd3964f255a9012710400b65986675 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : test_copie_group.cxx
-//  Module : MED
-
 using namespace std;
 #include<string>
 
index afe04ccb08afc414916b595e18eed29dcb151a0a..3cd8745bc1fb650d3ce458e3546a1817082d1539 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : test_copie_medarray.cxx
-//  Module : MED
-
 using namespace std;
 /* Programme de test du constructeur de copies de la classe MEDARRAY de MEDMEM
    jroy - 16/12/2002 */
index 53f794410de4bb91806ee90e8e7debf75c75b49b..c8e83c56e96955983acfbad10bd50aeb55101f65 100644 (file)
@@ -1,12 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  CEA/DEN, EDF R&D
-//
-//
-//
-//  File   : test_copie_mesh.cxx
-//  Module : MED
-
 using namespace std;
 #include<string>
 
index bc228814a7b0b4a8714eb46f5dc4bff239bd216e..5abfe4f5ebe6f65788177f8ea3838f8826067ece 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM : MED files in memory
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : test_copie_support.cxx
-//  Module : MED
-
 using namespace std;
 #include<string>
 
diff --git a/src/MEDMEM/test_gibi_driver.cxx b/src/MEDMEM/test_gibi_driver.cxx
new file mode 100644 (file)
index 0000000..cfa50ec
--- /dev/null
@@ -0,0 +1,38 @@
+#include "MEDMEM_GibiMeshDriver.hxx"
+#include "MEDMEM_Mesh.hxx"
+
+int main (int argc, char ** argv)
+{
+    /* process the arguments */
+    if (argc != 2) 
+    {
+       cerr << "Usage : " << argv[0] 
+       << "Gibifilename" << endl << endl
+       << "-> lit le fichier gibi filename ,crée un fichier MED" << endl;
+       exit(-1);
+    }
+    string gibifilename  = argv[1];
+
+    // Construction des noms de fichier
+    const string ext=".sauve";
+    string::size_type pos=gibifilename.find(ext,0);
+    string basename (gibifilename, 0, pos);
+    string medfile=basename+".med";
+    string cast2medfile="cast_"+basename+".med";
+
+    // lecture du fichier gibi
+    MESH * myMesh= new MESH() ; 
+    GIBI_MESH_RDONLY_DRIVER myGibiMeshDriver(gibifilename, myMesh) ;
+    myGibiMeshDriver.open() ;
+    myGibiMeshDriver.read() ;
+    myGibiMeshDriver.close() ;
+
+    cout << "Impression de MESH : " << endl;
+    cout << *myMesh;
+
+    // creation d'un fichier med
+    int idMed = myMesh->addDriver(MED_DRIVER, medfile, basename);
+    myMesh->write(idMed) ;
+    delete myMesh;
+
+}
diff --git a/src/MEDMEM/test_operation_fielddouble.cxx b/src/MEDMEM/test_operation_fielddouble.cxx
new file mode 100644 (file)
index 0000000..4338f6e
--- /dev/null
@@ -0,0 +1,403 @@
+// Programme de test des operations sur les champs
+
+#include <string>
+#include <iostream>
+#include <iomanip>
+#include <cmath>
+
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Group.hxx"
+
+#include "MEDMEM_MedMeshDriver.hxx"
+#include "MEDMEM_MedFieldDriver.hxx"
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_define.hxx"
+
+double myfunction1(double x)
+{
+    return 0.25*(x-1.0);
+}
+
+
+using namespace std;
+void affiche_field_(FIELD_ * myField, const SUPPORT * mySupport)
+{
+  cout << "Field "<< myField->getName() << " : " <<myField->getDescription() <<  endl ;
+  int NumberOfComponents = myField->getNumberOfComponents() ;
+  cout << "- Nombre de composantes : "<< NumberOfComponents << endl ;
+  cout << "- Nombre de valeurs     : "<< myField->getNumberOfValues() << endl ;
+  for (int i=1; i<NumberOfComponents+1; i++) {
+    cout << "  - composante "<<i<<" :"<<endl ;
+    cout << "      - nom         : "<<myField->getComponentName(i)<< endl;
+    cout << "      - description : "<<myField->getComponentDescription(i) << endl;
+    cout << "      - units       : "<<myField->getMEDComponentUnit(i) << endl;
+  }
+  cout << "- iteration :" << endl ;
+  cout << "    - numero : " << myField->getIterationNumber()<< endl  ;
+  cout << "    - ordre  : " << myField->getOrderNumber()<< endl  ;
+  cout << "    - temps  : " << myField->getTime()<< endl  ;
+
+  cout << "- Type : " << myField->getValueType()<< endl;
+
+  cout << "- Adresse support : " << mySupport << endl;
+}
+
+void affiche_fieldT(FIELD<double> * myField, const SUPPORT * mySupport)
+{
+  affiche_field_((FIELD_ *) myField, mySupport);
+
+  cout << "- Valeurs :"<<endl;
+  int NumberOf = mySupport->getNumberOfElements(MED_ALL_ELEMENTS);
+  int NumberOfComponents = myField->getNumberOfComponents() ;
+
+  for (int i=1; i<NumberOf+1; i++) {
+    const double * value = myField->getValueI(MED_FULL_INTERLACE,i) ;
+    for (int j=0; j<NumberOfComponents; j++)
+      cout << value[j]<< " ";
+    cout<<endl;
+  }
+  cout << endl;
+  cout << "Norme euclidienne : " << myField->norm2() << endl;
+  cout << "Norme max         : " << myField->normMax() << endl;
+  try
+  {
+      for (int i=1; i<=myField->getNumberOfComponents(); ++i)
+           cout << "Norme L2 - comp=" << i << " : " << myField->normL2(i) << endl;
+      cout << "Norme L2          : " << myField->normL2() << endl;
+
+      for (int i=1; i<=myField->getNumberOfComponents(); ++i)
+           cout << "Norme L1 - comp=" << i << " : " << myField->normL1(i) << endl;
+      cout << "Norme L1          : " << myField->normL1() << endl;
+  }
+  catch (MEDEXCEPTION &ex)
+  {
+      cout << ex.what() << endl;
+  }
+}
+
+void affiche_valeur_field(const FIELD<double>& f)
+{
+    const int tailleMax=12;
+    const int taille=f.getNumberOfValues()*f.getNumberOfComponents();
+    const double * value=f.getValue(f.getvalue()->getMode());
+    if(taille<=tailleMax)
+       for(int i=0;i<taille;i++)
+           cout << setw(3) << value[i] << " ";
+    else
+    {
+       for(int i=0; i<tailleMax/2; ++i)
+           cout << setw(3) << value[i] << " ";
+       cout << "    ...    ";
+       for(int i=taille-tailleMax/2 ; i<taille; ++i)
+           cout << setw(3) << value[i] << " ";
+    }
+}
+
+void checkOperation(const FIELD<double>& resOp, const FIELD<double>& f1, const FIELD<double>& f2, 
+       char Op, const char* intitule, int verbose)
+{
+    int res=0;
+
+    // get pointers to inside arrays of values
+    medModeSwitch mode=resOp.getvalue()->getMode();
+    const double * value=resOp.getValue(mode);
+    const double * value1=f1.getValue(mode);
+    const double * value2=f2.getValue(mode);
+    const int size=f1.getNumberOfValues()*f1.getNumberOfComponents(); // size of field1
+    // check size compatibility
+    if(f1.getNumberOfValues()*f1.getNumberOfComponents()!=size ||
+           resOp.getNumberOfValues()*resOp.getNumberOfComponents()!=size)
+       res=1;
+
+    if(!res)
+    {
+       switch(Op)
+       {
+           case '+':
+               for(int i=0; i!=size; ++i)
+                   if(value[i]!=value1[i]+value2[i])   
+                       res+=1;
+               break;
+           case '-':
+               for(int i=0; i!=size; ++i)
+                   if(value[i]!=value1[i]-value2[i])   
+                       res+=1;
+               break;
+           case 'n':
+               for(int i=0; i!=size; ++i)
+                   if(value[i]!=-value1[i])
+                       res+=1;
+               break;
+           case '*':
+               for(int i=0; i!=size; ++i)
+                   if(value[i]!=value1[i]*value2[i])   
+                       res+=1;
+               break;
+           case '/':
+               for(int i=0; i!=size; ++i)
+                   if(value2[i]!=0.0)
+                       if(value[i]!=value1[i]/value2[i])       
+                           res+=1;
+               break;
+           case '=':
+               for(int i=0; i!=size; ++i)
+                   if(value[i]!=value2[i])
+                       res+=1;
+               break;
+           case 'a':
+               for(int i=0; i!=size; ++i)
+                   if(value[i]!=value1[i]+value2[i]*value2[i]) 
+                       res+=1;
+               break;
+       }
+           
+    }
+
+    if (verbose)
+       cout << endl << intitule << "[";
+    cout << res;
+    if (verbose)
+    {
+       cout << "] : ";
+       affiche_valeur_field(resOp);
+    }
+    else 
+       cout << endl;
+}
+
+int main (int argc, char ** argv)
+{
+    /* process the arguments */
+    int verbose=0;  //  verbose=1 if the verbose mode is selected
+    int res=0; // unit test result
+    int ntest=0;  // numéro du test
+
+    if (argc>=2 && !strcmp(argv[1],"-v"))
+       verbose=1;
+
+    if (argc != 4+verbose) 
+    {
+       cerr << "Usage : " << argv[0] 
+       << "[-v] filename meshname fieldname" << endl << endl
+       << "-> tests field's operations on the FIELD<double> fieldname" << endl
+       << "Use optional option -v to select verbose mode" << endl;
+       exit(-1);
+    }
+    string filename  = argv[verbose+1];
+    string meshname  = argv[verbose+2];
+    string fieldname = argv[verbose+3];
+
+    /* read MESH, SUPPORT and FIELDS */
+    MESH * myMesh = new MESH(MED_DRIVER,filename,meshname);
+    SUPPORT * mySupport;
+    FIELD<double> * myField1;
+    try
+    {
+       mySupport = new SUPPORT(myMesh,"Support on all Cells",MED_CELL);
+       myField1 = new FIELD<double>(mySupport,MED_DRIVER,filename,fieldname) ;
+       myField1->setValueType(MED_REEL64);
+    }
+    catch (MEDEXCEPTION &ex)
+    {
+       // field wasn't found on cells, try on nodes
+       delete mySupport ;
+       mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE);
+       try 
+       {
+           myField1 = new FIELD<double>(mySupport,MED_DRIVER,filename,fieldname) ;
+       }
+       catch (...) 
+       {
+           cout << "Field double " << fieldname << " not found !!!" << endl ;
+           exit (-1) ;
+       }
+    }
+    FIELD<double> * myField2 = new FIELD<double>(* myField1);
+    FIELD<double> myFieldPlus = *myField1 + *myField2;
+    if(verbose)
+    {
+       // affichage des nprmes,des champs f1, f2, scalarProduct(f1,f2) et f1+f2
+       FIELD<double>* myField1_vol=myField1->getSupport()->getMesh()->getVolume(myField1->getSupport());
+       cout << "Norme L2 calculée en fournissant le volume : " << myField1->normL2(myField1_vol) << endl;
+        for (int i=1; i<=myField1->getNumberOfComponents(); ++i)
+           cout << "Norme L2 - comp=" << i << " : " << myField1->normL2(i,myField1_vol) << endl;
+       cout << "Norme L1 calculée en fournissant le volume : " << myField1->normL1(myField1_vol) << endl;
+        for (int i=1; i<=myField1->getNumberOfComponents(); ++i)
+           cout << "Norme L1 - comp=" << i << " : " << myField1->normL1(i,myField1_vol) << endl;
+       delete myField1_vol;
+
+       affiche_fieldT(myField1, myField1->getSupport());
+       cout <<  endl << string(60,'-') << endl;
+       affiche_fieldT(myField2, myField2->getSupport());
+       cout << endl << string(60,'-') << endl;
+       
+       FIELD<double>* myFieldDot = FIELD<double>::scalarProduct(*myField1, *myField2);
+       affiche_fieldT(myFieldDot, myFieldDot->getSupport());
+       delete myFieldDot;
+       cout <<  endl << string(60,'-') << endl ;
+       affiche_fieldT(&myFieldPlus, myFieldPlus.getSupport());
+       cout <<  endl << string(60,'-') << endl << endl ;
+    }
+
+
+    // Verifie plusieurs cas de non compatibilité 
+
+    // test 1 : Unites non compatibles
+    const string unite=myField1->getMEDComponentUnit(1);
+    myField1->setMEDComponentUnit(1,string("UniteBidon"));
+    ntest++; res=1;
+    try
+    {
+       FIELD<double> myFieldPlus = *myField1 + *myField2;
+       if(verbose) 
+       {
+           cout << endl << string(60,'-') << endl;
+           cout<< "Test " << ntest << " : incompatibilité d'unité : " << endl << endl;
+       }
+    }
+    catch (MEDEXCEPTION & ex)
+    {
+       res=0;
+       if(verbose) 
+           cout << ex.what() << endl;
+       myField1->setMEDComponentUnit(1,unite);
+    }
+    cout << res << endl;
+
+    // test 2 : numberOfComponents non compatibles
+    const int numberOfComponents =myField1->getNumberOfComponents();
+    myField1->setNumberOfComponents(13);
+    ntest++; res=1;
+    try
+    {
+       if(verbose) 
+       {
+           cout << endl << string(60,'-') << endl;
+           cout<< "Test " << ntest << " : incompatibilité nombre de composantes : " << endl << endl;
+       }
+       FIELD<double> myFieldPlus = *myField1 + *myField2;
+    }
+    catch (MEDEXCEPTION & ex)
+    {
+       res=0;
+       if(verbose)
+           cout << endl << ex.what() << endl << endl;
+       myField1->setNumberOfComponents(numberOfComponents);
+    }
+    cout << res << endl;
+
+    // test 3 : supports non compatibles
+    const SUPPORT mySupport2(myMesh,"On_all_node",MED_NODE);
+    myField1->setSupport(&mySupport2);
+    ntest++; res=1;
+    try
+    {
+       if(verbose)
+           cout << endl << string(60,'-') << endl << "Test " << ntest << " : incompatibilité des supports"  << endl << endl;
+       FIELD<double> myFieldPlus = *myField1 + *myField2;
+    }
+    catch (MEDEXCEPTION & ex)
+    {
+       res=0;
+       if(verbose)
+           cout << ex.what() << endl << endl << endl;
+       myField1->setSupport(mySupport);
+    }
+    cout << res << endl;
+
+    // test 4 : champs de taille nulle
+    myField1->setNumberOfComponents(0);
+    myField2->setNumberOfComponents(0);
+    ntest++; res=2;
+    try
+    {
+       if(verbose)
+           cout<< endl << string(60,'-') << endl << "Test " << ntest << " : incompatibilité taille nulle" << endl << endl;
+       FIELD<double> myFieldPlus = *myField1 + *myField2;
+    }
+    catch (MEDEXCEPTION & ex)
+    {
+       --res;
+       if(verbose) 
+           cout << ex.what() << endl << endl ;
+    }
+    try
+    {
+       double mynorm2=myField1->norm2();
+    }
+    catch (MEDEXCEPTION & ex)
+    {
+       --res;
+       if(verbose) 
+           cout << ex.what() << endl << endl ;
+       myField1->setNumberOfComponents(numberOfComponents);
+       myField2->setNumberOfComponents(numberOfComponents);
+    }
+    cout << res << endl;
+
+    // Apres toutes ces exceptions, des opérations qui marchent!
+
+    if(verbose)
+    {
+       cout<< endl << string(60,'-') << endl << "Test " << ++ntest << " : Operations arithmétiques" << endl;
+       cout << endl << " f1           : "; affiche_valeur_field(*myField1);
+       cout << endl << " f2           : "; affiche_valeur_field(*myField2);
+       cout  << endl << string(140,'-');
+    }
+
+    // Test du résultats de certaines opérations et affichage si verbose
+    checkOperation(myFieldPlus, *myField1, *myField2, '+', " f1+f2    ", verbose);
+    FIELD<double>* myFieldadd = FIELD<double>::add(*myField1, *myField2);
+    checkOperation( *myFieldadd, *myField1, *myField2, '+', "add(f1,f2)", verbose);
+    delete myFieldadd;
+
+    FIELD<double> myFieldMoins = *myField1 - *myField2;
+    checkOperation(myFieldMoins, *myField1, *myField2, '-', " f1-f2    ", verbose);
+    FIELD<double>* myFieldsub = FIELD<double>::sub(*myField1, *myField2);
+    checkOperation( *myFieldsub, *myField1, *myField2, '-', "sub(f1,f2)", verbose);
+    delete myFieldsub;
+    FIELD<double> myFieldNeg = -(*myField1);
+    checkOperation(myFieldNeg, *myField1, *myField1, 'n', " -f1      ", verbose);
+    
+    FIELD<double> myFieldFois = *myField1 * *myField2;
+    checkOperation(myFieldFois, *myField1, *myField2, '*', " f1*f2    ", verbose);
+    FIELD<double>* myFieldmul = FIELD<double>::mul(*myField1, *myField2);
+    checkOperation( *myFieldmul, *myField1, *myField2, '*', "mul(f1,f2)", verbose);
+    
+    FIELD<double> myFieldDiv = *myField1 / *myField2;
+    checkOperation(myFieldDiv, *myField1, *myField2, '/', " f1/f2    ", verbose);
+    FIELD<double>* myFielddiv = FIELD<double>::div(*myField1, *myField2);
+    checkOperation( *myFielddiv, *myField1, *myField2, '/', "div(f1,f2)", verbose);
+    delete myFielddiv;
+
+    FIELD<double> myFieldAsso = (*myField1)+(*myField2)*(*myField2);
+    checkOperation(myFieldAsso, *myField1, *myField2, 'a', " f1+f2*f2 ", verbose);
+
+    myField1->applyLin(4.0,1.0);
+    checkOperation(*myField1, *myField2, *myField2, 'l', " 4.f1 + 1 ", verbose);
+    myField1->applyFunc<myfunction1>();
+    checkOperation( *myField1, *myField2, *myField1, '=', "CB : ->f1)", verbose);
+
+    *myField1 += *myField2;
+    checkOperation(*myField1, *myField2, *myField2, '+', " f1+=f2   ", verbose);
+
+    *myField1 -= *myField2;
+    checkOperation(*myField1, *myField2, *myField2, '=', " f1-=f2   ", verbose);
+
+    *myField1 *= *myField2;
+    checkOperation(*myField1, *myField2, *myField2, '*', " f1*=f2   ", verbose);
+    *myField1 /= *myField2;
+    checkOperation(*myField1, *myFieldmul, *myField2, '/', " f1/=f2   ", verbose);
+    delete myFieldmul;
+
+
+    delete myField1;
+    delete myField2;
+    delete mySupport ;
+    delete myMesh ;
+    return 0;
+}
diff --git a/src/MEDMEM/test_operation_fieldint.cxx b/src/MEDMEM/test_operation_fieldint.cxx
new file mode 100644 (file)
index 0000000..48e33ea
--- /dev/null
@@ -0,0 +1,301 @@
+// Programme de test des operations sur les champs
+
+#include <string>
+#include <iostream>
+#include <iomanip>
+#include <cmath>
+
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Group.hxx"
+
+#include "MEDMEM_MedMeshDriver.hxx"
+#include "MEDMEM_MedFieldDriver.hxx"
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_define.hxx"
+
+int myfunction1(int x)
+{
+    return 2*x;
+}
+
+int myfunction2(int x)
+{
+    return x/2;
+}
+
+using namespace std;
+void affiche_field_(FIELD_ * myField, const SUPPORT * mySupport)
+{
+  cout << "Field "<< myField->getName() << " : " <<myField->getDescription() <<  endl ;
+  int NumberOfComponents = myField->getNumberOfComponents() ;
+  cout << "- Nombre de composantes : "<< NumberOfComponents << endl ;
+  cout << "- Nombre de valeurs     : "<< myField->getNumberOfValues() << endl ;
+  for (int i=1; i<NumberOfComponents+1; i++) {
+    cout << "  - composante "<<i<<" :"<<endl ;
+    cout << "      - nom         : "<<myField->getComponentName(i)<< endl;
+    cout << "      - description : "<<myField->getComponentDescription(i) << endl;
+    cout << "      - units       : "<<myField->getMEDComponentUnit(i) << endl;
+  }
+  cout << "- iteration :" << endl ;
+  cout << "    - numero : " << myField->getIterationNumber()<< endl  ;
+  cout << "    - ordre  : " << myField->getOrderNumber()<< endl  ;
+  cout << "    - temps  : " << myField->getTime()<< endl  ;
+
+  cout << "- Type : " << myField->getValueType()<< endl;
+
+  cout << "- Adresse support : " << mySupport << endl;
+}
+
+void affiche_fieldT(FIELD<int> * myField, const SUPPORT * mySupport)
+{
+  affiche_field_((FIELD_ *) myField, mySupport);
+
+  cout << "- Valeurs :"<<endl;
+  int NumberOf = mySupport->getNumberOfElements(MED_ALL_ELEMENTS);
+  int NumberOfComponents = myField->getNumberOfComponents() ;
+
+  for (int i=1; i<NumberOf+1; i++) {
+    const int * value = myField->getValueI(MED_FULL_INTERLACE,i) ;
+    for (int j=0; j<NumberOfComponents; j++)
+      cout << value[j]<< " ";
+    cout<<endl;
+  }
+  std::cout << std::endl;
+  std::cout << "Norme euclidienne : " << myField->norm2() << endl;
+  std::cout << "Norme max         : " << myField->normMax() << endl;
+  try
+  {
+      for (int i=1; i<=myField->getNumberOfComponents(); ++i)
+           std::cout << "Norme L2 - comp=" << i << " : " << myField->normL2(i) << endl;
+      std::cout << "Norme L2          : " << myField->normL2() << endl;
+
+      for (int i=1; i<=myField->getNumberOfComponents(); ++i)
+           std::cout << "Norme L1 - comp=" << i << " : " << myField->normL1(i) << endl;
+      std::cout << "Norme L1          : " << myField->normL1() << endl;
+  }
+  catch (MEDEXCEPTION &ex)
+  {
+      std::cout << ex.what() << std::endl;
+  }
+}
+
+void affiche_valeur_field(const char * intitule, const int taille, const FIELD<int>& f)
+{
+    const int * value=f.getValue(f.getvalue()->getMode());
+    std::cout << endl << intitule;
+    for(int i=0;i<taille;i++)
+       std::cout << setw(3) << value[i] << " ";
+}
+
+int main (int argc, char ** argv)
+{
+    if (argc != 4) 
+    {
+       cerr << "Usage : " << argv[0] 
+       << " filename meshname fieldname" << endl << endl;
+       exit(-1);
+    }
+    string filename = argv[1] ;
+    string meshname = argv[2] ;
+    string fieldname = argv[3];
+
+    MESH * myMesh = new MESH(MED_DRIVER,filename,meshname);
+    SUPPORT * mySupport;
+    FIELD<int> * myField1;
+    try
+    {
+       /* read MESH, SUPPORT and FIELD */
+       mySupport = new SUPPORT(myMesh,"Support on all Cells",MED_CELL);
+       myField1 = new FIELD<int>(mySupport,MED_DRIVER,filename,fieldname) ;
+       myField1->setValueType(MED_REEL64);
+    }
+    catch (MEDEXCEPTION &ex)
+    {
+       delete mySupport ;
+       mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE);
+       try 
+       {
+           myField1 = new FIELD<int>(mySupport,MED_DRIVER,filename,fieldname) ;
+           myField1->setValueType(MED_INT32);
+           myField1->setValueIJ(10,1,-9); // pour tester les normes max avec une valeur negative
+       }
+       catch (...) 
+       {
+           cout << "Field int " << fieldname << " not found !!!" << endl ;
+           exit (-1) ;
+       }
+    }
+
+    FIELD<int> * myField2 = new FIELD<int>(* myField1);
+    //myField1->setNumberOfValues(16); // PROVISOIRE !! BUG
+    //myField2->setNumberOfValues(16); // PROVISOIRE !! BUG
+//     FIELD<int>* myField1_vol=myField1->getSupport()->getMesh()->getVolume(myField1->getSupport());
+//     affiche_fieldT(myField1_vol, myField1->getSupport());
+
+    affiche_fieldT(myField1, myField1->getSupport());
+    std::cout <<  endl << string(60,'-') << endl;
+    affiche_fieldT(myField2, myField2->getSupport());
+
+    // Verifie plusieurs cas de non compatibilité 
+
+    // Unites non compatibles
+    const string unite=myField1->getMEDComponentUnit(1);
+    myField1->setMEDComponentUnit(1,string("UniteBidon"));
+    try
+    {
+       std::cout << endl << string(60,'-') << endl;
+       std::cout<< "Test incompatibilité d'unité :" << endl;
+       FIELD<int> myFieldPlus = *myField1 + *myField2;
+    }
+    catch (MEDEXCEPTION & ex)
+    {
+       std::cout << "MEDEXCEPTION : " << ex.what() << endl;
+       myField1->setMEDComponentUnit(1,unite);
+    }
+
+    // numberOfComponents non compatibles
+    const int numberOfComponents =myField1->getNumberOfComponents();
+    myField1->setNumberOfComponents(4);
+    try
+    {
+       std::cout << endl << string(60,'-') << endl;
+       std::cout<< "Test incompatibilité nombre de composantes :" << endl;
+       FIELD<int> myFieldPlus = *myField1 + *myField2;
+    }
+    catch (MEDEXCEPTION & ex)
+    {
+       std::cout << ex.what() << endl;
+       myField1->setNumberOfComponents(numberOfComponents);
+    }
+
+    // supports non compatibles
+    const SUPPORT mySupport2(myMesh,"On_all_node",MED_NODE);
+    myField1->setSupport(&mySupport2);
+    try
+    {
+       std::cout << endl << string(60,'-') << endl;
+       std::cout<< "Test incompatibilité des supports :" << endl;
+       FIELD<int> myFieldPlus = *myField1 + *myField2;
+    }
+    catch (MEDEXCEPTION & ex)
+    {
+       std::cout << ex.what() << endl;
+       myField1->setSupport(mySupport);
+    }
+
+    // champs de taille nulle
+    myField1->setNumberOfComponents(0);
+    myField2->setNumberOfComponents(0);
+    try
+    {
+       std::cout << endl << string(60,'-') << endl;
+       std::cout<< "Test incompatibilité taille nulle :" << endl;
+       FIELD<int> myFieldPlus = *myField1 + *myField2;
+    }
+    catch (MEDEXCEPTION & ex)
+    {
+       std::cout << ex.what() << endl;
+    }
+    try
+    {
+       double mynorm2=myField1->norm2();
+    }
+    catch (MEDEXCEPTION & ex)
+    {
+       std::cout << ex.what() << endl;
+       myField1->setNumberOfComponents(numberOfComponents);
+       myField2->setNumberOfComponents(numberOfComponents);
+    }
+
+    // Apres toutes ces exceptions, des opérations qui marchent!
+
+    FIELD<int> myFieldPlus = *myField1 + *myField2;
+    FIELD<int> myFieldMoins = *myField1 - *myField2;
+    FIELD<int> myFieldNeg = -(*myField1);
+    FIELD<int> myFieldFois = *myField1 * *myField2;
+    FIELD<int> myFieldDiv = *myField1 / *myField2;
+    FIELD<int> myFieldAsso = (*myField1)+(*myField2)*(*myField2);
+    FIELD<int>* myFieldadd = FIELD<int>::add(*myField1, *myField2);
+    FIELD<int>* myFieldsub = FIELD<int>::sub(*myField1, *myField2);
+    FIELD<int>* myFieldmul = FIELD<int>::mul(*myField1, *myField2);
+    FIELD<int>* myFielddiv = FIELD<int>::div(*myField1, *myField2);
+    FIELD<int>* myFieldDot = FIELD<int>::scalarProduct(*myField1, *myField2);
+
+    std::cout <<  endl << string(60,'-') << endl << "f1+f2 :" << endl << endl;
+    affiche_fieldT(&myFieldPlus, myFieldPlus.getSupport());
+    std::cout <<  endl << string(60,'-') << endl << "add(f1,f2) :" << endl << endl;
+    affiche_fieldT(myFieldadd, myFieldadd->getSupport());
+    std::cout <<  endl << string(60,'-') << endl << "scalarProduct(f1,f2) :" << endl << endl;
+    affiche_fieldT(myFieldDot, myFieldDot->getSupport());
+    std::cout <<  endl << string(60,'-') << endl << " - f1 :" << endl << endl;
+    affiche_fieldT(&myFieldNeg, myFieldNeg.getSupport());
+
+    medModeSwitch mode=myFieldPlus.getvalue()->getMode();
+    int size=myFieldPlus.getNumberOfValues()*myFieldPlus.getNumberOfComponents();
+  
+    std::cout <<  endl << string(60,'-') << endl << "Tests opérations :" << endl << endl;
+    affiche_valeur_field("  f1    :", size, *myField1);
+    affiche_valeur_field("  f2    :", size, *myField2);
+    std::cout << endl << "        " << string(4*size,'-');
+
+    affiche_valeur_field("  +     :", size, myFieldPlus);
+    affiche_valeur_field(" add    :", size, *myFieldadd);
+    affiche_valeur_field("  -     :", size, myFieldMoins);
+    affiche_valeur_field(" sub    :", size, *myFieldsub);
+    affiche_valeur_field("  *     :", size, myFieldFois);
+    affiche_valeur_field(" mul    :", size, *myFieldmul);
+    affiche_valeur_field("  /     :", size, myFieldDiv);
+    affiche_valeur_field(" div    :", size, *myFielddiv);
+    affiche_valeur_field("f1+f2*f1:", size, myFieldAsso);
+    affiche_valeur_field("  - f1  :", size, myFieldNeg);
+
+    // Test applyLin
+    std::cout << endl;
+    myField1->applyLin(1,1);
+    affiche_valeur_field(" f1+1 :", size, *myField1);
+    myField1->applyLin(1,-1);
+    affiche_valeur_field(" -> f1  :", size, *myField1);
+    
+    // Test applyFunc
+    std::cout << endl;
+    myField1->applyFunc<myfunction1>();
+    affiche_valeur_field(" CB 2f1 :", size, *myField1);
+    myField1->applyFunc<myfunction2>();
+    affiche_valeur_field(" -> f1  :", size, *myField1);
+
+    // Test operateur +=
+    std::cout << endl;
+    *myField1 += *myField2;
+    affiche_valeur_field(" f1+=f2 :", size, *myField1);
+
+    // Test operateur *=
+    *myField1 *= *myField2;
+    affiche_valeur_field(" f1*=f2 :", size, *myField1);
+
+    // Test operateur /=
+    *myField1 /= *myField2;
+    affiche_valeur_field(" f1/=f2 :", size, *myField1);
+
+    // Test operateur -=
+    *myField1 -= *myField2;
+    affiche_valeur_field(" f1-=f2 :", size, *myField1);
+
+    std::cout << endl << endl; 
+
+
+    delete myFieldadd;
+    delete myFieldsub;
+    delete myFieldmul;
+    delete myFielddiv;
+    delete myFieldDot;
+//    delete myField1_vol;
+
+    delete myField1;
+    delete myField2;
+    delete mySupport ;
+    delete myMesh ;
+    return 0;
+}
index e45c82c263e6276ecef3eff58a02760ec976af5d..56f00863818ed593464a0aee126b9412586315fc 100755 (executable)
@@ -93,14 +93,23 @@ int main (int argc, char ** argv) {
 
   string chainevide(MED_TAILLE_PNOM+2,' ');
   cout << "- Nom du maillage : <<"    << meshName       << ">>" << endl;
-  cout << "- Dimension du maillage : "<< SpaceDimension <<  endl;
+  cout << "- Dimension d'espace : "<< SpaceDimension <<  endl;
+  cout << "- Dimension du maillage : "<< MeshDimension <<  endl;
   cout << "- Pas de nom universel "   << endl ;
   cout << "- Nombre de noeuds : "     << NumberOfNodes  << " " << endl;
 
   int NumberOfTypes           = myMesh->getNumberOfTypes(MED_CELL);
   const medGeometryElement  * Types = myMesh->getTypes(MED_CELL);
   
-  
+  cout << "- Nombre de Type de mailles : " << NumberOfTypes << endl;
+
+  if (NumberOfTypes > 0)
+    {
+      cout << "  Types : ";
+      for (int itype=0; itype<NumberOfTypes; itype++) cout << Types[itype] << " ";
+      cout << endl;
+    }
+
   const list<MED_FR::med_geometrie_element> currentEntity = MED_FR::meshEntities[(MED_FR::med_entite_maillage)MED_CELL];
   list<MED_FR::med_geometrie_element>::const_iterator currentGeometry;
   for (currentGeometry  = currentEntity.begin();
@@ -113,6 +122,18 @@ int main (int argc, char ** argv) {
        cout << " " << endl;
   }
 
+  NumberOfTypes = myMesh->getNumberOfTypes(MED_FACE);
+  Types = myMesh->getTypes(MED_FACE);
+  
+  cout << "- Nombre de Type de faces : " << NumberOfTypes << endl;
+
+  if (NumberOfTypes > 0)
+    {
+      cout << "  Types : ";
+      for (int itype=0; itype<NumberOfTypes; itype++) cout << Types[itype] << " ";
+      cout << endl;
+    }
+
   const list<MED_FR::med_geometrie_element> currentEntity2 = MED_FR::meshEntities[(MED_FR::med_entite_maillage)MED_FACE];
   for (currentGeometry  = currentEntity2.begin();
        currentGeometry != currentEntity2.end(); 
@@ -124,6 +145,18 @@ int main (int argc, char ** argv) {
        cout << " " << endl;
   }
 
+  NumberOfTypes = myMesh->getNumberOfTypes(MED_EDGE);
+  Types = myMesh->getTypes(MED_EDGE);
+  
+  cout << "- Nombre de Type de aretes : " << NumberOfTypes << endl;
+
+  if (NumberOfTypes > 0)
+    {
+      cout << "  Types : ";
+      for (int itype=0; itype<NumberOfTypes; itype++) cout << Types[itype] << " ";
+      cout << endl;
+    }
+
   const list<MED_FR::med_geometrie_element> currentEntity3 = MED_FR::meshEntities[(MED_FR::med_entite_maillage)MED_EDGE];
   for (currentGeometry  = currentEntity3.begin();
        currentGeometry != currentEntity3.end(); 
index b43749ee3c2e497275f0e50489e52fbfb0b9e54b..41529316a41e0945942a88c89b94e2c7ccb049a6 100755 (executable)
@@ -330,7 +330,7 @@ int main (int argc, char ** argv)
                        {
                                try
                                {
-                                       double d = mycoo.getCoordinate(num + 1,axe+1);
+                                       const double d = mycoo.getCoordinate(num + 1,axe+1);
                                        cout << d <<" , ";
                                        ASSERT(fabs(d - coor3[num])  < pouieme);
                                                ASSERT(fabs(d - coor2[(num * SpaceDim)+axe]) < pouieme);
index fe011b0046ce4286b1bf7ca99d5ac4f4dab1dcd1..4a7d775148d46dfec1414e83b195e0adfe59bd52 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM_SWIG : binding of C++ implementation and Python
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_SWIG_FieldDouble.cxx
-//  Module : MED
-
 using namespace std;
 #include "MEDMEM_SWIG_FieldDouble.hxx"
 
@@ -59,15 +33,44 @@ FIELDDOUBLE::FIELDDOUBLE(const SUPPORT * Support, const int NumberOfComponents)
  */
 //=============================================================================
 FIELDDOUBLE::FIELDDOUBLE(const SUPPORT * Support, driverTypes driverType,
-                        const string & fileName,
-                        const string & fieldName) :
-  FIELD<double>(Support, driverType, fileName, fieldName)
+                        const string & fileName, const string & fieldName,
+                        const int iterationNumber, const int orderNumber) :
+  FIELD<double>(Support, driverType, fileName, fieldName,
+               iterationNumber, orderNumber)
 {
   BEGIN_OF("Another constructor with arguments (for Python API) FIELDDOUBLE");
 
+  med_type_champ type = MED_REEL64;
+
+  setValueType(type);
+
   END_OF("Another constructor with arguments (for Python API) FIELDDOUBLE");
 }
 //=============================================================================
+/*!
+ * Copy constructor
+ */
+//=============================================================================
+FIELDDOUBLE::FIELDDOUBLE(const FIELDDOUBLE & m) :
+  FIELD<double>( (FIELD<double> &) m)
+{
+  BEGIN_OF("Copy constructor (for Python API) FIELDDOUBLE");
+
+  END_OF("Copy constructor (for Python API) FIELDDOUBLE");
+}
+//=============================================================================
+/*!
+ * Copy constructor from a FIELD<double>
+ */
+//=============================================================================
+FIELDDOUBLE::FIELDDOUBLE(const FIELD<double> & m) :
+  FIELD<double>( m)
+{
+  BEGIN_OF("Copy constructor (for Python API) FIELDDOUBLE from a FIELD<double>");
+
+  END_OF("Copy constructor (for Python API) FIELDDOUBLE from a FIELD<double>");
+}
+//=============================================================================
 /*!
  * Destructor
  */
index c4e0a5d8d618db7281e27cedb7175a558b72be9c..408f100a1794ec1d5d2bbd92a13573988128eb9a 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM_SWIG : binding of C++ implementation and Python
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_SWIG_FieldDouble.hxx
-//  Module : MED
-
 #ifndef MEDMEM_SWIG_FIELDDOUBLE_HXX_
 #define MEDMEM_SWIG_FIELDDOUBLE_HXX_
 
@@ -35,7 +9,10 @@ public:
   FIELDDOUBLE();
   FIELDDOUBLE(const SUPPORT * Support, const int NumberOfComponents);
   FIELDDOUBLE(const SUPPORT * Support, driverTypes driverType,
-             const string & fileName="", const string & fieldName="");
+             const string & fileName="", const string & fieldName="",
+             const int iterationNumber=-1, const int orderNumber=-1);
+  FIELDDOUBLE(const FIELDDOUBLE & m);
+  FIELDDOUBLE(const FIELD<double> & m);
   ~FIELDDOUBLE();
 };
 
index 125948dbbd34dafc9929e950156cb026a7d18418..f2f002af1b5ed8da20531b811529722894e4a3f0 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM_SWIG : binding of C++ implementation and Python
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_SWIG_FieldInt.cxx
-//  Module : MED
-
 using namespace std;
 #include "MEDMEM_SWIG_FieldInt.hxx"
 
@@ -59,15 +33,43 @@ FIELDINT::FIELDINT(const SUPPORT * Support, const int NumberOfComponents) : FIEL
  */
 //=============================================================================
 FIELDINT::FIELDINT(const SUPPORT * Support, driverTypes driverType,
-                  const string & fileName,
-                  const string & fieldName) :
-  FIELD<int>(Support, driverType, fileName, fieldName)
+                  const string & fileName, const string & fieldName,
+                  const int iterationNumber, const int orderNumber) :
+  FIELD<int>(Support, driverType, fileName, fieldName,
+            iterationNumber, orderNumber)
 {
   BEGIN_OF("Another constructor with arguments (for Python API) FIELDINT");
 
+  med_type_champ type = MED_INT32;
+
+  setValueType(type);
+
   END_OF("Another constructor with arguments (for Python API) FIELDINT");
 }
 //=============================================================================
+/*!
+ * Copy constructor
+ */
+//=============================================================================
+FIELDINT::FIELDINT(const FIELDINT & m) : FIELD<int>( (FIELD<int> &) m)
+{
+  BEGIN_OF("Copy constructor (for Python API) FIELDINT");
+
+  END_OF("Copy constructor (for Python API) FIELDINT");
+}
+//=============================================================================
+/*!
+ * Copy constructor from a FIELD<int>
+ */
+//=============================================================================
+FIELDINT::FIELDINT(const FIELD<int> & m) :
+  FIELD<int>( m)
+{
+  BEGIN_OF("Copy constructor (for Python API) FIELDINT from a FIELD<int>");
+
+  END_OF("Copy constructor (for Python API) FIELDINT from a FIELD<int>");
+}
+//=============================================================================
 /*!
  * Destructor
  */
index 1393c9b78c4c7976c93a46a69ac1693d03232718..557066196553a74c47751fcca92bb9b075c8bbbd 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM_SWIG : binding of C++ implementation and Python
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_SWIG_FieldInt.hxx
-//  Module : MED
-
 #ifndef MEDMEM_SWIG_FIELDINT_HXX_
 #define MEDMEM_SWIG_FIELDINT_HXX_
 
@@ -35,7 +9,10 @@ public:
   FIELDINT();
   FIELDINT(const SUPPORT * Support, const int NumberOfComponents);
   FIELDINT(const SUPPORT * Support, driverTypes driverType,
-          const string & fileName="", const string & fieldName="");
+          const string & fileName="", const string & fieldName="",
+          const int iterationNumber=-1, const int orderNumber=-1);
+  FIELDINT(const FIELDINT & m);
+  FIELDINT(const FIELD<int> & m);
   ~FIELDINT();
 };
 
index 69f1e777fd245c17b6c2aec1c13bf2776bb1e582..8b662aee8875c3e60b64e6b2ba4ba779031bb786 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM_SWIG : binding of C++ implementation and Python
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_SWIG_MedFieldDoubleDriver.cxx
-//  Module : MED
-
 using namespace std;
 #include "MEDMEM_SWIG_MedFieldDoubleDriver.hxx"
 
index 8238c94e187fbdff4daed03c023c9d8ecc958f68..65e5d657321e8102cdca284e1dbfa7deb3139e25 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM_SWIG : binding of C++ implementation and Python
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_SWIG_MedFieldDoubleDriver.hxx
-//  Module : MED
-
 #ifndef MEDMEM_SWIG_MEDFIELDDOUBLEDRIVER_HXX_
 #define MEDMEM_SWIG_MEDFIELDDOUBLEDRIVER_HXX_
 
index 8639d925ff9e1147e37384025e36ec17641b947c..87b25165d261cf327d2f68077286857c51b8b0cb 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM_SWIG : binding of C++ implementation and Python
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_SWIG_MedFieldIntDriver.cxx
-//  Module : MED
-
 using namespace std;
 #include "MEDMEM_SWIG_MedFieldIntDriver.hxx"
 
index 5ba83081703abfd65f5a0bd188a4b8f4995832ad..bb43c893fcef31b83b60924860414ba8fce28ec8 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MEDMEM_SWIG : binding of C++ implementation and Python
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : MEDMEM_SWIG_MedFieldIntDriver.hxx
-//  Module : MED
-
 #ifndef MEDMEM_SWIG_MEDFIELDINTDRIVER_HXX_
 #define MEDMEM_SWIG_MEDFIELDINTDRIVER_HXX_
 
index 480d3a9cc779e1c5fb663bdb1af3e2085c18a2b8..2c1e9343e9209dfde99f05109265195291c97a19 100644 (file)
@@ -1,32 +1,8 @@
-//  MED MEDMEM_SWIG : binding of C++ implementation and Python
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : libMEDMEM_Swig.i
-//  Module : MED
-
 %module libMEDMEM_Swig
 
 %{
+#include <sstream>
+#include <string>
 #include "MEDMEM_CellModel.hxx"
 #include "MEDMEM_GenDriver.hxx"
 #include "MEDMEM_MedMeshDriver.hxx"
@@ -66,7 +42,7 @@
 {
   try
     {
-      $action   ;
+      $action
     }
   catch(MEDEXCEPTION& exception)
     {
 
 %rename(assign) *::operator=;
 
+/*
+  typemap for vector<FAMILY *> C++ object
+*/
+
+%typemap(python,in) vector<FAMILY *>, const vector<FAMILY *>
+{
+  /* typemap in for vector<FAMILY *> */
+  /* Check if is a list */
+
+  if (PyList_Check($input)) { 
+    int size = PyList_Size($input);
+    $1.resize(size);
+
+    for (int i=0; i < size; i++)
+      {
+       PyObject * tmp = PyList_GetItem($input,i);
+       FAMILY * f;
+
+       int err = SWIG_ConvertPtr(tmp, (void **) &f, $descriptor(FAMILY *),
+                                 SWIG_POINTER_EXCEPTION);
+
+       if (err == -1)
+         {
+           char * message = "Error in typemap(python,in) for vector<FAMILY *> each component should be a FAMILY pointer";
+           PyErr_SetString(PyExc_RuntimeError, message);
+           return NULL;
+         }
+
+       $1[i] = f;
+      }
+  } 
+  else
+    { 
+      PyErr_SetString(PyExc_TypeError,"not a list");
+      return NULL;
+    }
+} 
+
+%typemap(python,out) vector<FAMILY *>
+{
+  /* typemap out for vector<FAMILY *> */
+  int size = $1.size();
+  $result = PyList_New(size);
+
+  for (int i=0;i<size;i++)
+    {
+      PyObject * tmp = SWIG_NewPointerObj($1[i],$descriptor(FAMILY *),0);
+
+      PyList_SetItem($result,i,tmp);
+    }
+}
+
+/*
+  typemap for vector<SUPPORT *> C++ object
+*/
+
+%typemap(python,in) vector<SUPPORT *>, const vector<SUPPORT *>
+{
+  /* typemap in for vector<SUPPORT *> */
+  /* Check if is a list */
+
+  if (PyList_Check($input)) { 
+    int size = PyList_Size($input);
+    $1.resize(size);
+
+    for (int i=0; i < size; i++)
+      {
+       PyObject * tmp = PyList_GetItem($input,i);
+       SUPPORT * s;
+
+       int err = SWIG_ConvertPtr(tmp, (void **) &s, $descriptor(SUPPORT *),
+                                 SWIG_POINTER_EXCEPTION);
+
+       if (err == -1)
+         {
+           char * message = "Error in typemap(python,in) for vector<SUPPORT *> each component should be a SUPPORT pointer";
+           PyErr_SetString(PyExc_RuntimeError, message);
+           return NULL;
+         }
+
+       $1[i] = s;
+      }
+  } 
+  else
+    { 
+      PyErr_SetString(PyExc_TypeError,"not a list");
+      return NULL;
+    }
+} 
+
+%typemap(python,out) vector<SUPPORT *>
+{
+  /* typemap out for vector<SUPPORT *> */
+  int size = $1.size();
+  $result = PyList_New(size);
+
+  for (int i=0;i<size;i++)
+    {
+      PyObject * tmp = SWIG_NewPointerObj($1[i],$descriptor(SUPPORT *),0);
+
+      PyList_SetItem($result,i,tmp);
+    }
+}
+
+%typemap(python,out) char *
+{
+  /* typemap out for char * */
+
+  $result = PyString_FromString($1);
+}
+
+%typemap(python,out) string {
+    $result = PyString_FromString($1.c_str());
+}
+
+%typemap(python,in) string {
+  $1=string(PyString_AsString($input));
+}
+
+/*
+  typemap in for PyObject * fonction Python wrapping of a
+  double or int fonction pointeur
+*/
+
+%typemap(python,in) PyObject * double_function, PyObject * integer_function
+{
+  /* typemap in for double or integer callable fonction pointeur */
+  /* Check if it is a callable fonction pointer */
+
+  if(PyCallable_Check($input) == 0)
+    {
+      char * message = "Error in typemap(python,in) for double or integer callable fonction pointeur : the argument should be a callable object";
+      PyErr_SetString(PyExc_RuntimeError, message);
+      return NULL;
+    }
+
+  $1 = $input;
+}
+
 /*
   enum of the C++ MED used in the Python API
 */
@@ -108,7 +223,8 @@ typedef enum {MED_NONE=0, MED_POINT1=1, MED_SEG2=102, MED_SEG3=103,
 
 typedef enum {MED_NODAL, MED_DESCENDING} medConnectivity ; 
 
-typedef enum {MED_DRIVER=0, VTK_DRIVER=1, NO_DRIVER=255} driverTypes;
+typedef enum {MED_DRIVER=0, GIBI_DRIVER=1, VTK_DRIVER=254,
+             NO_DRIVER=255} driverTypes;
 
 typedef enum {MED_REEL64=6, MED_INT32=24, MED_INT64=26,
              MED_INT} med_type_champ;
@@ -154,70 +270,6 @@ class CELLMODEL
   medGeometryElement getConstituentType(int dim,int num);
 
   int getNumberOfConstituentsType();
-
-
-
-/*   int* getNodesConstituent(int dim,int num) const; */
-
-
-
-
-
-
-
-
-
-/*   medGeometryElement*  getConstituentsType(int dim) const; */
-
-
-
-
-
-
-
-
-
-
-
-/*   set<medGeometryElement>  getAllConstituentsType() const; */
-
-
-/*   map<medGeometryElement,int>  getNumberOfConstituentsForeachType() const; */
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 
   ~CELLMODEL();
 
@@ -234,11 +286,9 @@ class CELLMODEL
     %newobject __str__();
     const char* __str__()
       {
-       ostrstream line;
-       line << "Python Printing CELLMODEL : " << *self << endl;
-       char * tmp = new char[strlen(line.str())+1];
-       strcpy(tmp,line.str());
-       return tmp;
+       ostringstream mess;
+       mess << "Python Printing CELLMODEL : " << *self << endl;
+       return strdup(mess.str().c_str());
       }
   }
 };
@@ -280,6 +330,8 @@ class SUPPORT
 
   void getBoundaryElements();
 
+  void setNumber(const int * index, const int* value);
+
   %extend {
     SUPPORT(MESH* Mesh, char * Name="", medEntityMesh Entity=MED_CELL)
       {
@@ -289,11 +341,11 @@ class SUPPORT
     %newobject __str__();
     const char* __str__()
       {
-       ostrstream line;
-       line << "Python Printing SUPPORT : " << *self << endl;
-       char * tmp = new char[strlen(line.str())+1];
-       strcpy(tmp,line.str());
-       return tmp;
+       ostringstream mess;
+       mess << "Python Printing SUPPORT : " << *self << endl;
+       char * tmp = const_cast <char *> (mess.str().c_str());
+       char * returned = strdup(tmp);
+       return returned;
       }
 
     void setpartial(char * Description, int NumberOfGeometricType,
@@ -352,6 +404,7 @@ class SUPPORT
              }
          }
        PyObject * result = Py_BuildValue("O", py_list);
+       Py_DECREF(py_list);
        return result;
       }
 
@@ -375,6 +428,7 @@ class SUPPORT
              }
          }
        PyObject * result = Py_BuildValue("O", py_list);
+       Py_DECREF(py_list);
        return result;
       }
 
@@ -398,6 +452,7 @@ class SUPPORT
              }
          }
        PyObject * result = Py_BuildValue("O", py_list);
+       Py_DECREF(py_list);
        return result;
       }
   }
@@ -453,10 +508,9 @@ class FAMILY : public SUPPORT
     %newobject __str__();
     const char* __str__()
       {
-       ostrstream line;
-       line << "Python Printing Family : " << *self << endl;
-       char * tmp = new char[strlen(line.str())+1];
-       strcpy(tmp,line.str());
+       ostringstream mess;
+       mess << "Python Printing Family : " << *self << endl;
+       return strdup(mess.str().c_str());
       }
 
     %newobject getAttributeDescription(int );
@@ -497,6 +551,7 @@ class FAMILY : public SUPPORT
              }
          }
        PyObject * result = Py_BuildValue("O", py_list);
+       Py_DECREF(py_list);
        return result;
       }
 
@@ -520,11 +575,15 @@ class FAMILY : public SUPPORT
              }
          }
        PyObject * result = Py_BuildValue("O", py_list);
+       Py_DECREF(py_list);
        return result;
       }
   }
 }; 
 
+
+
+
 class FIELD_
 {
 public:
@@ -555,6 +614,17 @@ public:
   void setNumberOfValues(int NumberOfValues);
   int getNumberOfValues() const;
 
+  string   getName() const;
+  string   getDescription() const;
+  string   getComponentName(int i) const;
+  string   getComponentDescription(int i) const;
+  string   getMEDComponentUnit(int i) const;
+  void     setName(string Name);
+  void     setComponentName(int i, string ComponentName);
+  void     setMEDComponentUnit(int i, string MEDComponentUnit);
+  void     setDescription(string Description);
+  void     setComponentDescription(int i, string ComponentDescription);
+
   %extend {
     int addDriver(driverTypes driverType,
                  char * fileName="Default File Name.med",
@@ -564,78 +634,10 @@ public:
                               string(driverName));
       }
 
-    void setName(char * name)
-      {
-       self->setName(string(name));
-      }
-
-    %newobject getName();
-    const char * getName()
-      {
-       string tmp_str = self->getName();
-       char * tmp = new char[strlen(tmp_str.c_str())+1];
-       strcpy(tmp,tmp_str.c_str());
-       return tmp;     
-      }
-
-    void setDescription(char * Description)
-      {
-       self->setDescription(string(Description));
-      }
-
-    %newobject getDescription();
-    const char * getDescription() const
-      {
-       string tmp_str = self->getDescription();
-       char * tmp = new char[strlen(tmp_str.c_str())+1];
-       strcpy(tmp,tmp_str.c_str());
-       return tmp;
-      }
-
-    %newobject getComponentName(int );
-    const char * getComponentName(int i)
-      {
-       string tmp_str = self->getComponentName(i);
-       char * tmp = new char[strlen(tmp_str.c_str())+1];
-       strcpy(tmp,tmp_str.c_str());
-       return tmp;     
-      }
-
-    void setComponentName(int i, char * ComponentName)
-      {
-       self->setComponentName(i,string(ComponentName));
-      }
-
-    %newobject getComponentDescription(int );
-    const char * getComponentDescription(int i)
-      {
-       string tmp_str = self->getComponentDescription(i);
-       char * tmp = new char[strlen(tmp_str.c_str())+1];
-       strcpy(tmp,tmp_str.c_str());
-       return tmp;     
-      }
-
-    void setComponentDescription(int i, char * ComponentDescription)
-      {
-       self->setComponentDescription(i,string(ComponentDescription));
-      }
-
-    %newobject getMEDComponentUnit(int );
-    const char * getMEDComponentUnit(int i)
-      {
-       string tmp_str = self->getMEDComponentUnit(i);
-       char * tmp = new char[strlen(tmp_str.c_str())+1];
-       strcpy(tmp,tmp_str.c_str());
-       return tmp;
-      }
-
-    void setMEDComponentUnit(int i, char * MEDComponentUnit)
-      {
-       self->setMEDComponentUnit(i,string(MEDComponentUnit));
-      }
   }
 }; 
 
+
 class FIELDDOUBLE : public FIELD_
 {
 public:
@@ -653,6 +655,8 @@ public:
 
   FIELDDOUBLE();    
 
+  FIELDDOUBLE(const FIELDDOUBLE & m);
+
   void read(int index=0);
 
   double getValueIJ(int i,int j) const;
@@ -667,12 +671,83 @@ public:
 
   void deallocValue();
 
+  void applyLin(double a, double n);
+
+  double normMax();
+  double norm2();
+  double normL2(int component, const FIELDDOUBLE * p_field_volume=NULL) const;
+  double normL2(const FIELDDOUBLE * p_field_volume=NULL) const;
+  double normL1(int component, const FIELDDOUBLE * p_field_volume=NULL) const;
+  double normL1(const FIELDDOUBLE * p_field_volume=NULL) const;
+
+
   %extend {
+    PyObject *  applyPyFunc( PyObject * func )
+    {
+       MESSAGE("Appel de applyPyFunc");
+       if (!PyCallable_Check(func)) {
+           PyErr_SetString(PyExc_TypeError, "FIELDDOUBLE.applyPyFunc prend en argument une fonction");
+           return NULL;
+       }
+
+       int nComp=self->getNumberOfComponents();
+       int nVal=self->getNumberOfValues();
+       for (int i=1; i!=nVal+1; ++i)
+           for ( int j=1 ;j!=nComp+1 ;++j )
+           {
+               self->setValueIJ(i,j,PyFloat_AsDouble (PyObject_CallFunction( func, "f", self->getValueIJ(i,j) ) ) );
+               //cout << "value(" << i << "," << j << ") = " << self->getValueIJ(i,j) << " -> ";
+               //cout << PyFloat_AsDouble (PyObject_CallFunction( func, "f", self->getValueIJ(i,j) ) ) << endl;
+           }
+        PyObject * result = Py_BuildValue("d", nComp*nVal);
+        return result;
+    }
+
+    %newobject __add__(const FIELDDOUBLE & );
+    FIELDDOUBLE * __add__(const FIELDDOUBLE & m)
+      {
+       MESSAGE("operator +  : Creation of the addition of two FIELDDOUBLEs");
+
+       FIELD<double>* result = FIELD<double>::add( *(FIELD<double>*)self , (FIELD<double>&)m );
+       return (FIELDDOUBLE*) result;
+
+/*     const FIELD<double> result = (*(FIELD<double>*)self) +
+         (FIELD<double>&)m;
+       return new FIELDDOUBLE(result); */
+      }
+
+    %newobject __sub__(const FIELDDOUBLE & );
+    FIELDDOUBLE * __sub__(const FIELDDOUBLE & m)
+      {
+       MESSAGE("operator -  : Creation of the substraction of two FIELDDOUBLEs");
+       FIELD<double>* result = FIELD<double>::sub( *(FIELD<double>*)self , (FIELD<double>&)m );
+       return (FIELDDOUBLE*) result;
+      }
+
+    %newobject __mul__(const FIELDDOUBLE & );
+    FIELDDOUBLE * __mul__(const FIELDDOUBLE & m)
+      {
+       MESSAGE("operator *  : Creation of the multiplication of two FIELDDOUBLEs");
+       FIELD<double>* result = FIELD<double>::mul( *(FIELD<double>*)self , (FIELD<double>&)m );
+       return (FIELDDOUBLE*) result;
+      }
+
+    %newobject __div__(const FIELDDOUBLE & );
+    FIELDDOUBLE * __div__(const FIELDDOUBLE & m)
+      {
+       MESSAGE("operator /  : Creation of the division of two FIELDDOUBLEs");
+       FIELD<double>* result = FIELD<double>::div( *(FIELD<double>*)self , (FIELD<double>&)m );
+       return (FIELDDOUBLE*) result;
+      }
+
     FIELDDOUBLE (const SUPPORT * Support, driverTypes driverType,
-                char * fileName, char * fieldName)
+                char * fileName, char * fieldName,
+                const int iterationNumber,
+                const int orderNumber)
       {
        return new FIELDDOUBLE(Support, driverType, string(fileName),
-                              string(fieldName));
+                              string(fieldName),iterationNumber,
+                              orderNumber);
       }
 
     void write(int index=0, char * driverName="")
@@ -680,6 +755,11 @@ public:
        self->write(index, string(driverName));
       }
 
+    void writeAppend(int index=0, char * driverName="")
+      {
+       self->writeAppend(index, string(driverName));
+      }
+
     PyObject * getValue(medModeSwitch Mode)
       {
        PyObject *py_list;
@@ -702,6 +782,7 @@ public:
              }
          }
        PyObject * result = Py_BuildValue("O", py_list);
+       Py_DECREF(py_list);
        return result;
       }
 
@@ -729,6 +810,7 @@ public:
              }
          }
        PyObject * result = Py_BuildValue("O", py_list);
+       Py_DECREF(py_list);
        return result;
       }
 
@@ -757,6 +839,8 @@ public:
 
   FIELDINT();
 
+  FIELDINT(const FIELDINT & m);
+
   void read(int index=0);
 
   int getValueIJ(int i,int j) const;
@@ -771,12 +855,74 @@ public:
 
   void deallocValue();
 
+  void applyLin(int a, int n);
+
+  double normMax();
+  double norm2();
+  double normL2(int component, const FIELDDOUBLE * p_field_volume=NULL) const;
+  double normL2(const FIELDDOUBLE * p_field_volume=NULL) const;
+  double normL1(int component, const FIELDDOUBLE * p_field_volume=NULL) const;
+  double normL1(const FIELDDOUBLE * p_field_volume=NULL) const;
+
+
   %extend {
+
+    PyObject *  applyPyFunc( PyObject * func )
+    {
+       if (!PyCallable_Check(func)) {
+           PyErr_SetString(PyExc_TypeError, "FIELDDOUBLE.applyPyFunc prend en argument une fonction");
+           return NULL;
+       }
+
+       int nComp=self->getNumberOfComponents();
+       int nVal=self->getNumberOfValues();
+       for (int i=1; i!=nVal+1; ++i)
+           for ( int j=1 ;j!=nComp+1 ;++j )
+               self->setValueIJ(i,j,PyInt_AsLong (PyObject_CallFunction( func, "i", self->getValueIJ(i,j) ) ) );
+        PyObject * result = Py_BuildValue("d", nComp*nVal);
+        return result;
+    }
+
+    %newobject __add__(const FIELDINT & );
+    FIELDINT * __add__(const FIELDINT & m)
+      {
+       MESSAGE("operator +  : Creation of the addition of two FIELDINTs");
+       FIELD<int>* result = FIELD<int>::add( *(FIELD<int>*)self , (FIELD<int>&)m );
+       return (FIELDINT*) result;
+      }
+
+    %newobject __sub__(const FIELDINT & );
+    FIELDINT * __sub__(const FIELDINT & m)
+      {
+       MESSAGE("operator -  : Creation of the substraction of two FIELDINTs");
+       FIELD<int>* result = FIELD<int>::sub( *(FIELD<int>*)self , (FIELD<int>&)m );
+       return (FIELDINT*) result;
+      }
+
+    %newobject __mul__(const FIELDINT & );
+    FIELDINT * __mul__(const FIELDINT & m)
+      {
+       MESSAGE("operator *  : Creation of the multiplication of two FIELDINTs");
+       FIELD<int>* result = FIELD<int>::mul( *(FIELD<int>*)self , (FIELD<int>&)m );
+       return (FIELDINT*) result;
+      }
+
+    %newobject __div__(const FIELDINT & );
+    FIELDINT * __div__(const FIELDINT & m)
+      {
+       MESSAGE("operator /  : Creation of the division of two FIELDINTs");
+       FIELD<int>* result = FIELD<int>::div( *(FIELD<int>*)self , (FIELD<int>&)m );
+       return (FIELDINT*) result;
+      }
+
     FIELDINT(const SUPPORT * Support, driverTypes driverType,
-             char * fileName, char * fieldName)
+             char * fileName, char * fieldName,
+            const int iterationNumber,
+            const int orderNumber)
       {
        return new FIELDINT(Support, driverType, string(fileName),
-                           string(fieldName));
+                           string(fieldName), iterationNumber,
+                           orderNumber);
       }
 
     void write(int index=0, char * driverName="")
@@ -784,6 +930,11 @@ public:
        self->write(index, string(driverName));
       }
 
+    void writeAppend(int index=0, char * driverName="")
+      {
+       self->writeAppend(index, string(driverName));
+      }
+
     PyObject * getValue(medModeSwitch Mode)
       {
        PyObject *py_list;
@@ -806,6 +957,7 @@ public:
              }
          }
        PyObject * result = Py_BuildValue("O", py_list);
+       Py_DECREF(py_list);
        return result;
       }
 
@@ -832,6 +984,7 @@ public:
              }
          }
        PyObject * result = Py_BuildValue("O", py_list);
+       Py_DECREF(py_list);
        return result;
       }
 
@@ -919,6 +1072,18 @@ public :
        return self->getSkin(Support3D);
       }
 
+    %newobject mergeSupports(const vector<SUPPORT *> );
+    SUPPORT * mergeSupports(const vector<SUPPORT *> Supports)
+      {
+       return self->mergeSupports(Supports);
+      }
+
+    %newobject intersectSupports(const vector<SUPPORT *> );
+    SUPPORT * intersectSupports(const vector<SUPPORT *> Supports)
+      {
+       return self->intersectSupports(Supports);
+      }
+
     CELLMODEL getCellType(medEntityMesh Entity,int i)
       {
        return self->getCellsTypes(Entity)[i];
@@ -965,6 +1130,14 @@ public :
        return tmp;
       }
 
+    %newobject __str__();
+    const char* __str__()
+      {
+       ostringstream mess;
+       mess << "Python Printing MESH : " << *self << endl;
+       return strdup(mess.str().c_str());
+      }
+
     %newobject getCoordinateName(int );
     const char * getCoordinateName(int i)
       {
@@ -1001,6 +1174,7 @@ public :
              }
          }
        PyObject * result = Py_BuildValue("O", py_list);
+       Py_DECREF(py_list);
        return result;
       }
 
@@ -1022,6 +1196,7 @@ public :
              }
          }
        PyObject * result = Py_BuildValue("O", py_list);
+       Py_DECREF(py_list);
        return result;
       }
 
@@ -1043,6 +1218,7 @@ public :
              }
          }
        PyObject * result = Py_BuildValue("O", py_list);
+       Py_DECREF(py_list);
        return result;
       }
 
@@ -1065,6 +1241,7 @@ public :
              }
          }
        PyObject * result = Py_BuildValue("O", py_list);
+       Py_DECREF(py_list);
        return result;
       }
 
@@ -1101,6 +1278,7 @@ public :
              }
          }
        PyObject * result = Py_BuildValue("O", py_list);
+       Py_DECREF(py_list);
        return result;
       }
 
@@ -1126,6 +1304,7 @@ public :
              }
          }
        PyObject * result = Py_BuildValue("O", py_list);
+       Py_DECREF(py_list);
        return result;
       }
 
@@ -1167,6 +1346,7 @@ public :
              }
          }
        PyObject * result = Py_BuildValue("O", py_list);
+       Py_DECREF(py_list);
        return result;
       }
 
@@ -1207,6 +1387,31 @@ public :
              }
          }
        PyObject * result = Py_BuildValue("O", py_list);
+       Py_DECREF(py_list);
+       return result;
+      }
+
+    PyObject * getGlobalNumberingIndex(medEntityMesh Entity)
+      {
+       PyObject *py_list;
+       const int * numberingIndex = self->getGlobalNumberingIndex(Entity);
+       int nbOfTypes = self->getNumberOfTypes(Entity);
+       int size = nbOfTypes+1;
+
+       py_list = PyList_New(size);
+       for (int i=0; i < size; i++)
+         {
+           int err = PyList_SetItem(py_list, i,
+                                    Py_BuildValue("i", numberingIndex[i]));
+           if(err)
+             {
+               char * message = "Error in MESH::getGlobalNumberingIndex";
+               PyErr_SetString(PyExc_RuntimeError, message);
+               return NULL;
+             }
+         }
+       PyObject * result = Py_BuildValue("O", py_list);
+       Py_DECREF(py_list);
        return result;
       }
 
@@ -1307,13 +1512,13 @@ class GRID : public MESH
 
   ~GRID();
 
-  int getNodeNumber(const int i, const int j=0, const int k=0);
+  int getNodeNumber(const int i, const int j=0, const int k=0) const ;
 
-  int getCellNumber(const int i, const int j=0, const int k=0) ;
+  int getCellNumber(const int i, const int j=0, const int k=0) const ;
 
-  int getEdgeNumber(const int Axis, const int i, const int j=0, const int k=0);
+  int getEdgeNumber(const int Axis, const int i, const int j=0, const int k=0) const ;
 
-  int getFaceNumber(const int Axis, const int i, const int j=0, const int k=0);
+  int getFaceNumber(const int Axis, const int i, const int j=0, const int k=0) const ;
   
   med_grid_type getGridType();
   
@@ -1372,6 +1577,7 @@ class GRID : public MESH
         PyList_SetItem(py_list, 0, Py_BuildValue("i", Axis));
       
       PyObject * result = Py_BuildValue("O", py_list);
+      Py_DECREF(py_list);
       return result;
     }
   }
@@ -1394,6 +1600,10 @@ class MED
 
   void write (int index=0);
 
+  void addField ( FIELD_  * const ptrField  );
+
+  void addMesh  ( MESH    * const ptrMesh   );
+
   %extend {
     /*
       WARNING:
@@ -1456,6 +1666,12 @@ class MED
       {
        return self->getField(string(fieldName),dt,it);
       }
+
+    SUPPORT * getSupport(char * meshName, medEntityMesh entity)
+      {
+       return self->getSupport(string(meshName),
+                               (MED_FR::med_entite_maillage) entity);
+      }
   }
 };
 
@@ -1479,6 +1695,14 @@ class MED_MED_RDONLY_DRIVER
       {
        return new MED_MED_RDONLY_DRIVER(string(fileName), ptrMed);
       }
+
+    %newobject __str__();
+    const char* __str__()
+      {
+       ostringstream mess;
+       mess << "Python Printing MED_MED_RDONLY_DRIVER : " << *self << endl;
+       return strdup(mess.str().c_str());
+      }
   }
 };
 
@@ -1498,6 +1722,14 @@ class MED_MED_WRONLY_DRIVER
       {
        return new MED_MED_WRONLY_DRIVER(string(fileName), ptrMed);
       }
+
+    %newobject __str__();
+    const char* __str__()
+      {
+       ostringstream mess;
+       mess << "Python Printing MED_MED_WRONLY_DRIVER : " << *self << endl;
+       return strdup(mess.str().c_str());
+      }
   }
 };
 
@@ -1520,6 +1752,14 @@ class MED_MED_RDWR_DRIVER : public virtual MED_MED_RDONLY_DRIVER,
       {
        return new MED_MED_RDWR_DRIVER(string(fileName), ptrMed);
       }
+
+    %newobject __str__();
+    const char* __str__()
+      {
+       ostringstream mess;
+       mess << "Python Printing MED_MED_RDWR_DRIVER : " << *self << endl;
+       return strdup(mess.str().c_str());
+      }
   }
 };
 
@@ -1547,6 +1787,14 @@ class MED_MESH_RDONLY_DRIVER
        return new MED_MESH_RDONLY_DRIVER(string(fileName), ptrMesh);
       }
 
+    %newobject __str__();
+    const char* __str__()
+      {
+       ostringstream mess;
+       mess << "Python Printing MED_MESH_RDONLY_DRIVER : " << *self << endl;
+       return strdup(mess.str().c_str());
+      }
+
     void setMeshName(char * meshName)
       {
        self->setMeshName(string(meshName));
@@ -1582,6 +1830,14 @@ class MED_MESH_WRONLY_DRIVER
        return new MED_MESH_WRONLY_DRIVER(string(fileName), ptrMesh);
       }
 
+    %newobject __str__();
+    const char* __str__()
+      {
+       ostringstream mess;
+       mess << "Python Printing MED_MESH_WRONLY_DRIVER : " << *self << endl;
+       return strdup(mess.str().c_str());
+      }
+
     void setMeshName(char * meshName)
       {
        self->setMeshName(string(meshName));
@@ -1619,6 +1875,14 @@ class MED_MESH_RDWR_DRIVER : public virtual MED_MESH_RDONLY_DRIVER,
        return new MED_MESH_RDWR_DRIVER(string(fileName), ptrMesh);
       }
 
+    %newobject __str__();
+    const char* __str__()
+      {
+       ostringstream mess;
+       mess << "Python Printing MED_MESH_RDWR_DRIVER : " << *self << endl;
+       return strdup(mess.str().c_str());
+      }
+
     void setMeshName(char * meshName)
       {
        self->setMeshName(string(meshName));
@@ -1659,6 +1923,14 @@ public:
        return new MED_FIELDDOUBLE_RDONLY_DRIVER(string(fileName), ptrField);
       }
 
+    %newobject __str__();
+    const char* __str__()
+      {
+       ostringstream mess;
+       mess << "Python Printing MED_FIELDDOUBLE_RDONLY_DRIVER : " << *self << endl;
+       return strdup(mess.str().c_str());
+      }
+
     void setFieldName(char * fieldName)
       {
        self->setFieldName(string(fieldName));
@@ -1695,6 +1967,14 @@ public:
        return new MED_FIELDDOUBLE_WRONLY_DRIVER(string(fileName), ptrField);
       }
 
+    %newobject __str__();
+    const char* __str__()
+      {
+       ostringstream mess;
+       mess << "Python Printing MED_FIELDDOUBLE_WRONLY_DRIVER : " << *self << endl;
+       return strdup(mess.str().c_str());
+      }
+
     void setFieldName(char * fieldName)
       {
        self->setFieldName(string(fieldName));
@@ -1731,6 +2011,14 @@ public:
        return new MED_FIELDDOUBLE_RDWR_DRIVER(string(fileName), ptrField);
       }
 
+    %newobject __str__();
+    const char* __str__()
+      {
+       ostringstream mess;
+       mess << "Python Printing MED_FIELDDOUBLE_RDWR_DRIVER : " << *self << endl;
+       return strdup(mess.str().c_str());
+      }
+
     void setFieldName(char * fieldName)
       {
        self->setFieldName(string(fieldName));
@@ -1771,6 +2059,14 @@ public:
        return new MED_FIELDINT_RDONLY_DRIVER(string(fileName), ptrField);
       }
 
+    %newobject __str__();
+    const char* __str__()
+      {
+       ostringstream mess;
+       mess << "Python Printing MED_FIELDINT_RDONLY_DRIVER : " << *self << endl;
+       return strdup(mess.str().c_str());
+      }
+
     void setFieldName(char * fieldName)
       {
        self->setFieldName(string(fieldName));
@@ -1807,6 +2103,14 @@ public:
        return new MED_FIELDINT_WRONLY_DRIVER(string(fileName), ptrField);
       }
 
+    %newobject __str__();
+    const char* __str__()
+      {
+       ostringstream mess;
+       mess << "Python Printing MED_FIELDINT_WRONLY_DRIVER : " << *self << endl;
+       return strdup(mess.str().c_str());
+      }
+
     void setFieldName(char * fieldName)
       {
        self->setFieldName(string(fieldName));
@@ -1843,6 +2147,14 @@ public:
        return new MED_FIELDINT_RDWR_DRIVER(string(fileName), ptrField);
       }
 
+    %newobject __str__();
+    const char* __str__()
+      {
+       ostringstream mess;
+       mess << "Python Printing MED_FIELDINT_RDWR_DRIVER : " << *self << endl;
+       return strdup(mess.str().c_str());
+      }
+
     void setFieldName(char * fieldName)
       {
        self->setFieldName(string(fieldName));
@@ -1859,27 +2171,447 @@ public:
   }
 };
 
+%newobject createFieldDoubleScalarProduct(FIELDDOUBLE * field1, FIELDDOUBLE * field2) ;
+FIELDDOUBLE * createFieldDoubleScalarProduct(FIELDDOUBLE * field1, FIELDDOUBLE * field2) ;
+
+%newobject createFieldIntScalarProduct(FIELDINT * field1, FIELDINT * field2) ;
+FIELDINT * createFieldIntScalarProduct(FIELDINT * field1, FIELDINT * field2) ;
+
 FIELDDOUBLE * createFieldDoubleFromField(FIELD_ * field) ;
 
 FIELDINT * createFieldIntFromField(FIELD_ * field) ;
 
+%newobject createFieldDoubleFromAnalytic(SUPPORT * , int , PyObject *);
+FIELDDOUBLE * createFieldDoubleFromAnalytic(SUPPORT * Support,
+                                           int NumberOfComponents,
+                                           PyObject * double_function) ;
+
+%newobject createFieldIntFromAnalytic(SUPPORT * , int , PyObject *);
+FIELDINT * createFieldIntFromAnalytic(SUPPORT * Support,
+                                     int NumberOfComponents,
+                                     PyObject * integer_function) ;
+
 GRID * createGridFromMesh( MESH * aMesh );
 
 %{
+  FIELDDOUBLE * createFieldDoubleScalarProduct(FIELDDOUBLE * field1, FIELDDOUBLE * field2) 
+  {
+     return (FIELDDOUBLE *) FIELD<double>::scalarProduct( (FIELD<double>)*field1, (FIELD<double>)*field2);
+  }
+  
+  FIELDINT * createFieldIntScalarProduct(FIELDINT * field1, FIELDINT * field2) 
+  {
+     return (FIELDINT *) FIELD<int>::scalarProduct( (FIELD<int>)*field1, (FIELD<int>)*field2);
+  }
+  
   FIELDDOUBLE * createFieldDoubleFromField(FIELD_ * field)
     {
-      MESSAGE("creatFieldDoubleFromField : Constructor (for Python API) FIELDDOUBLE with parameter FIELD_");
+      MESSAGE("createFieldDoubleFromField : Constructor (for Python API) FIELDDOUBLE with parameter FIELD_");
       MESSAGE("Its returns a proper cast of the input pointer :: FIELD_ --> FIELDDOUBLE");
       return (FIELDDOUBLE *) field;
     }
 
   FIELDINT * createFieldIntFromField(FIELD_ * field)
     {
-      MESSAGE("creatFieldIntFromField : Constructor (for Python API) FIELDINT with parameter FIELD_");
+      MESSAGE("createFieldIntFromField : Constructor (for Python API) FIELDINT with parameter FIELD_");
       MESSAGE("Its returns a proper cast of the input pointer :: FIELD_ --> FIELDINT");
       return (FIELDINT *) field;
     }
 
+  FIELDDOUBLE * createFieldDoubleFromAnalytic(SUPPORT * Support,
+                                             int NumberOfComponents,
+                                             PyObject * double_function)
+    {
+      MESSAGE("createFieldDoubleFromAnalytic : Constructor (for Python API) FIELDDOUBLE from an analytic fonction");
+
+      FIELDDOUBLE * fieldDouble  = new FIELDDOUBLE(Support,NumberOfComponents);
+
+      int NumberOfValues = fieldDouble->getNumberOfValues();
+      double * values = new double[NumberOfValues*NumberOfComponents];
+
+      const double * x = (const double *) NULL;
+      const double * y = (const double *) NULL;
+      const double * z = (const double *) NULL;
+
+      FIELD<double> * barycenterField = (FIELD<double> *) NULL;
+
+      medEntityMesh entity = Support->getEntity();
+      bool onAll = Support->isOnAllElements();
+
+      MESH * mesh = Support->getMesh();
+      int spaceDim = mesh->getSpaceDimension();
+
+      if (entity == MED_NODE)
+       {
+         if (onAll)
+           {
+             const double * coord = mesh->getCoordinates(MED_NO_INTERLACE);
+
+             x = coord;
+             y = coord+NumberOfValues;
+             if (spaceDim == 3) z = y+NumberOfValues;
+           }
+         else
+           {
+             const int * nodesNumber = Support->getNumber(MED_ALL_ELEMENTS);
+             const double * coord = mesh->getCoordinates(MED_FULL_INTERLACE);
+
+             double * x_tmp = new double [NumberOfValues];
+             double * y_tmp = new double [NumberOfValues];
+
+             for (int i=0; i<NumberOfValues; i++)
+               {
+                 int j = nodesNumber[i]*spaceDim;
+                 x_tmp[i] = coord[j];
+                 y_tmp[i] = coord[j+1];
+               }
+
+             x = x_tmp;
+             y = y_tmp;
+
+             if (spaceDim == 3)
+               {
+                 double * z_tmp = new double [NumberOfValues];
+
+                 for (int i=0; i<NumberOfValues; i++)
+                   {
+                     int j = nodesNumber[i]*spaceDim + 2;
+                     z_tmp[i] = coord[j];
+                   }
+
+                 z = z_tmp;
+               }
+           }
+       }
+      else
+       {
+         barycenterField = mesh->getBarycenter(Support);
+         const double * barycenter =
+           barycenterField->getValue(MED_NO_INTERLACE);
+
+         x = barycenter;
+         y = barycenter+NumberOfValues;
+         if (spaceDim == 3) z = y+NumberOfValues;
+       }
+
+      for (int i=0; i<NumberOfValues; i++)
+       {
+         double x_val = x[i];
+         double y_val = y[i];
+         double z_val = 0.0;
+
+         if (spaceDim == 2)
+           {
+           MESSAGE("debug ...... x = " << x_val << " y = " << y_val);
+           }
+         else if (spaceDim == 3)
+           {
+             z_val = z[i];
+             MESSAGE("debug ...... x = " << x_val << " y = " << y_val << " z = " << z_val);
+           }
+
+         PyObject * tuple;
+
+         if (spaceDim == 2) tuple = PyTuple_New(2);
+         else if (spaceDim == 3) tuple = PyTuple_New(3);
+
+         int index = 0;
+         int err = PyTuple_SetItem(tuple,index,Py_BuildValue("d",x_val));
+
+         if (err != 0)
+           throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic");
+
+         index = 1;
+         err = PyTuple_SetItem(tuple,index,Py_BuildValue("d",y_val));
+
+         if (err != 0)
+           throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic");
+
+         if (spaceDim == 3)
+           {
+             index = 2;
+             err = PyTuple_SetItem(tuple,index,Py_BuildValue("d",z_val));
+
+             if (err != 0)
+               throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic");
+           }
+
+         PyObject * function_ret = PyObject_CallObject(double_function,
+                                                       tuple);
+
+         SCRUTE(function_ret);
+
+         if ((function_ret == (PyObject *) NULL) && (spaceDim == 2))
+           throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its API (double, double))");
+         else if ((function_ret == (PyObject *) NULL) && (spaceDim == 3))
+           throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its API (double, double, double))");
+
+         err = PyList_Check(function_ret);
+
+         if (!err)
+           if (spaceDim == 2)
+             {
+               Py_DECREF(function_ret);
+               throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its API list of double fonct (double, double))");
+             }
+           else if (spaceDim == 3)
+             {
+               Py_DECREF(function_ret);
+               throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its API list of double fonct (double, double, double))");
+             }
+
+         int size = PyList_Size(function_ret);
+
+         if (size != NumberOfComponents)
+           if (spaceDim == 2)
+             {
+               Py_DECREF(function_ret);
+               throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its API list of double fonct (double, double), especially the size of the returned list)");
+             }
+           else if (spaceDim == 3)
+             {
+               Py_DECREF(function_ret);
+               throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its API list of double fonct (double, double, double), especially the size of the returned list)");
+             }
+
+         for (int j=0; j<NumberOfComponents; j++)
+           {
+             PyObject * tmp = PyList_GetItem(function_ret,j);
+
+             err = PyFloat_Check(tmp);
+
+             if (!err)
+               if (spaceDim == 2)
+                 {
+                   Py_DECREF(function_ret);
+                   throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its API list of double fonct (double, double), especially the type of the returned list)");
+                 }
+               else if (spaceDim == 3)
+                 {
+                   Py_DECREF(function_ret);
+                   throw MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its API list of double fonct (double, double, double), especially the type of the returned list)");
+                 }
+
+             values[i*NumberOfComponents+j] = PyFloat_AsDouble(tmp);
+           }
+
+         Py_DECREF(function_ret);
+         Py_DECREF(tuple);
+       }
+
+      fieldDouble->setValue(MED_FULL_INTERLACE,values);
+
+      delete [] values;
+
+      if ((entity == MED_NODE) && (!onAll))
+       {
+         delete [] x;
+         delete [] y;
+
+         if (Support->getMesh()->getSpaceDimension() == 3)
+           delete [] z;
+       }
+      else if (entity != MED_NODE) delete barycenterField ;
+
+      return fieldDouble;
+    }
+
+  FIELDINT * createFieldIntFromAnalytic(SUPPORT * Support,
+                                       int NumberOfComponents,
+                                       PyObject * integer_function)
+    {
+      MESSAGE("createFieldIntFromAnalytic : Constructor (for Python API) FIELDINT from an analytic fonction");
+
+      FIELDINT * fieldInt = new FIELDINT(Support,NumberOfComponents);
+
+      int NumberOfValues = fieldInt->getNumberOfValues();
+      int * values = new int[NumberOfValues*NumberOfComponents];
+
+      const double * x = (const double *) NULL;
+      const double * y = (const double *) NULL;
+      const double * z = (const double *) NULL;
+
+      FIELD<double> * barycenterField = (FIELD<double> *) NULL;
+
+      medEntityMesh entity = Support->getEntity();
+      bool onAll = Support->isOnAllElements();
+
+      MESH * mesh = Support->getMesh();
+      int spaceDim = mesh->getSpaceDimension();
+
+      if (entity == MED_NODE)
+       {
+         if (onAll)
+           {
+             const double * coord = mesh->getCoordinates(MED_NO_INTERLACE);
+
+             x = coord;
+             y = coord+NumberOfValues;
+             if (spaceDim == 3) z = y+NumberOfValues;
+           }
+         else
+           {
+             const int * nodesNumber = Support->getNumber(MED_ALL_ELEMENTS);
+             const double * coord = mesh->getCoordinates(MED_FULL_INTERLACE);
+
+             double * x_tmp = new double [NumberOfValues];
+             double * y_tmp = new double [NumberOfValues];
+
+             for (int i=0; i<NumberOfValues; i++)
+               {
+                 int j = nodesNumber[i]*spaceDim;
+                 x_tmp[i] = coord[j];
+                 y_tmp[i] = coord[j+1];
+               }
+
+             x = x_tmp;
+             y = y_tmp;
+
+             if (spaceDim == 3)
+               {
+                 double * z_tmp = new double [NumberOfValues];
+
+                 for (int i=0; i<NumberOfValues; i++)
+                   {
+                     int j = nodesNumber[i]*spaceDim + 2;
+                     z_tmp[i] = coord[j];
+                   }
+
+                 z = z_tmp;
+               }
+           }
+       }
+      else
+       {
+         barycenterField = mesh->getBarycenter(Support);
+         const double * barycenter =
+           barycenterField->getValue(MED_NO_INTERLACE);
+
+         x = barycenter;
+         y = barycenter+NumberOfValues;
+         if (spaceDim == 3) z = y+NumberOfValues;
+       }
+
+      for (int i=0; i<NumberOfValues; i++)
+       {
+         double x_val = x[i];
+         double y_val = y[i];
+         double z_val = 0.0;
+
+         if (spaceDim == 2)
+           {
+           MESSAGE("debug ...... x = " << x_val << " y = " << y_val);
+           }
+         else if (spaceDim == 3)
+           {
+             z_val = z[i];
+             MESSAGE("debug ...... x = " << x_val << " y = " << y_val << " z = " << z_val);
+           }
+
+         PyObject * tuple;
+
+         if (spaceDim == 2) tuple = PyTuple_New(2);
+         else if (spaceDim == 3) tuple = PyTuple_New(3);
+
+         int index = 0;
+         int err = PyTuple_SetItem(tuple,index,Py_BuildValue("d",x_val));
+
+         if (err != 0)
+           throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic");
+
+         index = 1;
+         err = PyTuple_SetItem(tuple,index,Py_BuildValue("d",y_val));
+
+         if (err != 0)
+           throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic");
+
+         if (spaceDim == 3)
+           {
+             index = 2;
+             err = PyTuple_SetItem(tuple,index,Py_BuildValue("d",z_val));
+
+             if (err != 0)
+               throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic");
+           }
+
+         PyObject * function_ret = PyObject_CallObject(integer_function,
+                                                       tuple);
+
+         if ((function_ret == (PyObject *) NULL) && (spaceDim == 2))
+           throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API (double, double))");
+         else if ((function_ret == (PyObject *) NULL) && (spaceDim == 3))
+           throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API (double, double, double))");
+
+         err = PyList_Check(function_ret);
+
+         if (!err)
+           if (spaceDim == 2)
+             {
+               Py_DECREF(function_ret);
+               throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API list of integer fonct (double, double))");
+             }
+           else if (spaceDim == 3)
+             {
+               Py_DECREF(function_ret);
+               throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API list of integer fonct (double, double, double))");
+             }
+
+         int size = PyList_Size(function_ret);
+
+         if (size != NumberOfComponents)
+           if (spaceDim == 2)
+             {
+               Py_DECREF(function_ret);
+               throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API list of integer fonct (double, double), especially the size of the returned list)");
+             }
+           else if (spaceDim == 3)
+             {
+               Py_DECREF(function_ret);
+               throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API list of integer fonct (double, double, double), especially the size of the returned list)");
+             }
+
+         for (int j=0; j<NumberOfComponents; j++)
+           {
+             PyObject * tmp = PyList_GetItem(function_ret,j);
+
+             err = PyInt_Check(tmp);
+
+             if (!err)
+               if (spaceDim == 2)
+                 {
+                   Py_DECREF(function_ret);
+                   throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API list of integer fonct (double, double), especially the type of the returned list)");
+                 }
+               else if (spaceDim == 3)
+                 {
+                   Py_DECREF(function_ret);
+                   throw MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (check its API list of integer fonct (double, double, double), especially the type of the returned list)");
+                 }
+
+             values[i*NumberOfComponents+j] = (int) PyInt_AsLong(tmp);
+           }
+
+         Py_DECREF(function_ret);
+         Py_DECREF(tuple);
+       }
+
+      fieldInt->setValue(MED_FULL_INTERLACE,values);
+
+      delete [] values;
+
+      if ((entity == MED_NODE) && (!onAll))
+       {
+         delete [] x;
+         delete [] y;
+
+         if (Support->getMesh()->getSpaceDimension() == 3)
+           delete [] z;
+       }
+      else if (entity != MED_NODE) delete barycenterField ;
+
+      return fieldInt;
+    }
+
   GRID * createGridFromMesh( MESH * aMesh )
     {
       MESSAGE("createGridFromMesh : Constructor (for Python API) GRID with parameter MESH *");
index dac89e76a65b2e0d3c86fe8c1d4863a3ea113ecf..63090c50ec9130d23c1e889e49e8608a13ddcc5c 100644 (file)
@@ -1,11 +1,11 @@
-#  MED MEDMEM_SWIG : binding of C++ implementation and Python
+###################################################################################
 #
-#  Copyright (C) 2003  CEA/DEN, EDF R&D
+# This Python script uses the wrapped C++ class MESHING to buid a mesh from only
+# primitive data like coordinates (Pythoin double array) and connectivity (Python
+# integer arrays). It is the Python equivalent of the C++ program
+# test_MEDMEM_Meshing.cxx in the ../MEDMEM directory of the SALOME distribution
 #
-#
-#
-#  File   : medMeshing_test.py
-#  Module : MED
+###################################################################################
 
 from libMEDMEM_Swig import *
 
@@ -245,12 +245,399 @@ myMeshing.setConnectivity(connectivityHexa,entity,types[2])
 
 # face part
 
+numberOfTypes = 2
+entity = MED_FACE
+
+types = []
+numberOfElements = []
+
+types.append(MED_TRIA3)
+numberOfElements.append(4)
+
+types.append(MED_QUAD4)
+numberOfElements.append(4)
+
+myMeshing.setNumberOfTypes(numberOfTypes,entity)
+myMeshing.setTypes(types,entity)
+myMeshing.setNumberOfElements(numberOfElements,entity)
+
+connectivityTria = []
+connectivity =  [1,4,3]
+connectivityTria.append(connectivity[0])
+connectivityTria.append(connectivity[1])
+connectivityTria.append(connectivity[2])
+connectivity =  [1,5,4]
+connectivityTria.append(connectivity[0])
+connectivityTria.append(connectivity[1])
+connectivityTria.append(connectivity[2])
+connectivity =  [1,6,5]
+connectivityTria.append(connectivity[0])
+connectivityTria.append(connectivity[1])
+connectivityTria.append(connectivity[2])
+connectivity =  [1,3,6]
+connectivityTria.append(connectivity[0])
+connectivityTria.append(connectivity[1])
+connectivityTria.append(connectivity[2])
+
+myMeshing.setConnectivity(connectivityTria,entity,types[0])
+
+connectivityQuad = []
+connectivity =  [7,8,9,10]
+connectivityQuad.append(connectivity[0])
+connectivityQuad.append(connectivity[1])
+connectivityQuad.append(connectivity[2])
+connectivityQuad.append(connectivity[3])
+connectivity =  [11,12,13,14]
+connectivityQuad.append(connectivity[0])
+connectivityQuad.append(connectivity[1])
+connectivityQuad.append(connectivity[2])
+connectivityQuad.append(connectivity[3])
+connectivity =  [11,7,8,12]
+connectivityQuad.append(connectivity[0])
+connectivityQuad.append(connectivity[1])
+connectivityQuad.append(connectivity[2])
+connectivityQuad.append(connectivity[3])
+connectivity =  [12,8,9,13]
+connectivityQuad.append(connectivity[0])
+connectivityQuad.append(connectivity[1])
+connectivityQuad.append(connectivity[2])
+connectivityQuad.append(connectivity[3])
+
+myMeshing.setConnectivity(connectivityQuad,entity,types[1])
+
 # edge part
 
 # saving of the generated mesh in MED and VTK format
 
+# adding GROUPs
+# on Node
+
+myGroup = GROUP()
+myGroup.setName("SomeNodes")
+myGroup.setMesh(myMeshing)
+myGroup.setEntity(MED_NODE)
+myGroup.setNumberOfGeometricType(1)
+
+myTypes = [MED_NONE]
+myGroup.setGeometricType(myTypes)
+
+myNumberOfElements = [4]
+myGroup.setNumberOfElements(myNumberOfElements)
+
+index = [1,5]
+values = [1,4,5,7]
+myGroup.setNumber(index,values)
+
+myMeshing.addGroup(myGroup)
+
+myGroup = GROUP()
+myGroup.setName("OtherNodes")
+myGroup.setMesh(myMeshing)
+myGroup.setEntity(MED_NODE)
+myGroup.setNumberOfGeometricType(1)
+
+myTypes = [MED_NONE]
+myGroup.setGeometricType(myTypes)
+
+myNumberOfElements = [3]
+myGroup.setNumberOfElements(myNumberOfElements)
+
+index = [1,4]
+values = [2,3,6]
+myGroup.setNumber(index,values)
+
+myMeshing.addGroup(myGroup)
+
+# on Cell
+
+myGroup = GROUP()
+myGroup.setName("SomeCells")
+myGroup.setMesh(myMeshing)
+myGroup.setEntity(MED_CELL)
+myGroup.setNumberOfGeometricType(3)
+
+myTypes = [MED_TETRA4,MED_PYRA5,MED_HEXA8]
+myGroup.setGeometricType(myTypes)
+
+myNumberOfElements = [4,1,2]
+myGroup.setNumberOfElements(myNumberOfElements)
+
+index = [1,5,6,8]
+values = [
+    2,7,8,12,
+    13,
+    15,16
+    ]
+myGroup.setNumber(index,values)
+
+myMeshing.addGroup(myGroup)
+
+myGroup = GROUP()
+myGroup.setName("OtherCells")
+myGroup.setMesh(myMeshing)
+myGroup.setEntity(MED_CELL)
+myGroup.setNumberOfGeometricType(2)
+
+myTypes = [MED_TETRA4,MED_PYRA5]
+myGroup.setGeometricType(myTypes)
+
+myNumberOfElements = [4,1]
+myGroup.setNumberOfElements(myNumberOfElements)
+
+index = [1,5,6]
+values = [
+    3,4,5,9,
+    14
+    ]
+myGroup.setNumber(index,values)
+
+myMeshing.addGroup(myGroup)
+
+# on Face
+
+myGroup = GROUP()
+myGroup.setName("SomeFaces")
+myGroup.setMesh(myMeshing)
+myGroup.setEntity(MED_FACE)
+myGroup.setNumberOfGeometricType(2)
+
+myTypes = [MED_TRIA3,MED_QUAD4]
+myGroup.setGeometricType(myTypes)
+
+myNumberOfElements = [2,3]
+myGroup.setNumberOfElements(myNumberOfElements)
+
+index = [1,3,6]
+values = [
+    2,4,
+    5,6,8
+    ]
+myGroup.setNumber(index,values)
+
+myMeshing.addGroup(myGroup)
+
+myGroup = GROUP()
+myGroup.setName("OtherFaces")
+myGroup.setMesh(myMeshing)
+myGroup.setEntity(MED_FACE)
+myGroup.setNumberOfGeometricType(1)
+
+myTypes = [MED_TRIA3]
+myGroup.setGeometricType(myTypes)
+
+myNumberOfElements = [2]
+myGroup.setNumberOfElements(myNumberOfElements)
+
+index = [1,3]
+values = [
+    1,3
+    ]
+myGroup.setNumber(index,values)
+
+myMeshing.addGroup(myGroup)
+
 idMed = myMeshing.addDriver(MED_DRIVER,medFileName,myMeshing.getName())
 myMeshing.write(idMed)
 
-idVtk = myMeshing.addDriver(MED_DRIVER,vtkFileName,myMeshing.getName())
+idVtk = myMeshing.addDriver(VTK_DRIVER,vtkFileName,myMeshing.getName())
 myMeshing.write(idVtk)
+
+# we build now 8 fields : 4 fields double (integer) :
+#                         2 fields on nodes (cells) :
+#                         1 scalar (vector)
+
+supportOnNodes = SUPPORT(myMeshing,"On_All_Nodes",MED_NODE)
+numberOfNodes = supportOnNodes.getNumberOfElements(MED_ALL_ELEMENTS)
+
+supportOnCells = SUPPORT(myMeshing,"On_All_Cells",MED_CELL)
+numberOfCells = supportOnCells.getNumberOfElements(MED_ALL_ELEMENTS)
+
+fieldDoubleScalarOnNodes = FIELDDOUBLE(supportOnNodes,1)
+fieldDoubleScalarOnNodes.setName("fieldScalarDoubleNode")
+fieldDoubleScalarOnNodes.setIterationNumber(-1)
+fieldDoubleScalarOnNodes.setOrderNumber(-1)
+fieldDoubleScalarOnNodes.setTime(0.0)
+
+fieldDoubleScalarOnNodes.setComponentName(1,"Vx")
+fieldDoubleScalarOnNodes.setComponentDescription(1,"comp1")
+fieldDoubleScalarOnNodes.setMEDComponentUnit(1,"unit1")
+
+fieldDoubleVectorOnNodes = FIELDDOUBLE(supportOnNodes,spaceDimension)
+fieldDoubleVectorOnNodes.setName("fieldVectorDoubleNode")
+fieldDoubleVectorOnNodes.setIterationNumber(-1)
+fieldDoubleVectorOnNodes.setOrderNumber(-1)
+fieldDoubleVectorOnNodes.setTime(0.0)
+
+fieldDoubleVectorOnNodes.setComponentName(1,"Vx")
+fieldDoubleVectorOnNodes.setComponentDescription(1,"comp1")
+fieldDoubleVectorOnNodes.setMEDComponentUnit(1,"unit1")
+fieldDoubleVectorOnNodes.setComponentName(2,"Vy")
+fieldDoubleVectorOnNodes.setComponentDescription(2,"comp2")
+fieldDoubleVectorOnNodes.setMEDComponentUnit(2,"unit2")
+fieldDoubleVectorOnNodes.setComponentName(3,"Vz")
+fieldDoubleVectorOnNodes.setComponentDescription(3,"comp3")
+fieldDoubleVectorOnNodes.setMEDComponentUnit(3,"unit3")
+
+fieldDoubleScalarOnCells = FIELDDOUBLE(supportOnCells,1)
+fieldDoubleScalarOnCells.setName("fieldScalarDoubleCell")
+fieldDoubleScalarOnCells.setIterationNumber(-1)
+fieldDoubleScalarOnCells.setOrderNumber(-1)
+fieldDoubleScalarOnCells.setTime(0.0)
+
+fieldDoubleScalarOnCells.setComponentName(1,"Vx")
+fieldDoubleScalarOnCells.setComponentDescription(1,"comp1")
+fieldDoubleScalarOnCells.setMEDComponentUnit(1,"unit1")
+
+fieldDoubleVectorOnCells = FIELDDOUBLE(supportOnCells,spaceDimension)
+fieldDoubleVectorOnCells.setName("fieldVectorrDoubleCell")
+fieldDoubleVectorOnCells.setIterationNumber(-1)
+fieldDoubleVectorOnCells.setOrderNumber(-1)
+fieldDoubleVectorOnCells.setTime(0.0)
+
+fieldDoubleVectorOnCells.setComponentName(1,"Vx")
+fieldDoubleVectorOnCells.setComponentDescription(1,"comp1")
+fieldDoubleVectorOnCells.setMEDComponentUnit(1,"unit1")
+fieldDoubleVectorOnCells.setComponentName(2,"Vy")
+fieldDoubleVectorOnCells.setComponentDescription(2,"comp2")
+fieldDoubleVectorOnCells.setMEDComponentUnit(2,"unit2")
+fieldDoubleVectorOnCells.setComponentName(3,"Vz")
+fieldDoubleVectorOnCells.setComponentDescription(3,"comp3")
+fieldDoubleVectorOnCells.setMEDComponentUnit(3,"unit3")
+
+fieldIntScalarOnNodes = FIELDINT(supportOnNodes,1)
+fieldIntScalarOnNodes.setName("fieldScalarIntNode")
+fieldIntScalarOnNodes.setIterationNumber(-1)
+fieldIntScalarOnNodes.setOrderNumber(-1)
+fieldIntScalarOnNodes.setTime(0.0)
+
+fieldIntScalarOnNodes.setComponentName(1,"Vx")
+fieldIntScalarOnNodes.setComponentDescription(1,"comp1")
+fieldIntScalarOnNodes.setMEDComponentUnit(1,"unit1")
+
+fieldIntVectorOnNodes = FIELDINT(supportOnNodes,spaceDimension)
+fieldIntVectorOnNodes.setName("fieldVectorIntNode")
+fieldIntVectorOnNodes.setIterationNumber(-1)
+fieldIntVectorOnNodes.setOrderNumber(-1)
+fieldIntVectorOnNodes.setTime(0.0)
+
+fieldIntVectorOnNodes.setComponentName(1,"Vx")
+fieldIntVectorOnNodes.setComponentDescription(1,"comp1")
+fieldIntVectorOnNodes.setMEDComponentUnit(1,"unit1")
+fieldIntVectorOnNodes.setComponentName(2,"Vy")
+fieldIntVectorOnNodes.setComponentDescription(2,"comp2")
+fieldIntVectorOnNodes.setMEDComponentUnit(2,"unit2")
+fieldIntVectorOnNodes.setComponentName(3,"Vz")
+fieldIntVectorOnNodes.setComponentDescription(3,"comp3")
+fieldIntVectorOnNodes.setMEDComponentUnit(3,"unit3")
+
+fieldIntScalarOnCells = FIELDINT(supportOnCells,1)
+fieldIntScalarOnCells.setName("fieldScalarIntCell")
+fieldIntScalarOnCells.setIterationNumber(-1)
+fieldIntScalarOnCells.setOrderNumber(-1)
+fieldIntScalarOnCells.setTime(0.0)
+
+fieldIntScalarOnCells.setComponentName(1,"Vx")
+fieldIntScalarOnCells.setComponentDescription(1,"comp1")
+fieldIntScalarOnCells.setMEDComponentUnit(1,"unit1")
+
+fieldIntVectorOnCells = FIELDINT(supportOnCells,spaceDimension)
+fieldIntVectorOnCells.setName("fieldVectorrIntCell")
+fieldIntVectorOnCells.setIterationNumber(-1)
+fieldIntVectorOnCells.setOrderNumber(-1)
+fieldIntVectorOnCells.setTime(0.0)
+
+fieldIntVectorOnCells.setComponentName(1,"Vx")
+fieldIntVectorOnCells.setComponentDescription(1,"comp1")
+fieldIntVectorOnCells.setMEDComponentUnit(1,"unit1")
+fieldIntVectorOnCells.setComponentName(2,"Vy")
+fieldIntVectorOnCells.setComponentDescription(2,"comp2")
+fieldIntVectorOnCells.setMEDComponentUnit(2,"unit2")
+fieldIntVectorOnCells.setComponentName(3,"Vz")
+fieldIntVectorOnCells.setComponentDescription(3,"comp3")
+fieldIntVectorOnCells.setMEDComponentUnit(3,"unit3")
+
+for i in range(numberOfNodes):
+    valueInt1 = i+1
+    valueInt2 = i+2
+    valueInt3 = i+3
+    valueDbl1 = valueInt1*0.1
+    valueDbl2 = valueInt2*0.1
+    valueDbl3 = valueInt3*0.1
+    fieldDoubleScalarOnNodes.setValueIJ(i+1,1,valueDbl1)
+
+    fieldIntScalarOnNodes.setValueIJ(i+1,1,valueInt1)
+
+    fieldDoubleVectorOnNodes.setValueIJ(i+1,1,valueDbl1)
+    fieldDoubleVectorOnNodes.setValueIJ(i+1,2,valueDbl2)
+    fieldDoubleVectorOnNodes.setValueIJ(i+1,3,valueDbl3)
+
+    fieldIntVectorOnNodes.setValueIJ(i+1,1,valueInt1)
+    fieldIntVectorOnNodes.setValueIJ(i+1,2,valueInt2)
+    fieldIntVectorOnNodes.setValueIJ(i+1,3,valueInt3)
+
+for i in range(numberOfCells):
+    valueInt1 = i+1
+    valueInt2 = i+2
+    valueInt3 = i+3
+    valueDbl1 = valueInt1*0.1
+    valueDbl2 = valueInt2*0.1
+    valueDbl3 = valueInt3*0.1
+    fieldDoubleScalarOnCells.setValueIJ(i+1,1,valueDbl1)
+
+    fieldIntScalarOnCells.setValueIJ(i+1,1,valueInt1)
+
+    fieldDoubleVectorOnCells.setValueIJ(i+1,1,valueDbl1)
+    fieldDoubleVectorOnCells.setValueIJ(i+1,2,valueDbl2)
+    fieldDoubleVectorOnCells.setValueIJ(i+1,3,valueDbl3)
+
+    fieldIntVectorOnCells.setValueIJ(i+1,1,valueInt1)
+    fieldIntVectorOnCells.setValueIJ(i+1,2,valueInt2)
+    fieldIntVectorOnCells.setValueIJ(i+1,3,valueInt3)
+
+idMed = fieldDoubleScalarOnNodes.addDriver(MED_DRIVER,medFileName,fieldDoubleScalarOnNodes.getName())
+fieldDoubleScalarOnNodes.write(idMed)
+
+idMed = fieldIntScalarOnNodes.addDriver(MED_DRIVER,medFileName,fieldIntScalarOnNodes.getName())
+fieldIntScalarOnNodes.write(idMed)
+
+idMed = fieldDoubleVectorOnNodes.addDriver(MED_DRIVER,medFileName,fieldDoubleVectorOnNodes.getName())
+fieldDoubleVectorOnNodes.write(idMed)
+
+idMed = fieldIntVectorOnNodes.addDriver(MED_DRIVER,medFileName,fieldIntVectorOnNodes.getName())
+fieldIntVectorOnNodes.write(idMed)
+
+idMed = fieldDoubleScalarOnCells.addDriver(MED_DRIVER,medFileName,fieldDoubleScalarOnCells.getName())
+fieldDoubleScalarOnCells.write(idMed)
+
+idMed = fieldIntScalarOnCells.addDriver(MED_DRIVER,medFileName,fieldIntScalarOnCells.getName())
+fieldIntScalarOnCells.write(idMed)
+
+idMed = fieldDoubleVectorOnCells.addDriver(MED_DRIVER,medFileName,fieldDoubleVectorOnCells.getName())
+fieldDoubleVectorOnCells.write(idMed)
+
+idMed = fieldIntVectorOnCells.addDriver(MED_DRIVER,medFileName,fieldIntVectorOnCells.getName())
+fieldIntVectorOnCells.write(idMed)
+
+idVtk = fieldDoubleScalarOnNodes.addDriver(VTK_DRIVER,vtkFileName,fieldDoubleScalarOnNodes.getName())
+fieldDoubleScalarOnNodes.writeAppend(idVtk)
+
+idVtk = fieldIntScalarOnNodes.addDriver(VTK_DRIVER,vtkFileName,fieldIntScalarOnNodes.getName())
+fieldIntScalarOnNodes.writeAppend(idVtk)
+
+idVtk = fieldDoubleVectorOnNodes.addDriver(VTK_DRIVER,vtkFileName,fieldDoubleVectorOnNodes.getName())
+fieldDoubleVectorOnNodes.writeAppend(idVtk)
+
+idVtk = fieldIntVectorOnNodes.addDriver(VTK_DRIVER,vtkFileName,fieldIntVectorOnNodes.getName())
+fieldIntVectorOnNodes.writeAppend(idVtk)
+
+idVtk = fieldDoubleScalarOnCells.addDriver(VTK_DRIVER,vtkFileName,fieldDoubleScalarOnCells.getName())
+fieldDoubleScalarOnCells.writeAppend(idVtk)
+
+idVtk = fieldIntScalarOnCells.addDriver(VTK_DRIVER,vtkFileName,fieldIntScalarOnCells.getName())
+fieldIntScalarOnCells.writeAppend(idVtk)
+
+idVtk = fieldDoubleVectorOnCells.addDriver(VTK_DRIVER,vtkFileName,fieldDoubleVectorOnCells.getName())
+fieldDoubleVectorOnCells.writeAppend(idVtk)
+
+idVtk = fieldIntVectorOnCells.addDriver(VTK_DRIVER,vtkFileName,fieldIntVectorOnCells.getName())
+fieldIntVectorOnCells.writeAppend(idVtk)
diff --git a/src/MEDMEM_SWIG/med_field_anal.py b/src/MEDMEM_SWIG/med_field_anal.py
new file mode 100755 (executable)
index 0000000..b250f15
--- /dev/null
@@ -0,0 +1,568 @@
+############################################################################
+#
+# This Python script is testing the generation of MED field using a
+# user-callable function with different number of components and
+# different SUPPORTs.
+#
+############################################################################
+
+from math import *
+
+def f_scal_dbl_2d(x, y):
+    ret = []
+    ret.append(x + y)
+    return ret
+
+def f_scal_dbl_3d(x, y, z):
+    ret = []
+    ret.append(x + y + z)
+    return ret
+
+def f_vect_dbl_2d(x, y):
+    ret = []
+    ret.append(x + y)
+    ret.append(2.*(x + y))
+    return ret
+
+def f_vect_dbl_3d(x, y, z):
+    ret = []
+    ret.append(x + y + z)
+    ret.append(2.*(x + y + z))
+    ret.append(3.*(x + y + z))
+    return ret
+
+def f_scal_int_2d(x, y):
+    ret = []
+    ret_tmp = x + y
+    ret_tmp = int(ret_tmp)
+    ret.append(ret_tmp)
+    return ret
+
+def f_scal_int_3d(x, y, z):
+    ret = []
+    ret_tmp = x + y + z
+    ret_tmp = int(ret_tmp)
+    ret.append(ret_tmp)
+    return ret
+
+def f_vect_int_2d(x, y):
+    ret = []
+    ret.append(int(x + y))
+    ret.append(int(2.*(x + y)))
+    return ret
+
+def f_vect_int_3d(x, y, z):
+    ret = []
+    ret.append(int(x + y + z))
+    ret.append(int(2.*(x + y + z)))
+    ret.append(int(3.*(x + y + z)))
+    return ret
+
+from libMEDMEM_Swig import *
+from random import *
+
+medFile = "carre_en_quad4_seg2.med"
+medFile = "cube_hexa8_quad4.med"
+
+def print_ord(i):
+    if i == 0:
+        return 'first'
+    elif i == 1:
+        return 'second'
+    elif i == 2:
+        return 'third'
+    else:
+        return `i`+'th'
+
+md = MED()
+
+mdDriver = MED_MED_RDONLY_DRIVER(medFile,md)
+
+mdDriver.open()
+mdDriver.readFileStruct()
+mdDriver.close()
+
+nbMeshes = md.getNumberOfMeshes()
+
+print "The med file", medFile, "contains", nbMeshes, "mesh(es)"
+
+mesh_name = md.getMeshName(0)
+mesh = md.getMesh(mesh_name)
+mesh.read()
+spaceDim = mesh.getSpaceDimension()
+meshDim = mesh.getMeshDimension()
+nbNodes = mesh.getNumberOfNodes()
+
+print ""
+print "The mesh",mesh_name,"is a",spaceDim,"D mesh on a",meshDim,"D geometry and has",nbNodes,"Nodes"
+
+print ""
+print "Updating supports in the Med Object"
+md.updateSupport()
+
+supportOnCell = md.getSupport(mesh_name,MED_CELL)
+
+supportOnNode = md.getSupport(mesh_name,MED_NODE)
+
+if (spaceDim == 3) :
+    supportOnConst = md.getSupport(mesh_name,MED_FACE)
+elif (spaceDim == 2) :
+    supportOnConst = md.getSupport(mesh_name,MED_EDGE)
+
+##print ""
+##print supportOnCell
+
+if (spaceDim == 2) :
+    fieldDoubleScalOnCell = createFieldDoubleFromAnalytic(supportOnCell,1,
+                                                          f_scal_dbl_2d)
+    fieldDoubleVectOnCell = createFieldDoubleFromAnalytic(supportOnCell,
+                                                          spaceDim,
+                                                          f_vect_dbl_2d)
+    fieldIntScalOnCell = createFieldIntFromAnalytic(supportOnCell,1,
+                                                    f_scal_int_2d)
+    fieldIntVectOnCell = createFieldIntFromAnalytic(supportOnCell,spaceDim,
+                                                    f_vect_int_2d)
+elif (spaceDim == 3) :
+    fieldDoubleScalOnCell = createFieldDoubleFromAnalytic(supportOnCell,1,
+                                                          f_scal_dbl_3d)
+    fieldDoubleVectOnCell = createFieldDoubleFromAnalytic(supportOnCell,
+                                                          spaceDim,
+                                                          f_vect_dbl_3d)
+    fieldIntScalOnCell = createFieldIntFromAnalytic(supportOnCell,1,
+                                                    f_scal_int_3d)
+    fieldIntVectOnCell = createFieldIntFromAnalytic(supportOnCell,spaceDim,
+                                                    f_vect_int_3d)
+
+fieldDoubleScalOnCell.setName("Scalar Double Field on all Cells")
+fieldDoubleScalOnCell.setDescription("Generated via a Python function")
+
+fieldDoubleVectOnCell.setName("Vector Double Field on all Cells")
+fieldDoubleVectOnCell.setDescription("Generated via a Python function")
+
+fieldIntScalOnCell.setName("Scalar Integer Field on all Cells")
+fieldIntScalOnCell.setDescription("Generated via a Python function")
+
+fieldIntVectOnCell.setName("Vector Integer Field on all Cells")
+fieldIntVectOnCell.setDescription("Generated via a Python function")
+
+name = fieldDoubleScalOnCell.getName()
+desc = fieldDoubleScalOnCell.getDescription()
+nbOfComp = fieldDoubleScalOnCell.getNumberOfComponents()
+print "     Field",name," : ",desc
+print "     Number Of Components:",nbOfComp
+iterationNb = fieldDoubleScalOnCell.getIterationNumber()
+orderNb = fieldDoubleScalOnCell.getOrderNumber()
+time = fieldDoubleScalOnCell.getTime()
+print "     Iteration Number",iterationNb
+print "     Order Number",orderNb
+print "     Time",time
+for k in range(nbOfComp):
+    kp1 = k+1
+    compName = fieldDoubleScalOnCell.getComponentName(kp1)
+    compDesc = fieldDoubleScalOnCell.getComponentDescription(kp1)
+    compUnit = fieldDoubleScalOnCell.getMEDComponentUnit(kp1)
+    print "      * Component:",kp1
+    print "          Name:",compName
+    print "          Description:",compDesc
+    print "          Unit:",compUnit
+
+support = fieldDoubleScalOnCell.getSupport()
+nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+print "     Values:",nbOf
+for k in range(nbOf):
+    valueI = fieldDoubleScalOnCell.getValueI(MED_FULL_INTERLACE,k+1)
+    print "     *",valueI[:nbOfComp]
+
+print ""
+name = fieldDoubleVectOnCell.getName()
+desc = fieldDoubleVectOnCell.getDescription()
+nbOfComp = fieldDoubleVectOnCell.getNumberOfComponents()
+print "     Field",name," : ",desc
+print "     Number Of Components:",nbOfComp
+iterationNb = fieldDoubleVectOnCell.getIterationNumber()
+orderNb = fieldDoubleVectOnCell.getOrderNumber()
+time = fieldDoubleVectOnCell.getTime()
+print "     Iteration Number",iterationNb
+print "     Order Number",orderNb
+print "     Time",time
+for k in range(nbOfComp):
+    kp1 = k+1
+    compName = fieldDoubleVectOnCell.getComponentName(kp1)
+    compDesc = fieldDoubleVectOnCell.getComponentDescription(kp1)
+    compUnit = fieldDoubleVectOnCell.getMEDComponentUnit(kp1)
+    print "      * Component:",kp1
+    print "          Name:",compName
+    print "          Description:",compDesc
+    print "          Unit:",compUnit
+
+support = fieldDoubleVectOnCell.getSupport()
+nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+print "     Values:",nbOf
+for k in range(nbOf):
+    valueI = fieldDoubleVectOnCell.getValueI(MED_FULL_INTERLACE,k+1)
+    print "     *",valueI[:nbOfComp]
+
+print ""
+name = fieldIntScalOnCell.getName()
+desc = fieldIntScalOnCell.getDescription()
+nbOfComp = fieldIntScalOnCell.getNumberOfComponents()
+print "     Field",name," : ",desc
+print "     Number Of Components:",nbOfComp
+iterationNb = fieldIntScalOnCell.getIterationNumber()
+orderNb = fieldIntScalOnCell.getOrderNumber()
+time = fieldIntScalOnCell.getTime()
+print "     Iteration Number",iterationNb
+print "     Order Number",orderNb
+print "     Time",time
+for k in range(nbOfComp):
+    kp1 = k+1
+    compName = fieldIntScalOnCell.getComponentName(kp1)
+    compDesc = fieldIntScalOnCell.getComponentDescription(kp1)
+    compUnit = fieldIntScalOnCell.getMEDComponentUnit(kp1)
+    print "      * Component:",kp1
+    print "          Name:",compName
+    print "          Description:",compDesc
+    print "          Unit:",compUnit
+
+support = fieldIntScalOnCell.getSupport()
+nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+print "     Values:",nbOf
+for k in range(nbOf):
+    valueI = fieldIntScalOnCell.getValueI(MED_FULL_INTERLACE,k+1)
+    print "     *",valueI[:nbOfComp]
+
+print ""
+name = fieldIntVectOnCell.getName()
+desc = fieldIntVectOnCell.getDescription()
+nbOfComp = fieldIntVectOnCell.getNumberOfComponents()
+print "     Field",name," : ",desc
+print "     Number Of Components:",nbOfComp
+iterationNb = fieldIntVectOnCell.getIterationNumber()
+orderNb = fieldIntVectOnCell.getOrderNumber()
+time = fieldIntVectOnCell.getTime()
+print "     Iteration Number",iterationNb
+print "     Order Number",orderNb
+print "     Time",time
+for k in range(nbOfComp):
+    kp1 = k+1
+    compName = fieldIntVectOnCell.getComponentName(kp1)
+    compDesc = fieldIntVectOnCell.getComponentDescription(kp1)
+    compUnit = fieldIntVectOnCell.getMEDComponentUnit(kp1)
+    print "      * Component:",kp1
+    print "          Name:",compName
+    print "          Description:",compDesc
+    print "          Unit:",compUnit
+
+support = fieldIntVectOnCell.getSupport()
+nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+print "     Values:",nbOf
+for k in range(nbOf):
+    valueI = fieldIntVectOnCell.getValueI(MED_FULL_INTERLACE,k+1)
+    print "     *",valueI[:nbOfComp]
+
+##print ""
+##print supportOnNode
+
+if (spaceDim == 2) :
+    fieldDoubleScalOnNode = createFieldDoubleFromAnalytic(supportOnNode,1,
+                                                          f_scal_dbl_2d)
+    fieldDoubleVectOnNode = createFieldDoubleFromAnalytic(supportOnNode,
+                                                          spaceDim,
+                                                          f_vect_dbl_2d)
+    fieldIntScalOnNode = createFieldIntFromAnalytic(supportOnNode,1,
+                                                    f_scal_int_2d)
+    fieldIntVectOnNode = createFieldIntFromAnalytic(supportOnNode, spaceDim,
+                                                    f_vect_int_2d)
+elif (spaceDim == 3) :
+    fieldDoubleScalOnNode = createFieldDoubleFromAnalytic(supportOnNode,1,
+                                                          f_scal_dbl_3d)
+    fieldDoubleVectOnNode = createFieldDoubleFromAnalytic(supportOnNode,
+                                                          spaceDim,
+                                                          f_vect_dbl_3d)
+    fieldIntScalOnNode = createFieldIntFromAnalytic(supportOnNode,1,
+                                                    f_scal_int_3d)
+    fieldIntVectOnNode = createFieldIntFromAnalytic(supportOnNode, spaceDim,
+                                                    f_vect_int_3d)
+
+fieldDoubleScalOnNode.setName("Scalar Double Field on all Nodes")
+fieldDoubleScalOnNode.setDescription("Generated via a Python function")
+
+fieldDoubleVectOnNode.setName("Vector Double Field on all Nodes")
+fieldDoubleVectOnNode.setDescription("Generated via a Python function")
+
+fieldIntScalOnNode.setName("Scalar Integer Field on all Nodes")
+fieldIntScalOnNode.setDescription("Generated via a Python function")
+
+fieldIntVectOnNode.setName("Vector Integer Field on all Nodes")
+fieldIntVectOnNode.setDescription("Generated via a Python function")
+
+print ""
+name = fieldDoubleScalOnNode.getName()
+desc = fieldDoubleScalOnNode.getDescription()
+nbOfComp = fieldDoubleScalOnNode.getNumberOfComponents()
+print "     Field",name," : ",desc
+print "     Number Of Components:",nbOfComp
+iterationNb = fieldDoubleScalOnNode.getIterationNumber()
+orderNb = fieldDoubleScalOnNode.getOrderNumber()
+time = fieldDoubleScalOnNode.getTime()
+print "     Iteration Number",iterationNb
+print "     Order Number",orderNb
+print "     Time",time
+for k in range(nbOfComp):
+    kp1 = k+1
+    compName = fieldDoubleScalOnNode.getComponentName(kp1)
+    compDesc = fieldDoubleScalOnNode.getComponentDescription(kp1)
+    compUnit = fieldDoubleScalOnNode.getMEDComponentUnit(kp1)
+    print "      * Component:",kp1
+    print "          Name:",compName
+    print "          Description:",compDesc
+    print "          Unit:",compUnit
+
+support = fieldDoubleScalOnNode.getSupport()
+nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+print "     Values:",nbOf
+for k in range(nbOf):
+    valueI = fieldDoubleScalOnNode.getValueI(MED_FULL_INTERLACE,k+1)
+    print "     *",valueI[:nbOfComp]
+
+print ""
+name = fieldDoubleVectOnNode.getName()
+desc = fieldDoubleVectOnNode.getDescription()
+nbOfComp = fieldDoubleVectOnNode.getNumberOfComponents()
+print "     Field",name," : ",desc
+print "     Number Of Components:",nbOfComp
+iterationNb = fieldDoubleVectOnNode.getIterationNumber()
+orderNb = fieldDoubleVectOnNode.getOrderNumber()
+time = fieldDoubleVectOnNode.getTime()
+print "     Iteration Number",iterationNb
+print "     Order Number",orderNb
+print "     Time",time
+for k in range(nbOfComp):
+    kp1 = k+1
+    compName = fieldDoubleVectOnNode.getComponentName(kp1)
+    compDesc = fieldDoubleVectOnNode.getComponentDescription(kp1)
+    compUnit = fieldDoubleVectOnNode.getMEDComponentUnit(kp1)
+    print "      * Component:",kp1
+    print "          Name:",compName
+    print "          Description:",compDesc
+    print "          Unit:",compUnit
+
+support = fieldDoubleVectOnNode.getSupport()
+nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+print "     Values:",nbOf
+for k in range(nbOf):
+    valueI = fieldDoubleVectOnNode.getValueI(MED_FULL_INTERLACE,k+1)
+    print "     *",valueI[:nbOfComp]
+
+print ""
+name = fieldIntScalOnNode.getName()
+desc = fieldIntScalOnNode.getDescription()
+nbOfComp = fieldIntScalOnNode.getNumberOfComponents()
+print "     Field",name," : ",desc
+print "     Number Of Components:",nbOfComp
+iterationNb = fieldIntScalOnNode.getIterationNumber()
+orderNb = fieldIntScalOnNode.getOrderNumber()
+time = fieldIntScalOnNode.getTime()
+print "     Iteration Number",iterationNb
+print "     Order Number",orderNb
+print "     Time",time
+for k in range(nbOfComp):
+    kp1 = k+1
+    compName = fieldIntScalOnNode.getComponentName(kp1)
+    compDesc = fieldIntScalOnNode.getComponentDescription(kp1)
+    compUnit = fieldIntScalOnNode.getMEDComponentUnit(kp1)
+    print "      * Component:",kp1
+    print "          Name:",compName
+    print "          Description:",compDesc
+    print "          Unit:",compUnit
+
+support = fieldIntScalOnNode.getSupport()
+nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+print "     Values:",nbOf
+for k in range(nbOf):
+    valueI = fieldIntScalOnNode.getValueI(MED_FULL_INTERLACE,k+1)
+    print "     *",valueI[:nbOfComp]
+
+print ""
+name = fieldIntVectOnNode.getName()
+desc = fieldIntVectOnNode.getDescription()
+nbOfComp = fieldIntVectOnNode.getNumberOfComponents()
+print "     Field",name," : ",desc
+print "     Number Of Components:",nbOfComp
+iterationNb = fieldIntVectOnNode.getIterationNumber()
+orderNb = fieldIntVectOnNode.getOrderNumber()
+time = fieldIntVectOnNode.getTime()
+print "     Iteration Number",iterationNb
+print "     Order Number",orderNb
+print "     Time",time
+for k in range(nbOfComp):
+    kp1 = k+1
+    compName = fieldIntVectOnNode.getComponentName(kp1)
+    compDesc = fieldIntVectOnNode.getComponentDescription(kp1)
+    compUnit = fieldIntVectOnNode.getMEDComponentUnit(kp1)
+    print "      * Component:",kp1
+    print "          Name:",compName
+    print "          Description:",compDesc
+    print "          Unit:",compUnit
+
+support = fieldIntVectOnNode.getSupport()
+nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+print "     Values:",nbOf
+for k in range(nbOf):
+    valueI = fieldIntVectOnNode.getValueI(MED_FULL_INTERLACE,k+1)
+    print "     *",valueI[:nbOfComp]
+
+##print ""
+##print supportOnConst
+
+if (spaceDim == 2) :
+    fieldDoubleScalOnConst = createFieldDoubleFromAnalytic(supportOnConst,1,
+                                                           f_scal_dbl_2d)
+    fieldDoubleVectOnConst = createFieldDoubleFromAnalytic(supportOnConst,
+                                                           spaceDim,
+                                                           f_vect_dbl_2d)
+    fieldIntScalOnConst = createFieldIntFromAnalytic(supportOnConst,1,
+                                                     f_scal_int_2d)
+    fieldIntVectOnConst = createFieldIntFromAnalytic(supportOnConst, spaceDim,
+                                                     f_vect_int_2d)
+elif (spaceDim == 3) :
+    fieldDoubleScalOnConst = createFieldDoubleFromAnalytic(supportOnConst,1,
+                                                           f_scal_dbl_3d)
+    fieldDoubleVectOnConst = createFieldDoubleFromAnalytic(supportOnConst,
+                                                           spaceDim,
+                                                           f_vect_dbl_3d)
+    fieldIntScalOnConst = createFieldIntFromAnalytic(supportOnConst,1,
+                                                     f_scal_int_3d)
+    fieldIntVectOnConst = createFieldIntFromAnalytic(supportOnConst, spaceDim,
+                                                     f_vect_int_3d)
+
+fieldDoubleScalOnConst.setName("Scalar Double Field on all Faces/Edges")
+fieldDoubleScalOnConst.setDescription("Generated via a Python function")
+
+fieldDoubleVectOnConst.setName("Vector Double Field on all Faces/Edges")
+fieldDoubleVectOnConst.setDescription("Generated via a Python function")
+
+fieldIntScalOnConst.setName("Scalar Integer Field on all Faces/Edges")
+fieldIntScalOnConst.setDescription("Generated via a Python function")
+
+fieldIntVectOnConst.setName("Vector Integer Field on all Faces/Edges")
+fieldIntVectOnConst.setDescription("Generated via a Python function")
+
+print ""
+name = fieldDoubleScalOnConst.getName()
+desc = fieldDoubleScalOnConst.getDescription()
+nbOfComp = fieldDoubleScalOnConst.getNumberOfComponents()
+print "     Field",name," : ",desc
+print "     Number Of Components:",nbOfComp
+iterationNb = fieldDoubleScalOnConst.getIterationNumber()
+orderNb = fieldDoubleScalOnConst.getOrderNumber()
+time = fieldDoubleScalOnConst.getTime()
+print "     Iteration Number",iterationNb
+print "     Order Number",orderNb
+print "     Time",time
+for k in range(nbOfComp):
+    kp1 = k+1
+    compName = fieldDoubleScalOnConst.getComponentName(kp1)
+    compDesc = fieldDoubleScalOnConst.getComponentDescription(kp1)
+    compUnit = fieldDoubleScalOnConst.getMEDComponentUnit(kp1)
+    print "      * Component:",kp1
+    print "          Name:",compName
+    print "          Description:",compDesc
+    print "          Unit:",compUnit
+
+support = fieldDoubleScalOnConst.getSupport()
+nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+print "     Values:",nbOf
+for k in range(nbOf):
+    valueI = fieldDoubleScalOnConst.getValueI(MED_FULL_INTERLACE,k+1)
+    print "     *",valueI[:nbOfComp]
+
+print ""
+name = fieldDoubleVectOnConst.getName()
+desc = fieldDoubleVectOnConst.getDescription()
+nbOfComp = fieldDoubleVectOnConst.getNumberOfComponents()
+print "     Field",name," : ",desc
+print "     Number Of Components:",nbOfComp
+iterationNb = fieldDoubleVectOnConst.getIterationNumber()
+orderNb = fieldDoubleVectOnConst.getOrderNumber()
+time = fieldDoubleVectOnConst.getTime()
+print "     Iteration Number",iterationNb
+print "     Order Number",orderNb
+print "     Time",time
+for k in range(nbOfComp):
+    kp1 = k+1
+    compName = fieldDoubleVectOnConst.getComponentName(kp1)
+    compDesc = fieldDoubleVectOnConst.getComponentDescription(kp1)
+    compUnit = fieldDoubleVectOnConst.getMEDComponentUnit(kp1)
+    print "      * Component:",kp1
+    print "          Name:",compName
+    print "          Description:",compDesc
+    print "          Unit:",compUnit
+
+support = fieldDoubleVectOnConst.getSupport()
+nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+print "     Values:",nbOf
+for k in range(nbOf):
+    valueI = fieldDoubleVectOnConst.getValueI(MED_FULL_INTERLACE,k+1)
+    print "     *",valueI[:nbOfComp]
+
+print ""
+name = fieldIntScalOnConst.getName()
+desc = fieldIntScalOnConst.getDescription()
+nbOfComp = fieldIntScalOnConst.getNumberOfComponents()
+print "     Field",name," : ",desc
+print "     Number Of Components:",nbOfComp
+iterationNb = fieldIntScalOnConst.getIterationNumber()
+orderNb = fieldIntScalOnConst.getOrderNumber()
+time = fieldIntScalOnConst.getTime()
+print "     Iteration Number",iterationNb
+print "     Order Number",orderNb
+print "     Time",time
+for k in range(nbOfComp):
+    kp1 = k+1
+    compName = fieldIntScalOnConst.getComponentName(kp1)
+    compDesc = fieldIntScalOnConst.getComponentDescription(kp1)
+    compUnit = fieldIntScalOnConst.getMEDComponentUnit(kp1)
+    print "      * Component:",kp1
+    print "          Name:",compName
+    print "          Description:",compDesc
+    print "          Unit:",compUnit
+
+support = fieldIntScalOnConst.getSupport()
+nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+print "     Values:",nbOf
+for k in range(nbOf):
+    valueI = fieldIntScalOnConst.getValueI(MED_FULL_INTERLACE,k+1)
+    print "     *",valueI[:nbOfComp]
+
+print ""
+name = fieldIntVectOnConst.getName()
+desc = fieldIntVectOnConst.getDescription()
+nbOfComp = fieldIntVectOnConst.getNumberOfComponents()
+print "     Field",name," : ",desc
+print "     Number Of Components:",nbOfComp
+iterationNb = fieldIntVectOnConst.getIterationNumber()
+orderNb = fieldIntVectOnConst.getOrderNumber()
+time = fieldIntVectOnConst.getTime()
+print "     Iteration Number",iterationNb
+print "     Order Number",orderNb
+print "     Time",time
+for k in range(nbOfComp):
+    kp1 = k+1
+    compName = fieldIntVectOnConst.getComponentName(kp1)
+    compDesc = fieldIntVectOnConst.getComponentDescription(kp1)
+    compUnit = fieldIntVectOnConst.getMEDComponentUnit(kp1)
+    print "      * Component:",kp1
+    print "          Name:",compName
+    print "          Description:",compDesc
+    print "          Unit:",compUnit
+
+support = fieldIntVectOnConst.getSupport()
+nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+print "     Values:",nbOf
+for k in range(nbOf):
+    valueI = fieldIntVectOnConst.getValueI(MED_FULL_INTERLACE,k+1)
+    print "     *",valueI[:nbOfComp]
+
+print ""
+print "END of the Pyhton script ..... Ctrl D to exit"
diff --git a/src/MEDMEM_SWIG/med_opfield_test.py b/src/MEDMEM_SWIG/med_opfield_test.py
new file mode 100755 (executable)
index 0000000..1d761e1
--- /dev/null
@@ -0,0 +1,490 @@
+############################################################################
+#
+# this Python script is testing all operations between FIELD(DOUBLE,INT)
+#
+############################################################################
+
+from libMEDMEM_Swig import *
+from random import *
+
+medFile = "pointe.med"
+
+def add_one(i):
+    return i+1
+
+def print_ord(i):
+    if i == 0:
+        return 'first'
+    elif i == 1:
+        return 'second'
+    elif i == 2:
+        return 'third'
+    else:
+        return `i`+'th'
+
+md = MED()
+
+mdDriver = MED_MED_RDONLY_DRIVER(medFile,md)
+
+mdDriver.open()
+mdDriver.readFileStruct()
+mdDriver.close()
+
+nbMeshes = md.getNumberOfMeshes()
+
+nbFields = md.getNumberOfFields()
+
+print "The med file", medFile, "contains", nbMeshes, "mesh(es) and", nbFields, "field(s)"
+
+if (nbMeshes>0):
+    print "Mesh(es) Name(s) is(are) "
+
+    for i in range(nbMeshes):
+        mesh_name = md.getMeshName(i)
+        print "   - ",mesh_name
+
+if (nbFields>0):
+    print "Field(s) Name(s) is(are) "
+
+    for i in range(nbFields):
+        field_name = md.getFieldName(i)
+        print "   - ",field_name
+
+print ""
+
+mesh_name = md.getMeshName(0)
+mesh = md.getMesh(mesh_name)
+mesh.read()
+spaceDim = mesh.getSpaceDimension()
+meshDim = mesh.getMeshDimension()
+nbNodes = mesh.getNumberOfNodes()
+print "The mesh",mesh_name,"is a",spaceDim,"D mesh on a",meshDim,"D geometry and has",nbNodes,"Nodes"
+
+if (nbFields>0):
+    print "Updating supports in the Med Object"
+    md.updateSupport()
+    print ""
+    print "Field(s) Analysis "
+    for i in range(nbFields):
+        print ""
+        field_name = md.getFieldName(i)
+        nbOfIt = md.getFieldNumberOfIteration(field_name)
+        print "The",print_ord(i),"field is",field_name,"with",nbOfIt,"iteration(s)"
+        for j in range(nbOfIt):
+            print ""
+            dtitfield = md.getFieldIteration(field_name,j)
+            dt = dtitfield.getdt()
+            it = dtitfield.getit()
+            field = md.getField(field_name,dt,it)
+            type = field.getValueType()
+            print "     * Iteration:",dt,"Order number:",it,"Type:",type
+            if type == MED_INT32:
+                fieldint = createFieldIntFromField(field)
+                fieldint.read()
+                name = fieldint.getName()
+                desc = fieldint.getDescription()
+                nbOfComp = fieldint.getNumberOfComponents()
+                print "     Field",name," : ",desc
+                print "     Number Of Components:",nbOfComp
+                iterationNb = fieldint.getIterationNumber()
+                orderNb = fieldint.getOrderNumber()
+                time = fieldint.getTime()
+                print "     Iteration Number",iterationNb
+                print "     Order Number",orderNb
+                print "     Time",time
+               print "Norme  2  : ", fieldint.norm2()
+               print "Norme Max : ", fieldint.normMax()
+
+               if fielddouble.getSupport().getEntity()!=MED_NODE:
+                   fieldint_vol=fieldint.getSupport().getMesh().getVolume(fieldint.getSupport())
+                   print "Norme L1  : ", fieldint.normL1()
+                   print "Norme L2  : ", fieldint.normL2()
+                   print "Norme L2(vol) : ", fieldint.normL2(fieldint_vol)
+
+                for k in range(nbOfComp):
+                    kp1 = k+1
+                    compName = fieldint.getComponentName(kp1)
+                    compDesc = fieldint.getComponentDescription(kp1)
+                    compUnit = fieldint.getMEDComponentUnit(kp1)
+                    print "      * Component:",kp1
+                    print "          Name:",compName
+                    print "          Description:",compDesc
+                    print "          Unit:",compUnit
+                   if fielddouble.getSupport().getEntity()!=MED_NODE:
+                       print "          Norme L1  : ", fieldint.normL1(kp1)
+                       print "          Norme L2  : ", fieldint.normL2(kp1)
+                       print "          Norme L2(vol) : ", fieldint.normL2(kp1,fieldint_vol)
+
+                support = fieldint.getSupport()
+                nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+                print "     Values:",nbOf
+                for k in range(nbOf):
+                    valueI = fieldint.getValueI(MED_FULL_INTERLACE,k+1)
+                    print "     *",valueI[:nbOfComp]
+                fieldint2 = FIELDINT(fieldint)
+                print ""
+                fieldintadd = fieldint + fieldint2
+                print "Test of the addition of two integer fields with creation a new one"
+                print ""
+                name = fieldintadd.getName()
+                desc = fieldintadd.getDescription()
+                nbOfComp = fieldintadd.getNumberOfComponents()
+                print "     Field",name," : ",desc
+                print "     Number Of Components:",nbOfComp
+                iterationNb = fieldintadd.getIterationNumber()
+                orderNb = fieldintadd.getOrderNumber()
+                time = fieldintadd.getTime()
+                print "     Iteration Number",iterationNb
+                print "     Order Number",orderNb
+                print "     Time",time
+                for k in range(nbOfComp):
+                    kp1 = k+1
+                    compName = fieldintadd.getComponentName(kp1)
+                    compDesc = fieldintadd.getComponentDescription(kp1)
+                    compUnit = fieldintadd.getMEDComponentUnit(kp1)
+                    print "      * Component:",kp1
+                    print "          Name:",compName
+                    print "          Description:",compDesc
+                    print "          Unit:",compUnit
+
+                support = fieldintadd.getSupport()
+                nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+                print "     Values:",nbOf
+                for k in range(nbOf):
+                    valueI = fieldintadd.getValueI(MED_FULL_INTERLACE,k+1)
+                    print "     *",valueI[:nbOfComp]
+                print ""
+                fieldintsub = fieldint - fieldint2
+                print "Test of the substraction of two integer fields with creation a new one"
+                print ""
+                name = fieldintsub.getName()
+                desc = fieldintsub.getDescription()
+                nbOfComp = fieldintsub.getNumberOfComponents()
+                print "     Field",name," : ",desc
+                print "     Number Of Components:",nbOfComp
+                iterationNb = fieldintsub.getIterationNumber()
+                orderNb = fieldintsub.getOrderNumber()
+                time = fieldintsub.getTime()
+                print "     Iteration Number",iterationNb
+                print "     Order Number",orderNb
+                print "     Time",time
+                for k in range(nbOfComp):
+                    kp1 = k+1
+                    compName = fieldintsub.getComponentName(kp1)
+                    compDesc = fieldintsub.getComponentDescription(kp1)
+                    compUnit = fieldintsub.getMEDComponentUnit(kp1)
+                    print "      * Component:",kp1
+                    print "          Name:",compName
+                    print "          Description:",compDesc
+                    print "          Unit:",compUnit
+
+                support = fieldintsub.getSupport()
+                nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+                print "     Values:",nbOf
+                for k in range(nbOf):
+                    valueI = fieldintsub.getValueI(MED_FULL_INTERLACE,k+1)
+                    print "     *",valueI[:nbOfComp]
+                print ""
+                fieldintmul = fieldint * fieldint2
+                print "Test of the multiplication of two integer fields with creation a new one"
+                print ""
+                name = fieldintmul.getName()
+                desc = fieldintmul.getDescription()
+                nbOfComp = fieldintmul.getNumberOfComponents()
+                print "     Field",name," : ",desc
+                print "     Number Of Components:",nbOfComp
+                iterationNb = fieldintmul.getIterationNumber()
+                orderNb = fieldintmul.getOrderNumber()
+                time = fieldintmul.getTime()
+                print "     Iteration Number",iterationNb
+                print "     Order Number",orderNb
+                print "     Time",time
+                for k in range(nbOfComp):
+                    kp1 = k+1
+                    compName = fieldintmul.getComponentName(kp1)
+                    compDesc = fieldintmul.getComponentDescription(kp1)
+                    compUnit = fieldintmul.getMEDComponentUnit(kp1)
+                    print "      * Component:",kp1
+                    print "          Name:",compName
+                    print "          Description:",compDesc
+                    print "          Unit:",compUnit
+
+                support = fieldintmul.getSupport()
+                nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+                print "     Values:",nbOf
+                for k in range(nbOf):
+                    valueI = fieldintmul.getValueI(MED_FULL_INTERLACE,k+1)
+                    print "     *",valueI[:nbOfComp]
+                print ""
+                fieldintdiv = fieldint / fieldint2
+                print "Test of the division of two integer fields with creation a new one"
+                print ""
+                name = fieldintdiv.getName()
+                desc = fieldintdiv.getDescription()
+                nbOfComp = fieldintdiv.getNumberOfComponents()
+                print "     Field",name," : ",desc
+                print "     Number Of Components:",nbOfComp
+                iterationNb = fieldintdiv.getIterationNumber()
+                orderNb = fieldintdiv.getOrderNumber()
+                time = fieldintdiv.getTime()
+                print "     Iteration Number",iterationNb
+                print "     Order Number",orderNb
+                print "     Time",time
+                for k in range(nbOfComp):
+                    kp1 = k+1
+                    compName = fieldintdiv.getComponentName(kp1)
+                    compDesc = fieldintdiv.getComponentDescription(kp1)
+                    compUnit = fieldintdiv.getMEDComponentUnit(kp1)
+                    print "      * Component:",kp1
+                    print "          Name:",compName
+                    print "          Description:",compDesc
+                    print "          Unit:",compUnit
+
+                support = fieldintdiv.getSupport()
+                nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+                print "     Values:",nbOf
+                for k in range(nbOf):
+                    valueI = fieldintdiv.getValueI(MED_FULL_INTERLACE,k+1)
+                    print "     *",valueI[:nbOfComp]
+            elif type == MED_REEL64:
+                fielddouble = createFieldDoubleFromField(field)
+                fielddouble.read()
+                name = fielddouble.getName()
+                desc = fielddouble.getDescription()
+                nbOfComp = fielddouble.getNumberOfComponents()
+                print "     Field",name," : ",desc
+                print "     Number Of Components:",nbOfComp
+                iterationNb = fielddouble.getIterationNumber()
+                orderNb = fielddouble.getOrderNumber()
+                time = fielddouble.getTime()
+                print "     Iteration Number",iterationNb
+                print "     Order Number",orderNb
+                print "     Time",time
+               print "Norme  2  : ", fielddouble.norm2()
+               print "Norme Max : ", fielddouble.normMax()
+               print "try sobolev",fielddouble.getSupport().getEntity()
+               if fielddouble.getSupport().getEntity()!=MED_NODE:
+                   fielddouble_vol=fielddouble.getSupport().getMesh().getVolume(fielddouble.getSupport())
+                   print "Norme L1  : ", fielddouble.normL1()
+                   print "Norme L2  : ", fielddouble.normL2()
+                   print "Norme L2(vol) : ", fielddouble.normL2(fielddouble_vol)
+                   
+                for k in range(nbOfComp):
+                    kp1 = k+1
+                    compName = fielddouble.getComponentName(kp1)
+                    compDesc = fielddouble.getComponentDescription(kp1)
+                    compUnit = fielddouble.getMEDComponentUnit(kp1)
+                    print "      * Component:",kp1
+                    print "          Name:",compName
+                    print "          Description:",compDesc
+                    print "          Unit:",compUnit
+                   if fielddouble.getSupport().getEntity()!=MED_NODE:
+                       print "          Norme L1  : ", fielddouble.normL1(kp1)
+                       print "          Norme L2  : ", fielddouble.normL2(kp1)
+                       print "          Norme L2(vol) : ", fielddouble.normL2(kp1, fielddouble_vol)
+
+                support = fielddouble.getSupport()
+                nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+                print "     Values:",nbOf
+                for k in range(nbOf):
+                    valueI = fielddouble.getValueI(MED_FULL_INTERLACE,k+1)
+                    print "     *",valueI[:nbOfComp]
+                fielddouble2 = FIELDDOUBLE(fielddouble)
+                print ""
+                fielddoubleadd = fielddouble + fielddouble2
+                print "Test of the addition of two double fields with creation a new one"
+                print ""
+                name = fielddoubleadd.getName()
+                desc = fielddoubleadd.getDescription()
+                nbOfComp = fielddoubleadd.getNumberOfComponents()
+                print "     Field",name," : ",desc
+                print "     Number Of Components:",nbOfComp
+                iterationNb = fielddoubleadd.getIterationNumber()
+                orderNb = fielddoubleadd.getOrderNumber()
+                time = fielddoubleadd.getTime()
+                print "     Iteration Number",iterationNb
+                print "     Order Number",orderNb
+                print "     Time",time
+                for k in range(nbOfComp):
+                    kp1 = k+1
+                    compName = fielddoubleadd.getComponentName(kp1)
+                    compDesc = fielddoubleadd.getComponentDescription(kp1)
+                    compUnit = fielddoubleadd.getMEDComponentUnit(kp1)
+                    print "      * Component:",kp1
+                    print "          Name:",compName
+                    print "          Description:",compDesc
+                    print "          Unit:",compUnit
+
+                support = fielddoubleadd.getSupport()
+                nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+                print "     Values:",nbOf
+                for k in range(nbOf):
+                    valueI = fielddoubleadd.getValueI(MED_FULL_INTERLACE,k+1)
+                    print "     *",valueI[:nbOfComp]
+                print ""
+                fielddoublesub = fielddouble - fielddouble2
+                print "Test of the substraction of two double fields with creation a new one"
+                print ""
+                name = fielddoublesub.getName()
+                desc = fielddoublesub.getDescription()
+                nbOfComp = fielddoublesub.getNumberOfComponents()
+                print "     Field",name," : ",desc
+                print "     Number Of Components:",nbOfComp
+                iterationNb = fielddoublesub.getIterationNumber()
+                orderNb = fielddoublesub.getOrderNumber()
+                time = fielddoublesub.getTime()
+                print "     Iteration Number",iterationNb
+                print "     Order Number",orderNb
+                print "     Time",time
+                for k in range(nbOfComp):
+                    kp1 = k+1
+                    compName = fielddoublesub.getComponentName(kp1)
+                    compDesc = fielddoublesub.getComponentDescription(kp1)
+                    compUnit = fielddoublesub.getMEDComponentUnit(kp1)
+                    print "      * Component:",kp1
+                    print "          Name:",compName
+                    print "          Description:",compDesc
+                    print "          Unit:",compUnit
+
+                support = fielddoublesub.getSupport()
+                nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+                print "     Values:",nbOf
+                for k in range(nbOf):
+                    valueI = fielddoublesub.getValueI(MED_FULL_INTERLACE,k+1)
+                    print "     *",valueI[:nbOfComp]
+                print ""
+                fielddoublemul = fielddouble * fielddouble2
+                print "Test of the multiplication of two double fields with creation a new one"
+                print ""
+                name = fielddoublemul.getName()
+                desc = fielddoublemul.getDescription()
+                nbOfComp = fielddoublemul.getNumberOfComponents()
+                print "     Field",name," : ",desc
+                print "     Number Of Components:",nbOfComp
+                iterationNb = fielddoublemul.getIterationNumber()
+                orderNb = fielddoublemul.getOrderNumber()
+                time = fielddoublemul.getTime()
+                print "     Iteration Number",iterationNb
+                print "     Order Number",orderNb
+                print "     Time",time
+                for k in range(nbOfComp):
+                    kp1 = k+1
+                    compName = fielddoublemul.getComponentName(kp1)
+                    compDesc = fielddoublemul.getComponentDescription(kp1)
+                    compUnit = fielddoublemul.getMEDComponentUnit(kp1)
+                    print "      * Component:",kp1
+                    print "          Name:",compName
+                    print "          Description:",compDesc
+                    print "          Unit:",compUnit
+
+                support = fielddoublemul.getSupport()
+                nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+                print "     Values:",nbOf
+                for k in range(nbOf):
+                    valueI = fielddoublemul.getValueI(MED_FULL_INTERLACE,k+1)
+                    print "     *",valueI[:nbOfComp]
+                print ""
+                fielddoublediv = fielddouble / fielddouble2
+                print "Test of the division of two double fields with creation a new one"
+                print ""
+                name = fielddoublediv.getName()
+                desc = fielddoublediv.getDescription()
+                nbOfComp = fielddoublediv.getNumberOfComponents()
+                print "     Field",name," : ",desc
+                print "     Number Of Components:",nbOfComp
+                iterationNb = fielddoublediv.getIterationNumber()
+                orderNb = fielddoublediv.getOrderNumber()
+                time = fielddoublediv.getTime()
+                print "     Iteration Number",iterationNb
+                print "     Order Number",orderNb
+                print "     Time",time
+                for k in range(nbOfComp):
+                    kp1 = k+1
+                    compName = fielddoublediv.getComponentName(kp1)
+                    compDesc = fielddoublediv.getComponentDescription(kp1)
+                    compUnit = fielddoublediv.getMEDComponentUnit(kp1)
+                    print "      * Component:",kp1
+                    print "          Name:",compName
+                    print "          Description:",compDesc
+                    print "          Unit:",compUnit
+
+                support = fielddoublediv.getSupport()
+                nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS)
+                print "     Values:",nbOf
+                for k in range(nbOf):
+                    valueI = fielddoublediv.getValueI(MED_FULL_INTERLACE,k+1)
+                    print "     *",valueI[:nbOfComp]
+            else:
+                print "  !!!! Bad type of Field !!!!"
+
+print ""
+print "TESTS OPERATIONS SUR FIELDDOUBLE : "
+
+
+fielddoublesub = fielddouble-fielddouble2
+fielddoublemul = fielddouble*fielddouble2
+fielddoublediv = fielddouble/fielddouble2
+fielddoubleasso = fielddouble+fielddouble2*fielddouble2
+fielddoubleSP=createFieldDoubleScalarProduct(fielddouble, fielddouble2)
+
+
+print " f1     : ",fielddouble.getValue(MED_FULL_INTERLACE)
+print " f2     : ",fielddouble2.getValue(MED_FULL_INTERLACE)
+print "--------------------------------------------------------------------------------------------------------------"
+print "  +     : ",fielddoubleadd.getValue(MED_FULL_INTERLACE)
+print "  -     : ",fielddoublesub.getValue(MED_FULL_INTERLACE)
+print "  *     : ",fielddoublemul.getValue(MED_FULL_INTERLACE)
+print "  /     : ",fielddoublediv.getValue(MED_FULL_INTERLACE)
+
+fielddouble+=fielddouble2;
+print "  +=    : ",fielddouble.getValue(MED_FULL_INTERLACE)
+fielddouble-=fielddouble2;
+print "  -=    : ",fielddouble.getValue(MED_FULL_INTERLACE)
+fielddouble*=fielddouble2;
+print "  *=    : ",fielddouble.getValue(MED_FULL_INTERLACE)
+fielddouble/=fielddouble2;
+print "  /=    : ",fielddouble.getValue(MED_FULL_INTERLACE)
+print "f1+f2*f2: ",fielddoubleasso.getValue(MED_FULL_INTERLACE)
+fielddouble.applyLin(4,1);
+print " 4f1+1  : ",fielddouble.getValue(MED_FULL_INTERLACE)
+print " f1.f2  : ",fielddoubleSP.getValue(MED_FULL_INTERLACE)
+fielddouble2.applyPyFunc(add_one)
+print " CB:f2+1: ",fielddouble2.getValue(MED_FULL_INTERLACE)
+
+print ""
+print "TESTS OPERATIONS SUR FIELDINT : "
+
+
+fieldintadd = fieldint+fieldint2
+fieldintsub = fieldint-fieldint2
+fieldintmul = fieldint*fieldint2
+fieldintdiv = fieldint/fieldint2
+fieldintasso = fieldint+fieldint*fieldint
+fieldintSP=createFieldIntScalarProduct(fieldint, fieldint2)
+
+print " f1     : ",fieldint.getValue(MED_FULL_INTERLACE)
+print " f2     : ",fieldint2.getValue(MED_FULL_INTERLACE)
+print "--------------------------------------------------------------------------------------------------------------"
+print "  +     : ",fieldintadd.getValue(MED_FULL_INTERLACE)
+print "  -     : ",fieldintsub.getValue(MED_FULL_INTERLACE)
+print "  *     : ",fieldintmul.getValue(MED_FULL_INTERLACE)
+print "  /     : ",fieldintdiv.getValue(MED_FULL_INTERLACE)
+fieldint+=fieldint2;
+print "  +=    : ",fieldint.getValue(MED_FULL_INTERLACE)
+fieldint-=fieldint2;
+print "  -=    : ",fieldint.getValue(MED_FULL_INTERLACE)
+fieldint*=fieldint2;
+print "  *=    : ",fieldint.getValue(MED_FULL_INTERLACE)
+fieldint/=fieldint2;
+print "  /=    : ",fieldint.getValue(MED_FULL_INTERLACE)
+print "f1+f2*f2: ",fieldintasso.getValue(MED_FULL_INTERLACE)
+fieldint.applyLin(4,1);
+print " 4f1+1  : ",fieldint.getValue(MED_FULL_INTERLACE)
+print " f1.f2  : ",fieldintSP.getValue(MED_FULL_INTERLACE)
+fieldint2.applyPyFunc(add_one)
+print " CB:f2+1: ",fieldint2.getValue(MED_FULL_INTERLACE)
+myname="toto"
+fieldint.setName(myname)
+name = fieldint.getName()
+print "test de setName : ",name
+print "END of the Pyhton script ..... Ctrl D to exit"
diff --git a/src/MEDMEM_SWIG/med_opsupp_test.py b/src/MEDMEM_SWIG/med_opsupp_test.py
new file mode 100755 (executable)
index 0000000..de43fc6
--- /dev/null
@@ -0,0 +1,403 @@
+############################################################################
+#
+# This Python script is testing the merge and the intersection of
+# several SUPPORTs
+#
+############################################################################
+
+from libMEDMEM_Swig import *
+from random import *
+
+medFile = "pointe.med"
+
+def print_ord(i):
+    if i == 0:
+        return 'first'
+    elif i == 1:
+        return 'second'
+    elif i == 2:
+        return 'third'
+    else:
+        return `i`+'th'
+
+md = MED()
+
+mdDriver = MED_MED_RDONLY_DRIVER(medFile,md)
+
+mdDriver.open()
+mdDriver.readFileStruct()
+mdDriver.close()
+
+nbMeshes = md.getNumberOfMeshes()
+
+print "The med file", medFile, "contains", nbMeshes, "mesh(es)"
+
+mesh_name = md.getMeshName(0)
+mesh = md.getMesh(mesh_name)
+mesh.read()
+spaceDim = mesh.getSpaceDimension()
+meshDim = mesh.getMeshDimension()
+nbNodes = mesh.getNumberOfNodes()
+print "The mesh",mesh_name,"is a",spaceDim,"D mesh on a",meshDim,"D geometry and has",nbNodes,"Nodes"
+
+print ""
+print "Mesh Families analysis:"
+print ""
+
+for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]:
+    nbFam = mesh.getNumberOfFamilies(entity)
+    if (entity == MED_NODE) & (nbFam > 0):
+        print "This mesh has",nbFam,"Node Family(ies)"
+    elif (entity == MED_NODE) & (nbFam == 0):
+        print "This mesh has no Node Family(ies)"
+    elif (entity == MED_CELL) & (nbFam > 0):
+        print "This mesh has",nbFam,"Cell Family(ies)"
+    elif (entity == MED_CELL) & (nbFam == 0):
+        print "This mesh has no Cell Family(ies)"
+    elif (entity == MED_FACE) & (nbFam > 0):
+        print "This mesh has",nbFam,"Face Family(ies)"
+    elif (entity == MED_FACE) & (nbFam == 0):
+        print "This mesh has no Face Family(ies)"
+    elif (entity == MED_EDGE) & (nbFam > 0):
+        print "This mesh has",nbFam,"Edge Family(ies)"
+    elif (entity == MED_EDGE) & (nbFam == 0):
+        print "This mesh has no Edge Family(ies)"
+    print ""
+    
+    if nbFam > 0:
+        for j in range(nbFam):
+            family = mesh.getFamily(entity,j+1)
+            familyName = family.getName()
+            familyDescription = family.getDescription()
+            familyEntity = family.getEntity()
+            familyBool = family.isOnAllElements()
+            print "  -Name:",familyName
+            print "  -Description:",familyDescription
+            print "  -Entity:",familyEntity
+            familyIdentifier = family.getIdentifier()
+            nbOfAtt = family.getNumberOfAttributes()
+            print "  -Identifier:",familyIdentifier
+            print "  -Number Of Attributes:",nbOfAtt
+            attributesids = family.getAttributesIdentifiers()
+            attributesvals = family.getAttributesValues()
+            for k in range(nbOfAtt):
+                print "    * Attributes:",attributesids[k],":",attributesvals[k],",",family.getAttributeDescription(k+1)
+            nbOfGrp = family.getNumberOfGroups()
+            print "  -Number Of Groups:",nbOfGrp
+            for k in range(nbOfGrp):
+                print "    * Group:",family.getGroupName(k+1)
+            print "  -Entities list:"
+            if (familyBool):
+                print "  -Is on all entities"
+            else:
+                nbOfTypes = family.getNumberOfTypes()
+                types = family.getTypes()
+                print "  -Number Of Types:",nbOfTypes
+                for k in range(nbOfTypes):
+                    type = types[k]
+                    nbOfElmtsOfType = family.getNumberOfElements(type)
+                    number = family.getNumber(type)
+                    print "    * Type",type
+                    print "    * Number",number[0:nbOfElmtsOfType]
+                print ""
+
+print "we are going to do some operation on Node families"
+print "by definition families have no intersection"
+print ""
+entity = MED_NODE
+familyNode1 = mesh.getFamily(entity,1)
+familyNode2 = mesh.getFamily(entity,2)
+familyNode3 = mesh.getFamily(entity,3)
+familyNode4 = mesh.getFamily(entity,4)
+
+listOfSupports = []
+listOfSupports.append(familyNode1)
+listOfSupports.append(familyNode2)
+
+support = mesh.mergeSupports(listOfSupports)
+
+supportName = support.getName()
+supportDescription = support.getDescription()
+supportMeshname = support.getMesh().getName()
+supportEntity = support.getEntity()
+supportBool = support.isOnAllElements()
+print "  -Name:",supportName
+print "  -Description:",supportDescription
+print "  -Entity:",supportEntity
+if (supportBool):
+    print "  -Is on all entities"
+else:
+    nbOfTypes = support.getNumberOfTypes()
+    types = support.getTypes()
+    print "  -Number Of Types:",nbOfTypes
+    for k in range(nbOfTypes):
+        type = types[k]
+        nbOfElmtsOfType = support.getNumberOfElements(type)
+        number = support.getNumber(type)
+        print "    * Type",type
+        print "    * Number",number[0:nbOfElmtsOfType]
+    print ""
+
+support = mesh.intersectSupports(listOfSupports)
+
+supportName = support.getName()
+supportDescription = support.getDescription()
+supportMeshname = support.getMesh().getName()
+supportEntity = support.getEntity()
+supportBool = support.isOnAllElements()
+print "  -Name:",supportName
+print "  -Description:",supportDescription
+print "  -Entity:",supportEntity
+if (supportBool):
+    print "  -Is on all entities"
+else:
+    nbOfTypes = support.getNumberOfTypes()
+    types = support.getTypes()
+    print "  -Number Of Types:",nbOfTypes
+    for k in range(nbOfTypes):
+        type = types[k]
+        nbOfElmtsOfType = support.getNumberOfElements(type)
+        number = support.getNumber(type)
+        print "    * Type",type
+        print "    * Number",number[0:nbOfElmtsOfType]
+    print ""
+
+listOfSupports.append(familyNode3)
+
+support = mesh.mergeSupports(listOfSupports)
+
+supportName = support.getName()
+supportDescription = support.getDescription()
+supportMeshname = support.getMesh().getName()
+supportEntity = support.getEntity()
+supportBool = support.isOnAllElements()
+print "  -Name:",supportName
+print "  -Description:",supportDescription
+print "  -Entity:",supportEntity
+if (supportBool):
+    print "  -Is on all entities"
+else:
+    nbOfTypes = support.getNumberOfTypes()
+    types = support.getTypes()
+    print "  -Number Of Types:",nbOfTypes
+    for k in range(nbOfTypes):
+        type = types[k]
+        nbOfElmtsOfType = support.getNumberOfElements(type)
+        number = support.getNumber(type)
+        print "    * Type",type
+        print "    * Number",number[0:nbOfElmtsOfType]
+    print ""
+
+print "we are going to do some operation on Cell families"
+print "by definition families have no intersection"
+print ""
+entity = MED_CELL
+familyCell1 = mesh.getFamily(entity,1)
+familyCell2 = mesh.getFamily(entity,2)
+familyCell3 = mesh.getFamily(entity,3)
+
+listOfSupports = []
+listOfSupports.append(familyCell1)
+listOfSupports.append(familyCell2)
+
+support = mesh.mergeSupports(listOfSupports)
+
+supportName = support.getName()
+supportDescription = support.getDescription()
+supportMeshname = support.getMesh().getName()
+supportEntity = support.getEntity()
+supportBool = support.isOnAllElements()
+print "  -Name:",supportName
+print "  -Description:",supportDescription
+print "  -Entity:",supportEntity
+if (supportBool):
+    print "  -Is on all entities"
+else:
+    nbOfTypes = support.getNumberOfTypes()
+    types = support.getTypes()
+    print "  -Number Of Types:",nbOfTypes
+    for k in range(nbOfTypes):
+        type = types[k]
+        nbOfElmtsOfType = support.getNumberOfElements(type)
+        number = support.getNumber(type)
+        print "    * Type",type
+        print "    * Number",number[0:nbOfElmtsOfType]
+    print ""
+
+support = mesh.intersectSupports(listOfSupports)
+
+supportName = support.getName()
+supportDescription = support.getDescription()
+supportMeshname = support.getMesh().getName()
+supportEntity = support.getEntity()
+supportBool = support.isOnAllElements()
+print "  -Name:",supportName
+print "  -Description:",supportDescription
+print "  -Entity:",supportEntity
+if (supportBool):
+    print "  -Is on all entities"
+else:
+    nbOfTypes = support.getNumberOfTypes()
+    types = support.getTypes()
+    print "  -Number Of Types:",nbOfTypes
+    for k in range(nbOfTypes):
+        type = types[k]
+        nbOfElmtsOfType = support.getNumberOfElements(type)
+        number = support.getNumber(type)
+        print "    * Type",type
+        print "    * Number",number[0:nbOfElmtsOfType]
+    print ""
+
+listOfSupports.append(familyCell3)
+
+support = mesh.mergeSupports(listOfSupports)
+
+supportName = support.getName()
+supportDescription = support.getDescription()
+supportMeshname = support.getMesh().getName()
+supportEntity = support.getEntity()
+supportBool = support.isOnAllElements()
+print "  -Name:",supportName
+print "  -Description:",supportDescription
+print "  -Entity:",supportEntity
+if (supportBool):
+    print "  -Is on all entities"
+else:
+    nbOfTypes = support.getNumberOfTypes()
+    types = support.getTypes()
+    print "  -Number Of Types:",nbOfTypes
+    for k in range(nbOfTypes):
+        type = types[k]
+        nbOfElmtsOfType = support.getNumberOfElements(type)
+        number = support.getNumber(type)
+        print "    * Type",type
+        print "    * Number",number[0:nbOfElmtsOfType]
+    print ""
+
+print "Let's now do an example of union and intersection of two supports with a non empty intersection"
+print ""
+support1 = SUPPORT(mesh,"Partial_Support_1",MED_CELL)
+support1Description = "Partial Support 1"
+support1NbOfTypes = 3
+support1TotNbElm = 8
+support1GeoType = [MED_TRIA3,MED_HEXA8,MED_PYRA5]
+support1NbOfElm = [4,2,2]
+support1NbValue = [1,2,3,4,15,16,13,14]
+
+support1.setpartial(support1Description,support1NbOfTypes,support1TotNbElm,
+                    support1GeoType,support1NbOfElm,support1NbValue)
+
+supportName = support1.getName()
+supportDescription = support1.getDescription()
+supportMeshname = support1.getMesh().getName()
+supportEntity = support1.getEntity()
+supportBool = support1.isOnAllElements()
+print "  -Name:",supportName
+print "  -Description:",supportDescription
+print "  -Entity:",supportEntity
+if (supportBool):
+    print "  -Is on all entities"
+else:
+    nbOfTypes = support1.getNumberOfTypes()
+    types = support1.getTypes()
+    print "  -Number Of Types:",nbOfTypes
+    for k in range(nbOfTypes):
+        type = types[k]
+        nbOfElmtsOfType = support1.getNumberOfElements(type)
+        number = support1.getNumber(type)
+        print "    * Type",type
+        print "    * Number",number[0:nbOfElmtsOfType]
+    print ""
+
+support2 = SUPPORT(mesh,"Partial_Support_2",MED_CELL)
+support2Description = "Partial Support 2"
+support2NbOfTypes = 3
+support2TotNbElm = 8
+support2GeoType = [MED_TRIA3,MED_HEXA8,MED_PYRA5]
+support2NbOfElm = [6,1,1]
+support2NbValue = [3,4,9,10,11,12,16,14]
+
+support2.setpartial(support2Description,support2NbOfTypes,support2TotNbElm,
+                    support2GeoType,support2NbOfElm,support2NbValue)
+
+supportName = support2.getName()
+supportDescription = support2.getDescription()
+supportMeshname = support2.getMesh().getName()
+supportEntity = support2.getEntity()
+supportBool = support2.isOnAllElements()
+print "  -Name:",supportName
+print "  -Description:",supportDescription
+print "  -Entity:",supportEntity
+if (supportBool):
+    print "  -Is on all entities"
+else:
+    nbOfTypes = support2.getNumberOfTypes()
+    types = support2.getTypes()
+    print "  -Number Of Types:",nbOfTypes
+    for k in range(nbOfTypes):
+        type = types[k]
+        nbOfElmtsOfType = support2.getNumberOfElements(type)
+        number = support2.getNumber(type)
+        print "    * Type",type
+        print "    * Number",number[0:nbOfElmtsOfType]
+    print ""
+
+listOfSupports = []
+listOfSupports.append(support1)
+listOfSupports.append(support2)
+
+print "The union"
+print ""
+
+support = mesh.mergeSupports(listOfSupports)
+
+supportName = support.getName()
+supportDescription = support.getDescription()
+supportMeshname = support.getMesh().getName()
+supportEntity = support.getEntity()
+supportBool = support.isOnAllElements()
+print "  -Name:",supportName
+print "  -Description:",supportDescription
+print "  -Entity:",supportEntity
+if (supportBool):
+    print "  -Is on all entities"
+else:
+    nbOfTypes = support.getNumberOfTypes()
+    types = support.getTypes()
+    print "  -Number Of Types:",nbOfTypes
+    for k in range(nbOfTypes):
+        type = types[k]
+        nbOfElmtsOfType = support.getNumberOfElements(type)
+        number = support.getNumber(type)
+        print "    * Type",type
+        print "    * Number",number[0:nbOfElmtsOfType]
+    print ""
+
+print "The intersection"
+print ""
+
+support = mesh.intersectSupports(listOfSupports)
+
+supportName = support.getName()
+supportDescription = support.getDescription()
+supportMeshname = support.getMesh().getName()
+supportEntity = support.getEntity()
+supportBool = support.isOnAllElements()
+print "  -Name:",supportName
+print "  -Description:",supportDescription
+print "  -Entity:",supportEntity
+if (supportBool):
+    print "  -Is on all entities"
+else:
+    nbOfTypes = support.getNumberOfTypes()
+    types = support.getTypes()
+    print "  -Number Of Types:",nbOfTypes
+    for k in range(nbOfTypes):
+        type = types[k]
+        nbOfElmtsOfType = support.getNumberOfElements(type)
+        number = support.getNumber(type)
+        print "    * Type",type
+        print "    * Number",number[0:nbOfElmtsOfType]
+    print ""
+
+print "END of the Pyhton script ..... Ctrl D to exit"
index 1525c9928f3a5e01be76a2d1062a6bfa013d7313..57dc43cc3917c3d7418190f79e9a882acf1d5817 100644 (file)
@@ -1,28 +1,11 @@
-#  MED MEDMEM_SWIG : binding of C++ implementation and Python
+###################################################################################
 #
-#  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+# This Python script is parsing a MED file using MED Memory from SALOME platform:
+# It analyses all meshes in the MED file (coordinates, connectivity of d-cells as
+# well as (d-1)-cells, families). It analyses fields stored in the MED file (d is
+# the space dimension). You can assume that it is a kind of MED file parser.
 #
-#
-#
-#  File   : med_test1.py
-#  Module : MED
+###################################################################################
 
 from libMEDMEM_Swig import *
 from random import *
@@ -409,25 +392,25 @@ if (nbMeshes>0):
             suppBound = mesh.getBoundaryElements(MED_FACE)
             nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS)
             print "Getting normal field on the boundary",nbElmBound
-##            normalBound = mesh.getNormal(suppBound)
-##            for j in range(nbElmBound):
-##                normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1)
-##                value1 = normalBoundJ[0]
-##                value2 = normalBoundJ[1]
-##                value3 = normalBoundJ[2]
-##                norm = (value1*value1 + value2*value2 + value3*value3)**(0.5)
-##                print "    * ",normalBoundJ[:spaceDim],"norm:",norm
+            normalBound = mesh.getNormal(suppBound)
+            for j in range(nbElmBound):
+                normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1)
+                value1 = normalBoundJ[0]
+                value2 = normalBoundJ[1]
+                value3 = normalBoundJ[2]
+                norm = (value1*value1 + value2*value2 + value3*value3)**(0.5)
+                print "    * ",normalBoundJ[:spaceDim],"norm:",norm
         elif spaceDim == 2:
             suppBound = mesh.getBoundaryElements(MED_EDGE)
             nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS)
             print "Getting normal field on the boundary",nbElmBound
-##            normalBound = mesh.getNormal(suppBound)
-##            for j in range(nbElmBound):
-##                normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1)
-##                value1 = normalBoundJ[0]
-##                value2 = normalBoundJ[1]
-##                norm = (value1*value1 + value2*value2)**(0.5)
-##                print "    * ",normalBoundJ[:spaceDim],"norm:",norm
+            normalBound = mesh.getNormal(suppBound)
+            for j in range(nbElmBound):
+                normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1)
+                value1 = normalBoundJ[0]
+                value2 = normalBoundJ[1]
+                norm = (value1*value1 + value2*value2)**(0.5)
+                print "    * ",normalBoundJ[:spaceDim],"norm:",norm
         print ""
 if (nbFields>0):
     print "Updating supports in the Med Object"
@@ -507,3 +490,4 @@ if (nbFields>0):
             else:
                 print "  !!!! Bad type of Field !!!!"
 
+print "END of the Pyhton script ..... Ctrl D to exit"
index 0bbb48f817135b62fea02111348b216c779eb20e..73a5c23bb4a36f6a3c42b13c8d6e0da079ca3dcc 100644 (file)
@@ -1,28 +1,12 @@
-#  MED MEDMEM_SWIG : binding of C++ implementation and Python
+###################################################################################
 #
-#  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+# This Python script is parsing a MED file using MED Memory from SALOME platform:
+# It analyses all meshes in the MED file (coordinates, connectivity of d-cells as
+# well as (d-1)-cells, families), it tests all fields generated ine the MESH class
+# and write them in a new file , it gives only the number of fields stored in the
+# MED file (d is the space dimension).
 #
-#
-#
-#  File   : med_test2.py
-#  Module : MED
+###################################################################################
 
 from libMEDMEM_Swig import *
 from random import *
index c179f07d8479c681f9efa0044053829e55d42826..9822fc08eeb345d75282df9a89f1d4ba34c10960 100644 (file)
@@ -1,28 +1,9 @@
-#  MED MEDMEM_SWIG : binding of C++ implementation and Python
+###################################################################################
 #
-#  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+# This Python script is parsing a MED file using MED Memory from SALOME platform:
+# It tests the setValue(I) function on MED fields
 #
-#
-#
-#  File   : med_test3.py
-#  Module : MED
+###################################################################################
 
 from libMEDMEM_Swig import *
 from random import *
index 0c4ecad4daec0bb3c9ab3196e9a4ebbb851d818b..d225030907990c90682cc147dd2e88f07514df41 100755 (executable)
@@ -1,11 +1,5 @@
-#  MED MEDMEM_SWIG : binding of C++ implementation and Python
-#
-#  Copyright (C) 2003  CEA/DEN, EDF R&D
-#
-#
-#
-#  File   : med_test_grid.py
-#  Module : MED
+#    Python script for testing T5.10 task
+# ###########################################
 
 #% Test structured mesh (GRID) reading from file test19.med
 #% test19.med can be obtained by running test19_c.out executable
index df3864b295852e5733c99cd64543a3d5c479bf0f..79d95b42b3d83088d0224b2b99c1ea06dc8bd549 100644 (file)
@@ -1,12 +1,3 @@
-#  MED MEDMEM_SWIG : binding of C++ implementation and Python
-#
-#  Copyright (C) 2003  CEA/DEN, EDF R&D
-#
-#
-#
-#  File   : med_test_skin.py
-#  Module : MED
-
 #% Test function MESH::getSkin() on mesh from file cube_hexa8_quad4.med
 #% The med file can be obtained by running create_mesh_c3h8q4 executable
 
index a9a1b07e67543fd9e9f42bfd67bb3b76bf31d81e..a527ec4d68acdedf61953a3316cb2ec53f9d5020 100644 (file)
@@ -1,54 +1,30 @@
-//  MED MEDMEM_SWIG : binding of C++ implementation and Python
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : my_typemap.i
-//  Module : MED
-
 %{
 #include <stdio.h>
 %}
 
 %typemap(python,in) string * {
+  /* typemap in for string * */
   /* Check if is a list */
-  if (PyList_Check($source)) {
-    int size = PyList_Size($source);
+  if (PyList_Check($input)) {
+    int size = PyList_Size($input);
     int i = 0;
-    $target = new string[size];
+    $1 = new string[size];
     for (i = 0; i < size; i++) {
-      PyObject *o = PyList_GetItem($source,i);
+      PyObject *o = PyList_GetItem($input,i);
       if (PyString_Check(o))
-       $target[i] = string(PyString_AsString(PyList_GetItem($source,i)));
+       $1[i] = string(PyString_AsString(PyList_GetItem($input,i)));
       else {
        PyErr_SetString(PyExc_TypeError,"list must contain strings");
-       free($target);
+       free($1);
        return NULL;
       }
     }
-    // $target[i] = 0;
-  } else {
-    PyErr_SetString(PyExc_TypeError,"not a list");
-    return NULL;
   }
+  else
+    {
+      PyErr_SetString(PyExc_TypeError,"not a list");
+      return NULL;
+    }
 }
 
 %typemap(python,in) double *
   /* free the memory allocated in the typemap in for medGeometryElement * */
   free($1);
 }
+
index 9cb1be44e94a25f3e382e85c9d71f80aecb8fcbe..cc7d34f401310b741b61b75973e250631099e604 100644 (file)
@@ -46,6 +46,8 @@ LIB_CLIENT_IDL= SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME
 
 EXPORT_PYSCRIPTS = libMedCorba_Swig.py medcorba_test.py batchmode_medcorba_test.py
 
+EXPORT_HEADERS = libMedCorba_Swig.i
+
 #############################################################################
 
 CPPFLAGS+= $(PYTHON_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
index 756fddeb65d287361722baa876ee39e1096d8c6b..6035d7b981502899b60a2e8a68a101bc9dee0e42 100644 (file)
@@ -1,29 +1,3 @@
-//  MED MedCorba_Swig : binding of MED CORBA objects woth Python
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : libMedCorba_Swig.i
-//  Module : MED
-
 %module libMedCorba_Swig
 
 %include "libMEDMEM_Swig.i"
@@ -444,6 +418,8 @@ FIELDDOUBLE * createLocalFieldDouble(const int, const int);
 
 FIELDINT * createLocalFieldInt(const int, const int);
 
+SALOME_MED::MESH_ptr createCorbaMesh(MESH * mesh);
+
 %{
   SALOME_MED::FIELDDOUBLE_ptr createCorbaFieldDouble(SALOME_MED::SUPPORT_ptr mySupportIOR,FIELDDOUBLE * field)
     {
@@ -550,6 +526,28 @@ FIELDINT * createLocalFieldInt(const int, const int);
       return supportcorba;
     }
 
+  SALOME_MED::MESH_ptr createCorbaMesh(MESH * mesh)
+    {
+      BEGIN_OF("SALOME_MED::MESH_ptr createCorbaMesh from libMedCorba_Swig");
+
+      SCRUTE(mesh);
+
+      MESH_i * meshimpl = new MESH_i(mesh);
+
+      SALOME_MED::MESH_ptr meshcorba =
+       meshimpl->POA_SALOME_MED::MESH::_this();
+
+      SCRUTE(meshimpl);
+
+      SCRUTE(meshcorba);
+
+      meshimpl->_remove_ref();
+
+      END_OF("SALOME_MED::MESH_ptr createCorbaMesh from libMedCorba_Swig");
+
+      return meshcorba;
+    }
+
   FIELDDOUBLE * createLocalFieldDouble(const int NumberOfComponents,
                                      const int LengthValue)
     {
index 81d51782adb0e4519d504e220ae3dc93d7f29aee..3f2d3fb37fb79b7df7874cdea40610ad9abc0bb2 100644 (file)
@@ -1,37 +1,14 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : Family_i.cxx
-//  Author : EDF
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Family_i.cxx
-
-using namespace std;
-#include "Family_i.hxx"
+//=============================================================================
+// File      :  Family_i.cxx
+// Project   :  SALOME
+// Copyright :  EDF 2002
+// Author    :  EDF
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Family_i.cxx
+//=============================================================================
 
 #include "utilities.h"
+#include "Family_i.hxx"
 #include "Utils_CorbaException.hxx"
-
 #include "MEDMEM_Family.hxx"
 
 //=============================================================================
@@ -47,7 +24,7 @@ FAMILY_i::FAMILY_i(): _family((::FAMILY*)NULL),
 }
 //=============================================================================
 /*!
- * constructor par recopie
+ * Copy Constructor 
  */
 //=============================================================================
 FAMILY_i::FAMILY_i(const FAMILY_i & f): _family(f._family),
index 8a1ae3153388b02f36d635877a440a7914491caa..11a9b3e7cb6c9302b18a79d2de34cdcfafacfbae 100644 (file)
@@ -1,31 +1,10 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : Family_i.hxx
-//  Author : EDF
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Family_i.hxx
-
+//=============================================================================
+// File      : Family_i.hxx
+// Project   : SALOME
+// Copyright : EDF 2002
+// Author    : EDF
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Family_i.hxx
+//=============================================================================
 #ifndef MED_FAMILY_I_HXX_
 #define MED_FAMILY_I_HXX_
 
index d44257488a69316ef008e1fc24ae220e49da15a7..f10252705f8354960c9b4e2c2cf1c98fac702d29 100644 (file)
@@ -1,32 +1,11 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : Fielddouble_i.hxx
-//  Author : EDF 
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Fielddouble_i.hxx
+//=============================================================================
+// File      : Fielddouble_i.hxx
+// Project   : SALOME
+// Author    : EDF 
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Fielddouble_i.hxx
+//=============================================================================
 
-using namespace std;
 #include "FieldDouble_i.hxx"
 #include "utilities.h"
 #include "convert.hxx"
index ff9fdb022bd452861e2aa8f5e215f83b7e2af5dc..fe149dd37475a97c71d77354016e795da90f112b 100644 (file)
@@ -1,30 +1,10 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : Fielddouble_i.hxx
-//  Author : EDF 
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Fielddouble_i.hxx
+//=============================================================================
+// File      : Fielddouble_i.hxx
+// Project   : SALOME
+// Author    : EDF 
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Fielddouble_i.hxx
+//=============================================================================
 
 #ifndef MED_FIELDDOUBLE_I_HXX_
 #define MED_FIELDDOUBLE_I_HXX_
index 7ab1782297826d2aa7fa50889d445fcaf3ab1b8b..c0a52b84dc28464f46303b9fb1a1a11695038e76 100644 (file)
@@ -1,32 +1,11 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : Fieldint_i.hxx
-//  Author : EDF 
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Fieldint_i.hxx
+//=============================================================================
+// File      : Fieldint_i.hxx
+// Project   : SALOME
+// Author    : EDF 
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Fieldint_i.hxx
+//=============================================================================
 
-using namespace std;
 #include "FieldInt_i.hxx"
 #include "utilities.h"
 #include "convert.hxx"
index ce338ff5b77d94071e562054f644211ab1013934..a5f20621c6e94dfa90e22b881ed8978bf332dc2d 100644 (file)
@@ -1,30 +1,10 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : FieldInt_i.hxx
-//  Author : EDF 
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/FieldInt_i.hxx
+//=============================================================================
+// File      : FieldInt_i.hxx
+// Project   : SALOME
+// Author    : EDF 
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/FieldInt_i.hxx
+//=============================================================================
 
 #ifndef MED_FIELDINT_I_HXX_
 #define MED_FIELDINT_I_HXX_
index bb0fd8abecbac90f3fb46cfa87a7786e43659703..f4db3ad73cf35beb96a12ffc1f2e773fe44fa271 100644 (file)
@@ -1,30 +1,11 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : FieldOf_i.hxx
-//  Author : EDF
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/FieldOf_i.hxx
+//=============================================================================
+// File      : FieldOf_i.hxx
+// Project   : SALOME
+// Author    : EDF
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/FieldOf_i.hxx
+//=============================================================================
+
 
 #ifndef MED_FIELDOF_I_HXX_
 #define MED_FIELDOF_I_HXX_
@@ -93,7 +74,7 @@ public :
     Engines::string_array * getComponentsNames()  throw (SALOME::SALOME_Exception);
     Engines::string_array * getComponentsUnits()  throw (SALOME::SALOME_Exception);
     void addInStudy(SALOMEDS::Study_ptr myStudy, 
-                   SALOME_MED::FIELD_ptr myIor)  throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection);
+                   SALOME_MED::FIELD_ptr myIor)  throw (SALOME::SALOME_Exception);
 
     CORBA::Long addDriver (SALOME_MED::medDriverTypes driverType, 
                           const char* fileName, const char* fieldName)
@@ -472,7 +453,7 @@ throw (SALOME::SALOME_Exception)
 //=============================================================================
 template <class T> void FIELDOF_i<T>::addInStudy(SALOMEDS::Study_ptr myStudy, 
                                                 SALOME_MED::FIELD_ptr myIor )
-throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
+throw (SALOME::SALOME_Exception)
 {
         BEGIN_OF(" FIELDOF_i::addInStudy");
         if (_fieldTptr==NULL)
@@ -492,14 +473,12 @@ throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
         SALOMEDS::AttributeIOR_var     aIOR;
 
         // Create SComponent labelled 'Med'
-        SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
+        SALOMEDS::SComponent_var medfather = myStudy->FindComponent("Med");
         if ( CORBA::is_nil(medfather) )
          THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
 
        // Create SObject labelled 'MEDFIELD' if it doesn't already exit
        SALOMEDS::SObject_var medfieldfather = myStudy->FindObject("MEDFIELD");
-       
-       myBuilder->NewCommand();
        if ( CORBA::is_nil(medfieldfather) ) 
        {
          MESSAGE("Add Object 'MEDFIELD'");
@@ -525,6 +504,7 @@ throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
         // Create object labelled according to Field's Name
 
         MESSAGE("Add a Field Object under "<<_fieldTptr->getName());
+        myBuilder->NewCommand();
         SALOMEDS::SObject_var newObj = myBuilder->NewObject(medfieldnamefather);
 
         ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
@@ -549,7 +529,6 @@ throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
          SALOMEDS::SObject_var newObjSupport = myBuilder->NewObject(newObj);
          myBuilder->Addreference(newObjSupport,supportObject);
        }
-       myBuilder->CommitCommand();
         _FieldId = newObj->GetID();
        MESSAGE("FIELDOF_i::addInStudy _FieldId="<< _FieldId);
 
index c6a5871a087a16778017e8fc185c57f07424013c..a4c941c851588de8c708c9c33358c967a1363272 100644 (file)
@@ -1,32 +1,11 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : Field_i.cxx
-//  Author : EDF
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Field_i.cxx
-
-using namespace std;
+//=============================================================================
+// File      : Field_i.cxx
+// Created   : mer fév 20 15:47:57 CET 2002
+// Author    : EDF
+// Project   : SALOME
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Field_i.cxx
+//=============================================================================
 # include "Field_i.hxx"
 
 FIELD_i::FIELD_i()
index fb44359c3de58d8b320d0946e9f60faf407ed91d..22fa2d99877f37d5550e14c8394645a488b7c50f 100644 (file)
@@ -1,31 +1,11 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : Field_i.hxx
-//  Author : EDF
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Field_i.hxx
-
+//=============================================================================
+// File      : Field_i.hxx
+// Created   : mer fév 20 15:47:57 CET 2002
+// Author    : EDF
+// Project   : SALOME
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Field_i.hxx
+//=============================================================================
 # ifndef __FIELD_I_H__
 # define __FIELD_I_H__
 
@@ -71,7 +51,7 @@ public :
                                     throw (SALOME::SALOME_Exception) = 0;
         virtual void             addInStudy(SALOMEDS::Study_ptr myStudy , 
                                            SALOME_MED::FIELD_ptr myIor)
-                                    throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection) = 0;
+                                    throw (SALOME::SALOME_Exception) = 0;
         virtual CORBA::Long      addDriver (SALOME_MED::medDriverTypes driverType, 
                                            const char* fileName, 
                                            const char* fieldName)
index 10c6a068e4a3fc057310c8037bd756b7b54d7984..d9e89d87e3800ce2bc4ac836e39ee86a1916f901 100644 (file)
@@ -1,32 +1,11 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : Group_i.cxx
-//  Author : EDF 
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/
+//=============================================================================
+// File      : Group_i.cxx
+// Project   : SALOME
+// Author    : EDF 
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/
+//=============================================================================
 
-using namespace std;
 #include <vector>
 
 #include "utilities.h"
index 35dc8828cde5c9670ceb90b21bcc8f8d5ec5d8a1..12419693bd5d243ac095249e242d0f9dd8230203 100644 (file)
@@ -1,31 +1,10 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : Group_i.hxx
-//  Author : EDF
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Group_i.hxx
-
+//=============================================================================
+// File      : Group_i.hxx
+// Project   : SALOME
+// Author    : EDF
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Group_i.hxx
+//=============================================================================
 #ifndef MED_GROUP_I_HXX_
 #define MED_GROUP_I_HXX_
 
index b3be89ac8046406d4e12967308be7f55ae7b428f..9e3538de87783d60364f84fc970367fca21a1069 100644 (file)
@@ -1,32 +1,11 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : Med_i.cxx
-//  Author : EDF
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Med_i.cxx
-
-using namespace std;
+//=============================================================================
+// File      : Med_i.cxx
+// Project   : SALOME
+// Author    : EDF
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Med_i.cxx
+//=============================================================================
+
 #include <deque>
 
 //#include "MEDMEM_Field.hxx"
@@ -222,36 +201,6 @@ void MED_i::initWithFieldType(SALOMEDS::Study_ptr myStudy,driverTypes driverType
 
   // SUPPORT :
   _med->updateSupport() ;
-  
-  // we add all group and family in study :
-  // we add all families 
-  vector<FAMILY*> familyVector ;
-  vector<FAMILY*>::iterator familyVectorIt ;
-  // we add all groups
-  vector<GROUP*> groupVector ;
-  vector<GROUP*>::iterator groupVectorIt ;
-  
-  MED_FR::MESH_ENTITIES::const_iterator currentEntity; 
-  for (int i=0; i<numberOfMeshes; i++) {
-    ::MESH * ptrMesh = _med->getMesh(meshesNames[i]) ;
-    for (currentEntity=MED_FR::meshEntities.begin();currentEntity != MED_FR::meshEntities.end(); currentEntity++) {
-      // family :
-      familyVector = ptrMesh->getFamilies((MED_EN::medEntityMesh)(*currentEntity).first) ;
-      for(familyVectorIt=familyVector.begin();familyVectorIt!=familyVector.end();familyVectorIt++) {
-       FAMILY_i * myFamilyI = new FAMILY_i(*familyVectorIt);
-       SALOME_MED::FAMILY_ptr myFamilyIOR = myFamilyI->POA_SALOME_MED::FAMILY::_this() ;
-       myFamilyI->addInStudy(myStudy,myFamilyIOR) ;
-      }
-      // group :
-      groupVector = ptrMesh->getGroups((MED_EN::medEntityMesh)(*currentEntity).first) ;
-      for(groupVectorIt=groupVector.begin();groupVectorIt!=groupVector.end();groupVectorIt++) {
-       GROUP_i * myGroupI = new GROUP_i(*groupVectorIt);
-       SALOME_MED::GROUP_ptr myGroupIOR = myGroupI->POA_SALOME_MED::GROUP::_this() ;
-       myGroupI->addInStudy(myStudy,myGroupIOR) ;
-      }
-    }      
-  }
-
   for (int i=0; i<numberOfMeshes; i++) {
     map<MED_FR::med_entite_maillage,::SUPPORT*> mySupports = _med->getSupports(meshesNames[i]) ;
     map<MED_FR::med_entite_maillage,::SUPPORT*>::const_iterator itSupport ;
@@ -808,7 +757,7 @@ throw (SALOME::SALOME_Exception)
  */
 //=============================================================================
 void MED_i::addInStudy(SALOMEDS::Study_ptr myStudy, SALOME_MED::MED_ptr myIor) 
-throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
+throw (SALOME::SALOME_Exception)
 {
        BEGIN_OF("MED_Mesh_i::addInStudy");
         if ( _medId != "" )
@@ -825,7 +774,7 @@ throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
         SALOMEDS::AttributeIOR_var     aIOR;
 
         // Create SComponent labelled 'MED' if it doesn't already exit
-        SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
+        SALOMEDS::SComponent_var medfather = myStudy->FindComponent("Med");
         if ( CORBA::is_nil(medfather) )
         {
          THROW_SALOME_CORBA_EXCEPTION("Component Med not found",
index fb006e63e84fa7b01e4b2249583fb8ae8e6e14b0..c50baec47615345534514b8ad00457a6108e4a09 100644 (file)
@@ -1,30 +1,10 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : Med_i.hxx
-//  Author : EDF
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Med_i.hxx
+//=============================================================================
+// File      : Med_i.hxx
+// Project   : SALOME
+// Author    : EDF
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Med_i.hxx
+//=============================================================================
 
 #ifndef _MED_MED_I_HXX_
 #define _MED_MED_I_HXX_
@@ -99,7 +79,7 @@ public:
                                                throw (SALOME::SALOME_Exception);
     void                   addInStudy(SALOMEDS::Study_ptr myStudy,
                                       SALOME_MED::MED_ptr myIor) 
-                                               throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection);
+                                               throw (SALOME::SALOME_Exception);
 };
 
 #endif /* _MED_MED_I_HXX_ */
index b32dbce0f692d8551b5de88b19c7f7c250aa1e02..261325421ae37df40e91f5129a213a56b0887889 100644 (file)
@@ -1,32 +1,11 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : Mesh_i.cxx
-//  Author : EDF 
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Mesh_i.cxx
+//=============================================================================
+// File      : Mesh_i.cxx
+// Project   : SALOME
+// Author    : EDF 
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Mesh_i.cxx
+//=============================================================================
 
-using namespace std;
 #include <vector>
 
 #include "utilities.h"
@@ -91,7 +70,7 @@ MESH_i::MESH_i(::MESH * const m ) :_mesh(m),
 }
 //=============================================================================
 /*!
- * Constructor par recopie
+ * Copy Constructor 
  */
 //=============================================================================
 //MESH_i::MESH_i(const MESH_i & m) :_mesh(m._mesh),
@@ -105,7 +84,7 @@ MESH_i::MESH_i( MESH_i & m) :_mesh(m._mesh),
 }
 //=============================================================================
 /*!
- * 
+ * Internal Method in order to have a const ptr
  */
 //=============================================================================
 ::MESH * MESH_i::constructConstMesh() const
@@ -198,7 +177,7 @@ throw (SALOME::SALOME_Exception)
  * CORBA: Accessor for Coordinates System
  */
 //=============================================================================
-char * MESH_i::getCoordinateSystem()
+char * MESH_i::getCoordinatesSystem()
 throw (SALOME::SALOME_Exception)
 {
        if (_mesh==NULL)
@@ -460,8 +439,7 @@ MESSAGE("MED_NODAL");
                        const int * tab=_mesh->getConnectivityIndex(
                                convertIdlConnToMedConn(mode),
                                convertIdlEntToMedEnt(entity));
-                       nbelements = elt1*(convertIdlEltToMedElt(geomElement)%100);
-                       //nbelements = tab[elt1 ] - 1 ;
+                       nbelements = tab[elt1 ] - 1 ;
                }
 SCRUTE(entity);
 SCRUTE(geomElement);
@@ -604,7 +582,6 @@ throw (SALOME::SALOME_Exception)
         Engines::long_array_var myseq= new Engines::long_array;
         try
         {
-                //int nbelements= ????
                 int nbelements; 
                if ( mode == SALOME_MED::MED_DESCENDING)
                {
@@ -980,7 +957,7 @@ throw (SALOME::SALOME_Exception)
  */
 //=============================================================================
 void MESH_i::addInStudy(SALOMEDS::Study_ptr myStudy,SALOME_MED::MESH_ptr myIor )
-throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
+throw (SALOME::SALOME_Exception)
 {
        BEGIN_OF("MED_Mesh_i::addInStudy");
        if ( _meshId != "" )
@@ -996,13 +973,12 @@ throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
         SALOMEDS::AttributeIOR_var     aIOR;
 
        // Find SComponent labelled 'MED'
-       SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
+       SALOMEDS::SComponent_var medfather = myStudy->FindComponent("Med");
        if ( CORBA::is_nil(medfather) ) 
          THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
 
        // Create SObject labelled 'MESH' if it doesn't already exit
        SALOMEDS::SObject_var medmeshfather = myStudy->FindObject("MEDMESH");
-       myBuilder->NewCommand();
        if ( CORBA::is_nil(medmeshfather) ) 
        {
                MESSAGE("Add Object MEDMESH");
@@ -1015,6 +991,7 @@ throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
        } ;
 
        MESSAGE("Add a mesh Object under MED/MEDMESH");
+       myBuilder->NewCommand();
        SALOMEDS::SObject_var newObj = myBuilder->NewObject(medmeshfather);
 
        ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
@@ -1038,7 +1015,7 @@ throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
  */
 //=============================================================================
 void MESH_i::addInStudy(SALOMEDS::Study_ptr myStudy,SALOME_MED::MESH_ptr myIor,const string & fileName )
-throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
+throw (SALOME::SALOME_Exception)
 {
         BEGIN_OF("MED_Mesh_i::addInStudy");
         if ( _meshId != "" )
@@ -1055,13 +1032,12 @@ throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
         SALOMEDS::AttributeComment_var aComment;
 
         // Find SComponent labelled 'Med'
-        SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
+        SALOMEDS::SComponent_var medfather = myStudy->FindComponent("Med");
         if ( CORBA::is_nil(medfather) )
           THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
 
         // Create SObject labelled 'MESH' if it doesn't already exit
         SALOMEDS::SObject_var medmeshfather = myStudy->FindObject("MEDMESH");
-        myBuilder->NewCommand();
         if ( CORBA::is_nil(medmeshfather) )
         {
                 MESSAGE("Add Object MEDMESH");
@@ -1074,6 +1050,7 @@ throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
         } ;
 
         MESSAGE("Add a mesh Object under MED/MEDMESH");
+        myBuilder->NewCommand();
         SALOMEDS::SObject_var newObj = myBuilder->NewObject(medmeshfather);
 
         ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
index 68429440e7eee6bef7e9f1ee75a61def37f7a26a..a2b1671147776a4536cbf5180b465a23a35cdad3 100644 (file)
@@ -1,30 +1,10 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : Mesh_i.hxx
-//  Author : EDF 
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Mesh_i.hxx
+//=============================================================================
+// File      : Mesh_i.hxx
+// Project   : SALOME
+// Author    : EDF 
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Mesh_i.hxx
+//=============================================================================
 
 #ifndef _MED_MESH_I_HXX_
 #define _MED_MESH_I_HXX_
@@ -73,7 +53,7 @@ public:
 
   CORBA::Long   getMeshDimension()     throw (SALOME::SALOME_Exception);
   
-  char *                  getCoordinateSystem() 
+  char *                  getCoordinatesSystem() 
     throw (SALOME::SALOME_Exception);
   
   Engines::double_array* getCoordinates(SALOME_MED::medModeSwitch typeSwitch)
@@ -152,10 +132,10 @@ public:
 
     // Others
     void        addInStudy (SALOMEDS::Study_ptr myStudy, 
-                           SALOME_MED::MESH_ptr myIor)   throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection);
+                           SALOME_MED::MESH_ptr myIor)   throw (SALOME::SALOME_Exception);
     void        addInStudy (SALOMEDS::Study_ptr myStudy, 
                            SALOME_MED::MESH_ptr myIor,
-                           const string & fileName)   throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection);
+                           const string & fileName)   throw (SALOME::SALOME_Exception);
     CORBA::Long addDriver  (SALOME_MED::medDriverTypes driverType, 
                            const char* fileName, const char* meshName)
                                                          throw (SALOME::SALOME_Exception);
index ea1d9b39a04544017944daebd6fc8fcc6d4239f3..c82bd554843236c99a90dea12c2a0740c7ec1c75 100644 (file)
@@ -1,32 +1,11 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : Support_i.cxx
-//  Author : EDF
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Support_i.cxx
-
-using namespace std;
+//=============================================================================
+// File      : Support_i.cxx
+// Project   : SALOME
+// Author    : EDF
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Support_i.cxx
+//=============================================================================
+
 #include "utilities.h"
 #include "Utils_CorbaException.hxx"
 #include "Utils_ORB_INIT.hxx"
@@ -292,6 +271,10 @@ throw (SALOME::SALOME_Exception)
 CORBA::Long SUPPORT_i::getNumberOfElements(SALOME_MED::medGeometryElement geomElement) 
 throw (SALOME::SALOME_Exception)
 {
+
+  SCRUTE(geomElement);
+  SCRUTE(SALOME_MED::MED_ALL_ELEMENTS);
+
        if (_support==NULL)
                THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
                                             SALOME::INTERNAL_ERROR);
@@ -317,6 +300,10 @@ throw (SALOME::SALOME_Exception)
 Engines::long_array *  SUPPORT_i::getNumber(SALOME_MED::medGeometryElement geomElement) 
 throw (SALOME::SALOME_Exception)
 {
+  SCRUTE(_support);
+  SCRUTE(geomElement);
+  SCRUTE(convertIdlEltToMedElt(geomElement));
+
        if (_support==NULL)
                THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
                                             SALOME::INTERNAL_ERROR);
@@ -409,16 +396,16 @@ throw (SALOME::SALOME_Exception)
  */
 //=============================================================================
 void SUPPORT_i::addInStudy (SALOMEDS::Study_ptr myStudy, SALOME_MED::SUPPORT_ptr myIor)
-  throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection)
+  throw (SALOME::SALOME_Exception)
 {
   BEGIN_OF("SUPPORT_i::addInStudy");
 
   if ( _supportId != "" )
-    {
+  {
       MESSAGE("Support already in Study");
       THROW_SALOME_CORBA_EXCEPTION("Support already in Study", \
                                   SALOME::BAD_PARAM);
-    };
+  };
   
   SALOMEDS::StudyBuilder_var     myBuilder = myStudy->NewBuilder();
   SALOMEDS::GenericAttribute_var anAttr;
@@ -427,44 +414,50 @@ void SUPPORT_i::addInStudy (SALOMEDS::Study_ptr myStudy, SALOME_MED::SUPPORT_ptr
   
   // Find SComponent labelled 'Med'
   MESSAGE("Find SComponent labelled 'Med'");
-  SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
+  SALOMEDS::SComponent_var medfather = myStudy->FindComponent("Med");
   if ( CORBA::is_nil(medfather) ) 
     THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
   
-  // Find SObject labelled 'MEDMESH'
-  MESSAGE("Find SObject labelled 'MEDMESH'");
-  cerr<<flush;
-  MESSAGE(flush);
   if ( CORBA::is_nil(myStudy) ) 
     THROW_SALOME_CORBA_EXCEPTION("Study deleted !!!",SALOME::INTERNAL_ERROR);
+
+  // Find SObject MESH (represent mesh in support)
   SALOMEDS::SObject_var medmeshfather = myStudy->FindObject("MEDMESH");
-  MESSAGE("Find SObject labelled 'MEDMESH' 2");
-  cerr<<flush;
-  MESSAGE(flush);
-  if ( CORBA::is_nil(medmeshfather) ){ 
-    MESSAGE( "On a leve l exception" << flush);
+  if ( CORBA::is_nil(medmeshfather) )
+  { 
+    cout << "On a leve l exception" << flush;
     THROW_SALOME_CORBA_EXCEPTION("SObject labelled 'MEDMESH' not Found",SALOME::INTERNAL_ERROR);
   }
-  // Find SObject MESH (represent mesh in support)
-  MESSAGE( "Find SObject MESH (represent mesh in support)"<< flush);
-  cerr<<flush;
-  MESSAGE(flush);
+  cout << "Find SObject MESH (represent mesh in support)"<< flush;
+
   string meshName = getMesh()->getName() ;
-  SALOMEDS::SObject_var medsupportfather = myStudy->FindObject(meshName.c_str()); // seulement sous Med : il peut y avoir le meme sous SMESH !!!
+
+               // seulement sous Med : il peut y avoir le meme sous SMESH !!!
+  SALOMEDS::SObject_var medsupportfather = myStudy->FindObject(meshName.c_str()); 
   if ( CORBA::is_nil(medsupportfather) ) 
     THROW_SALOME_CORBA_EXCEPTION("SObject Mesh in Support not Found",SALOME::INTERNAL_ERROR);
   // perhaps add MESH automatically ?
   
   MESSAGE("Add a support Object under MED/MESH/MESHNAME");
-  cerr<<flush;
-  MESSAGE(flush);
-  myBuilder->NewCommand();
-
-  SALOMEDS::SObject_var supportEntry = myStudy->FindObject(_support->getName().c_str()); // c'est pas bon, car il faut rechercher uniquement sous le bon MESH !!!
-  if ( CORBA::is_nil(supportEntry) ) { 
+  SALOMEDS::SObject_var medsupfather = myStudy->FindObject("MEDSUPPORT");
+  if ( CORBA::is_nil(medsupfather) )
+  {
+                MESSAGE("Add Object MEDSUPPORT");
+                medsupfather = myBuilder->NewObject(medmeshfather);
+                anAttr = myBuilder->FindOrCreateAttribute(medsupfather, "AttributeName");
+                aName = SALOMEDS::AttributeName::_narrow(anAttr);
+                aName->SetValue("MEDSUPPORT");
+
+  } ;
+
+
+  //myBuilder->NewCommand();
+  SALOMEDS::SObject_var supportEntry = myStudy->FindObject(_support->getName().c_str());
+                        // c'est pas bon, car il faut rechercher uniquement sous le bon MESH !!!
+  if ( CORBA::is_nil(supportEntry) ) 
+  { 
     // not already in study : we create it !
-    SALOMEDS::SObject_var newObj = myBuilder->NewObject(medsupportfather);
-    
+    SALOMEDS::SObject_var newObj = myBuilder->NewObject(medsupfather);
     ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
     ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
     CORBA::ORB_var &orb = init(0,0);
@@ -476,7 +469,9 @@ void SUPPORT_i::addInStudy (SALOMEDS::Study_ptr myStudy, SALOME_MED::SUPPORT_ptr
     aName = SALOMEDS::AttributeName::_narrow(anAttr);
     aName->SetValue(_support->getName().c_str());
     _supportId = newObj->GetID();
-  } else {
+  } 
+  else 
+  {
     // already in study : put new AttributeIOR !
     ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
     ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
index 58475ab147a8e6d69f9b2bcfd9c8e43cb8c23cc5..8929bf5fde7bc1d211d55239e86fca6afc551e2a 100644 (file)
@@ -1,30 +1,10 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : Support_i.hxx
-//  Author : EDF 
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Support_i.hxx
+//=============================================================================
+// File      : Support_i.hxx
+// Project   : SALOME
+// Author    : EDF 
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Support_i.hxx
+//=============================================================================
 
 #ifndef _MED_SUPPORT_I_HXX_
 #define _MED_SUPPORT_I_HXX_
@@ -84,7 +64,7 @@ public:
   // Others
   void           addInStudy (SALOMEDS::Study_ptr myStudy, 
                          SALOME_MED::SUPPORT_ptr myIor)
-    throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection);
+    throw (SALOME::SALOME_Exception);
   
   //                                   Cuisine interne
   CORBA::Long   getCorbaIndex()   throw (SALOME::SALOME_Exception);
index e0bed847160537f847147ca584722ead4f809e66..9bd0ee293f7fb876881d2970f5b9422e83e9f084 100644 (file)
@@ -1,32 +1,12 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : convert.cxx
-//  Author : EDF
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/convert.cxx
+//=============================================================================
+// File      : convert.cxx
+// Created   : mer fév 20 15:47:57 CET 2002
+// Author    : EDF
+// Project   : SALOME
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/convert.cxx
+//=============================================================================
 
-using namespace std;
 #include "utilities.h"
 #include "Utils_CorbaException.hxx"
 
@@ -66,6 +46,9 @@ throw (SALOME::SALOME_Exception)
 medGeometryElement convertIdlEltToMedElt(SALOME_MED::medGeometryElement element) 
 throw (SALOME::SALOME_Exception)
 {
+
+  SCRUTE(element);
+
   switch (element)
     {
     case SALOME_MED::MED_NONE     :  return MED_NONE;
index f3217d6b97b8ab444b121d589b0bf08801763b72..78a5de6e9a2e420ed9581d2a7e2d56ca0bcbfe3f 100644 (file)
@@ -1,31 +1,11 @@
-//  MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
-//
-//  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : convert.hxx
-//  Author : EDF
-//  Module : MED
-//  $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/convert.hxx
-
+//=============================================================================
+// File      : convert.hxx
+// Created   : mer fév 20 15:47:57 CET 2002
+// Author    : EDF
+// Project   : SALOME
+// Copyright : EDF 2002
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/convert.hxx
+//=============================================================================
 # if ! defined ( __CONVERT_H__ )
 # define __CONVERT_H__