Salome HOME
Initialisation module SMESH_SRC de la base SMESH V1
authoradmin <salome-admin@opencascade.com>
Fri, 7 Mar 2003 14:55:31 +0000 (14:55 +0000)
committeradmin <salome-admin@opencascade.com>
Fri, 7 Mar 2003 14:55:31 +0000 (14:55 +0000)
13 files changed:
src/DriverMED/DriverMED_R_SMDS_Mesh.cxx [new file with mode: 0644]
src/DriverMED/DriverMED_R_SMDS_Mesh.h [new file with mode: 0644]
src/DriverMED/DriverMED_R_SMESHDS_Document.cxx [new file with mode: 0644]
src/DriverMED/DriverMED_R_SMESHDS_Document.h [new file with mode: 0644]
src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx [new file with mode: 0644]
src/DriverMED/DriverMED_R_SMESHDS_Mesh.h [new file with mode: 0644]
src/DriverMED/DriverMED_W_SMDS_Mesh.cxx [new file with mode: 0644]
src/DriverMED/DriverMED_W_SMDS_Mesh.h [new file with mode: 0644]
src/DriverMED/DriverMED_W_SMESHDS_Document.cxx [new file with mode: 0644]
src/DriverMED/DriverMED_W_SMESHDS_Document.h [new file with mode: 0644]
src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx [new file with mode: 0644]
src/DriverMED/DriverMED_W_SMESHDS_Mesh.h [new file with mode: 0644]
src/DriverMED/Makefile.in [new file with mode: 0644]

diff --git a/src/DriverMED/DriverMED_R_SMDS_Mesh.cxx b/src/DriverMED/DriverMED_R_SMDS_Mesh.cxx
new file mode 100644 (file)
index 0000000..3109feb
--- /dev/null
@@ -0,0 +1,477 @@
+#include "DriverMED_R_SMDS_Mesh.h"
+#include "utilities.h"
+
+DriverMED_R_SMDS_Mesh::DriverMED_R_SMDS_Mesh() {
+}
+
+DriverMED_R_SMDS_Mesh::~DriverMED_R_SMDS_Mesh() {
+;
+}
+
+void DriverMED_R_SMDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) {
+  myMesh = aMesh;
+}
+
+void DriverMED_R_SMDS_Mesh::SetFile(string aFile) {
+  myFileId = -1;
+  myFile = aFile;
+}
+
+void DriverMED_R_SMDS_Mesh::SetFileId(med_idt aFileId) {
+  myFileId = aFileId;
+}
+
+void DriverMED_R_SMDS_Mesh::SetMeshId(int aMeshId) {
+  myMeshId = aMeshId;
+}
+
+void DriverMED_R_SMDS_Mesh::Add() {
+  ;
+}
+
+void DriverMED_R_SMDS_Mesh::Read() {
+
+  med_err ret = 0;
+  int i,j,k,l;
+  int numero;
+  char message[200];
+  Standard_Boolean ok;
+  /* nombre d'objets MED */
+  char nom_universel[MED_TAILLE_LNOM+1];
+  med_int long_fichier_en_tete; 
+  char *fichier_en_tete;
+  char version_hdf[10];
+  char version_med[10];
+  med_int nmaa,mdim,nnoe;
+  med_int nmai[MED_NBR_GEOMETRIE_MAILLE],nfac[MED_NBR_GEOMETRIE_FACE];
+  med_int nare[MED_NBR_GEOMETRIE_ARETE];
+  /* nom du maillage */
+  char nommaa[MED_TAILLE_NOM+1];
+  /* noeuds */
+  med_float *coo;
+  char nomcoo[3*MED_TAILLE_PNOM+1];
+  char unicoo[3*MED_TAILLE_PNOM+1];
+  char *nomnoe;
+  med_int *numnoe;
+  med_int *nufano; 
+  med_repere rep;
+  med_booleen inonoe,inunoe;
+  med_mode_switch mode_coo;
+  char str[MED_TAILLE_PNOM+1];
+  /* elements */
+  med_int nsup;
+  med_int edim;
+  med_int taille;
+  med_int elem_id;
+  med_int cmpt = 0;
+  med_int *connectivite;
+  char *nomele;
+  med_int *numele;
+  med_int *nufael;
+  med_booleen inoele, inuele;
+  med_connectivite typ_con;
+  med_geometrie_element typgeo;
+  med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] = {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};
+  med_int desmai[MED_NBR_GEOMETRIE_MAILLE] = {0,2,3,3,3,4,4,4,4,6,6,5,5,5,5};
+  med_int nmailles[MED_NBR_GEOMETRIE_MAILLE];
+  char nommai[MED_NBR_GEOMETRIE_MAILLE] [MED_TAILLE_NOM+1] = {"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"};
+  med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] = {MED_TRIA3,MED_TRIA6,
+                                                MED_QUAD4,MED_QUAD8};
+  med_int desfac[MED_NBR_GEOMETRIE_FACE] = {3,3,4,4};
+  med_int nfaces[MED_NBR_GEOMETRIE_FACE];
+  char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM+1] = {"MED_TRIA3","MED_TRIA6",
+                                                      "MED_QUAD4","MED_QUAD8"};
+  med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] = {MED_SEG2,MED_SEG3};
+  med_int desare[MED_NBR_GEOMETRIE_ARETE] = {2,3};
+  med_int naretes[MED_NBR_GEOMETRIE_ARETE];
+  char nomare[MED_NBR_GEOMETRIE_ARETE] [MED_TAILLE_NOM+1] = {"MED_SEG2","MED_SEG3"};
+  /* familles */
+  med_int nfam;
+  med_int natt,ngro;
+  char *attdes,*gro;
+  med_int *attval,*attide;
+  char nomfam[MED_TAILLE_NOM+1];
+  med_int numfam;
+  char str1[MED_TAILLE_DESC+1];
+  char str2[MED_TAILLE_LNOM+1];
+  
+  char* file2Read;
+  bool locally_managed;
+  SCRUTE(myFileId);
+  if (myFileId==-1) 
+    locally_managed = true;
+  else
+    locally_managed = false;
+
+  if (locally_managed)
+    { 
+    file2Read = (char*)myFile.c_str();
+    myFileId = MEDouvrir(file2Read,MED_LECT);
+    if (myFileId < 0)
+      {
+       fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read);
+       exit(EXIT_FAILURE);
+      }
+    numero = 1;
+    }
+  else
+    numero = myMeshId;
+    
+  typ_con = MED_NOD;
+  mode_coo = MED_FULL_INTERLACE;
+  
+
+  /****************************************************************************
+  *                       NOMBRES D'OBJETS MED                                *
+  ****************************************************************************/
+  fprintf(stdout,"\n(****************************)\n");
+  fprintf(stdout,"(* INFORMATIONS GENERALES : *)\n");
+  fprintf(stdout,"(****************************)\n");
+
+  /* lecture du nom et de la dimension du maillage */
+  fprintf(stdout,"%d %d\n",myFileId,numero);
+  ret = MEDmaaInfo(myFileId,numero,nommaa,&mdim);
+  fprintf(stdout,"%d\n",ret);
+  if (ret < 0)
+    {
+      fprintf(stderr,">> ERREUR : lecture du nom du maillage \n");
+      exit(EXIT_FAILURE);
+    }
+  fprintf(stdout,"- Nom du maillage : <<%s>>\n",nommaa);
+  fprintf(stdout,"- Dimension du maillage : %d\n",mdim);
+
+  /* Combien de noeuds ? */
+  nnoe = MEDnEntMaa(myFileId,nommaa,MED_COOR,MED_NOEUD,MED_POINT1,typ_con);
+  if (nnoe < 0)
+    {
+      fprintf(stderr,">> ERREUR : lecture du nombre de noeuds \n");
+      exit(EXIT_FAILURE);
+    }
+  fprintf(stdout,"- Nombre de noeuds : %d \n",nnoe);
+
+  /* Combien de mailles, faces ou aretes ? */
+  for (i=0;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+    {
+      nmailles[i] = MEDnEntMaa(myFileId,nommaa,MED_CONN,MED_MAILLE,typmai[i],
+                              typ_con);
+      if (nmailles[i] < 0)
+       {
+         fprintf(stderr,">> ERREUR : lecture du nombre de mailles \n");
+         exit(EXIT_FAILURE);
+       }
+      fprintf (stdout,"- Nombre de mailles de type %s : %d \n",nommai[i],nmailles[i]);
+    }
+
+  for (i=0;i<MED_NBR_GEOMETRIE_FACE;i++)
+    {
+      nfaces[i] = MEDnEntMaa(myFileId,nommaa,MED_CONN,MED_FACE,typfac[i],
+                            typ_con);
+      if (nfaces[i] < 0)
+       {
+         fprintf(stderr,">> ERREUR : lecture du nombre de faces \n");
+         exit(EXIT_FAILURE);
+       }
+      fprintf (stdout,"- Nombre de faces de type %s : %d \n",nomfac[i],nfaces[i]);
+    }    
+
+  for (i=0;i<MED_NBR_GEOMETRIE_ARETE;i++)
+    {
+      naretes[i] = MEDnEntMaa(myFileId,nommaa,MED_CONN,MED_ARETE,typare[i],
+                             typ_con); 
+      if (naretes[i] < 0)
+       {
+         fprintf(stderr,">> ERREUR : lecture du nombre d'aretes \n");
+         exit(EXIT_FAILURE);
+       }
+      fprintf (stdout,"- Nombre d'aretes de type %s : %d \n",nomare[i],naretes[i]);
+    }
+
+  /* nombre de familles */
+  nfam = MEDnFam(myFileId,nommaa,0,MED_FAMILLE);
+  if (nfam < 0)
+    {
+      fprintf(stderr,">> ERREUR : lecture du nombre de familles \n");
+      exit(EXIT_FAILURE);
+    }  
+  fprintf(stdout,"- Nombre de familles : %d \n",nfam);
+
+  /****************************************************************************
+  *                       LECTURE DES NOEUDS                                  *
+  ****************************************************************************/
+  fprintf(stdout,"\n(************************)\n");
+  fprintf(stdout,"(* NOEUDS DU MAILLAGE : *)\n");
+  fprintf(stdout,"(************************)\n");
+
+  /* Allocations memoires */
+  /* table des coordonnees 
+     profil : (dimension * nombre de noeuds ) */
+  coo = (med_float*) malloc(sizeof(med_float)*nnoe*mdim);
+  /* table  des numeros, des numeros de familles des noeuds
+     profil : (nombre de noeuds) */
+  numnoe = (med_int*) malloc(sizeof(med_int)*nnoe);
+  nufano = (med_int*) malloc(sizeof(med_int)*nnoe);
+  /* table des noms des noeuds 
+     profil : (nnoe*MED_TAILLE_PNOM+1) */
+  nomnoe = (char*) malloc(MED_TAILLE_PNOM*nnoe+1);
+
+  /* lecture des noeuds : 
+     - coordonnees
+     - noms (optionnel dans un fichier MED) 
+     - numeros (optionnel dans un fichier MED) 
+     - numeros des familles */
+  ret = MEDnoeudsLire(myFileId,nommaa,mdim,coo,mode_coo,&rep,
+                     nomcoo,unicoo,nomnoe,&inonoe,numnoe,&inunoe,
+                     nufano,nnoe);
+  if (ret < 0)
+    strcpy(message,">> ERREUR : lecture des noeuds \n");
+
+  if (inunoe) {
+    for (int i=0;i<nnoe;i++) {
+      ok = myMesh->AddNodeWithID(coo[i*3],coo[i*3+1],coo[i*3+2],numnoe[i]);
+      //fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],coo[i*3+2]);
+    }
+  }
+  else {
+    for (int i=0;i<nnoe;i++) {
+      ok = myMesh->AddNodeWithID(coo[i*3],coo[i*3+1],coo[i*3+2],i+1);
+      //fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],i);
+    }
+  }
+
+  //fprintf(stdout,"\n- Numeros des familles des noeuds : \n");
+  //for (i=0;i<nnoe;i++)
+  //fprintf(stdout," %d ",*(nufano+i));
+  //fprintf(stdout,"\n");
+
+  SCRUTE(myMesh->NbNodes());
+
+  /* liberation memoire */
+  free(coo);
+  free(nomnoe);
+  free(numnoe);
+  free(nufano);
+
+  /****************************************************************************
+  *                       LECTURE DES ELEMENTS                                *
+  ****************************************************************************/
+  fprintf(stdout,"\n(**************************)\n");
+  fprintf(stdout,"(* ELEMENTS DU MAILLAGE : *)\n");
+  fprintf(stdout,"(**************************)");
+  //fprintf(Out,"CELLS\n");
+  /* Lecture des connectivites, noms, numeros des mailles */
+  //printf("%d %d %d %d\n",nmailles[3],nmailles[4],nmailles[5],nmailles[9]);
+
+  if (ret == 0)
+    for (i=0;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+      {
+       if (nmailles[i] > 0 && ret == 0)
+         {
+           /* dimension de la maille */
+           edim = typmai[i] / 100;
+           nsup = 0;
+           if (mdim  == 2 || mdim == 3)
+             if (edim == 1)
+               nsup = 1;
+           if (mdim == 3)
+             if (edim == 2)
+               nsup = 1;
+
+           taille = nsup+typmai[i]%100;
+           //taille = typmai[i]%100;
+           
+           /* allocation memoire */
+           connectivite = (med_int*)malloc(sizeof(med_int)*
+                                           taille*nmailles[i]);
+           nomele = (char*)malloc(sizeof(char)*MED_TAILLE_PNOM*
+                                  nmailles[i]+1);
+           numele = (med_int*)malloc(sizeof(med_int)*
+                                     nmailles[i]);
+           nufael = (med_int*)malloc(sizeof(med_int)*
+                                     nmailles[i]);
+           
+           /* lecture des donnĂ©es */
+           ret = MEDelementsLire(myFileId,nommaa,mdim,connectivite,mode_coo,
+                                 nomele,&inoele,numele,&inuele,nufael,
+                                 nmailles[i],MED_MAILLE,typmai[i],
+                                 typ_con);
+           SCRUTE(typmai[i]);
+           switch (typmai[i])
+             {
+             case MED_SEG2  : {
+               if (inuele) {
+                 for (j=0;j<nmailles[i];j++) {
+                   elem_id=*(numele+j);
+                   ok = myMesh->AddEdgeWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),elem_id);
+                 }
+               }
+               else {
+                 for (j=0;j<nmailles[i];j++) {
+                   cmpt++;
+                   ok = myMesh->AddEdgeWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),cmpt);
+                 }
+               }
+
+               break;
+             }
+             case MED_TRIA3  : {
+               if (inuele) {
+                 for (j=0;j<nmailles[i];j++) {
+                   elem_id=*(numele+j);
+                   ok = myMesh->AddFaceWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),elem_id);
+                   //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2));
+                 }
+               }
+               else {
+                 for (j=0;j<nmailles[i];j++) {
+                   cmpt++;
+                   ok = myMesh->AddFaceWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),cmpt);
+                   //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2));
+                 }
+               }
+
+               break;
+             }
+             case MED_QUAD4  : {
+               if (inuele) {
+                 for (j=0;j<nmailles[i];j++) {
+                   elem_id=*(numele+j);
+                   ok = myMesh->AddFaceWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),elem_id);
+                   //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3));
+                 }
+               }
+               else {
+                 for (j=0;j<nmailles[i];j++) {
+                   cmpt++;
+                   ok = myMesh->AddFaceWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),cmpt);
+                   //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3));
+                 }
+               }
+               break;
+             }
+             case MED_HEXA8  : {
+               if (inuele) {
+                 for (j=0;j<nmailles[i];j++) {
+                   elem_id=*(numele+j);
+                   ok = myMesh->AddVolumeWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),*(connectivite+j*(taille)+4),*(connectivite+j*(taille)+5),*(connectivite+j*(taille)+6),*(connectivite+j*(taille)+7),elem_id);
+                   //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3),*(connectivite+j*(taille-nsup)+4),*(connectivite+j*(taille-nsup)+5),*(connectivite+j*(taille-nsup)+6),*(connectivite+j*(taille-nsup)+7));
+                 }
+               }
+               else {
+                 for (j=0;j<nmailles[i];j++) {
+                   cmpt++;
+                   ok = myMesh->AddVolumeWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),*(connectivite+j*(taille)+4),*(connectivite+j*(taille)+5),*(connectivite+j*(taille)+6),*(connectivite+j*(taille)+7),cmpt);
+                   //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),*(connectivite+j*(taille)+4),*(connectivite+j*(taille)+5),*(connectivite+j*(taille)+6),*(connectivite+j*(taille)+7));
+                 }
+               }
+               break;
+             }
+             default : {
+               break ;
+             }
+             }
+
+           //fprintf(stdout,"\n  - NumĂ©ros de familles : \n");
+           //for (j=0;j<nmailles[i];j++)
+           //fprintf(stdout," %d ",*(nufael+j));
+           
+           /* liberation memoire */
+           free(connectivite);
+           free(nomele);
+           free(numele);
+           free(nufael);
+         }
+      }
+
+  SCRUTE(myMesh->NbEdges());
+  SCRUTE(myMesh->NbFaces());
+  /****************************************************************************
+   *                       LECTURE DES FAMILLES                                *
+   ****************************************************************************/
+  printf("\n(*************************)\n");
+  printf("(* FAMILLES DU MAILLAGE : *)\n");
+  printf("(*************************)\n");
+  if (ret == 0)
+    for (i=0;i<nfam;i++)
+      {
+       
+       /* nombre de groupes */
+       ngro = MEDnFam(myFileId,nommaa,i+1,MED_GROUPE);
+       if (ngro < 0)  
+         {
+           ret = -1;
+           strcpy(message,
+                  ">> ERREUR : lecture du nombre de groupes d'une famille \n");
+         }
+       
+       /* nombre d'attributs */
+       if (ret == 0)
+         {
+           natt = MEDnFam(myFileId,nommaa,i+1,MED_ATTR);
+           if (natt < 0)
+             {
+               ret = -1;
+               strcpy(message,
+                  ">> ERREUR : lecture du nombre d'attributs d'une famille\n");
+             }
+         }
+
+       if (ret == 0)
+         fprintf(stdout,"- Famille %d a %d attributs et %d groupes \n",i+1,natt,ngro); 
+
+       /* nom,numero,attributs,groupes */
+       if (ret == 0)
+         {
+           attide = (med_int*) malloc(sizeof(med_int)*natt);
+           attval = (med_int*) malloc(sizeof(med_int)*natt);       
+           attdes = (char *) malloc(MED_TAILLE_DESC*natt+1);
+           gro = (char*) malloc(MED_TAILLE_LNOM*ngro+1);
+           ret = MEDfamInfo(myFileId,nommaa,i+1,nomfam,&numfam,attide,attval,
+                            attdes,&natt,gro,&ngro);
+           fprintf(stdout,"  - Famille de nom %s et de numero %d : \n",nomfam,numfam);
+           fprintf(stdout,"  - Attributs : \n");
+           for (j=0;j<natt;j++)
+             {
+               strncpy(str1,attdes+j*MED_TAILLE_DESC,MED_TAILLE_DESC);
+               str1[MED_TAILLE_DESC] = '\0';
+               fprintf(stdout,"   ide = %d - val = %d - des = %s\n",*(attide+j),
+                      *(attval+j),str1);
+             }
+            free(attide);
+           free(attval);
+            free(attdes);
+            fprintf(stdout,"  - Groupes :\n");
+           for (j=0;j<ngro;j++)
+             {
+               strncpy(str2,gro+j*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
+               str2[MED_TAILLE_LNOM] = '\0';
+               fprintf(stdout,"   gro = %s\n",str2);
+             }
+            free(gro);
+         }
+      }
+
+  if (locally_managed)
+    ret = MEDfermer(myFileId);
+
+}
diff --git a/src/DriverMED/DriverMED_R_SMDS_Mesh.h b/src/DriverMED/DriverMED_R_SMDS_Mesh.h
new file mode 100644 (file)
index 0000000..a07f499
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef _INCLUDE_DRIVERMED_R_SMDS_MESH
+#define _INCLUDE_DRIVERMED_R_SMDS_MESH
+
+#include "SMDS_Mesh.hxx"
+#include "Mesh_Reader.h"
+
+extern "C"
+{
+#include <med.h>
+}
+
+class DriverMED_R_SMDS_Mesh : public Mesh_Reader {
+
+  public :
+    DriverMED_R_SMDS_Mesh();
+    ~DriverMED_R_SMDS_Mesh();
+
+    void Add();
+    void Read();
+    void SetMesh(Handle(SMDS_Mesh)& aMesh);
+    void SetFile(string);
+
+    void SetFileId(med_idt);
+    void SetMeshId(int);
+
+private :
+    Handle_SMDS_Mesh myMesh;
+    string myFile; 
+    med_idt myFileId;
+    int myMeshId;
+
+};
+#endif
diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Document.cxx b/src/DriverMED/DriverMED_R_SMESHDS_Document.cxx
new file mode 100644 (file)
index 0000000..4624786
--- /dev/null
@@ -0,0 +1,91 @@
+#include "DriverMED_R_SMESHDS_Document.h"
+#include "DriverMED_R_SMESHDS_Mesh.h"
+#include "utilities.h"
+
+extern "C" {
+  Document_Reader* maker() {
+    return new DriverMED_R_SMESHDS_Document;
+  }
+}
+
+DriverMED_R_SMESHDS_Document::DriverMED_R_SMESHDS_Document() {
+;
+}
+
+DriverMED_R_SMESHDS_Document::~DriverMED_R_SMESHDS_Document() {
+;
+}
+
+//void DriverMED_R_SMESHDS_Document::SetFile(string aFile) {
+//  myFile = aFile;
+//}
+
+void DriverMED_R_SMESHDS_Document::Read() {
+
+  med_err ret = 0;
+  med_idt fid;
+  med_int nmaa;
+
+  Standard_Integer myMeshId;
+
+  //string myFile = string("/home/home_users/cai/projects/salome_prev04/SALOME_ROOT/data/fra1.med");
+
+/****************************************************************************
+  *                      OUVERTURE DU FICHIER EN LECTURE                      *
+  ****************************************************************************/
+  char* file2Read = (char*)myFile.c_str();
+  fid = MEDouvrir(file2Read,MED_LECT);
+  if (fid < 0)
+    {
+      fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read);
+      exit(EXIT_FAILURE);
+    }
+
+  /****************************************************************************
+  *                      COMBIEN DE MAILLAGES ?                               *
+  ****************************************************************************/
+  nmaa = MEDnMaa(fid);
+  if (nmaa < 0)
+    {
+      fprintf(stderr,">> ERREUR : lecture du nombre de maillages \n");
+      exit(EXIT_FAILURE);
+    }
+  printf("Nombre de maillages = %d\n",nmaa);
+
+  string myClass = string("SMESHDS_Mesh");
+  string myExtension = string("MED");
+
+
+  for (int meshIt=1;meshIt<=nmaa;meshIt++) {
+    myMeshId = myDocument->NewMesh();
+    printf("MeshId = %d\n",myMeshId);
+
+    Handle(SMDS_Mesh) myMesh = myDocument->GetMesh(myMeshId);
+  SCRUTE(myMesh);
+
+    // Handle (SMDS_Mesh) MMM =.........
+    //ex Handle(SMESHDS_Mesh) myMesh2 =Handle(SMESHDS_Mesh)::DownCast(MMM);
+
+    DriverMED_R_SMESHDS_Mesh* myReader = new DriverMED_R_SMESHDS_Mesh;
+
+    myReader->SetMesh(myMesh);
+    myReader->SetMeshId(myMeshId);
+
+    //myReader->SetFile(myFile);
+  SCRUTE(fid);
+    myReader->SetFileId(fid);
+
+    myReader->Add();
+
+  }
+
+  /****************************************************************************
+  *                      FERMETURE DU FICHIER                                 *
+  ****************************************************************************/
+  ret = MEDfermer(fid);
+  
+  if (ret != 0)
+    fprintf(stderr,">> ERREUR : erreur a la fermeture du fichier %s\n",file2Read);
+
+
+}
diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Document.h b/src/DriverMED/DriverMED_R_SMESHDS_Document.h
new file mode 100644 (file)
index 0000000..4d046f5
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef _INCLUDE_DRIVERMED_R_SMESHDS_DOCUMENT
+#define _INCLUDE_DRIVERMED_R_SMESHDS_DOCUMENT
+
+#include "SMESHDS_Document.hxx"
+#include "Document_Reader.h"
+
+extern "C"
+{
+#include <med.h>
+}
+
+class DriverMED_R_SMESHDS_Document : public Document_Reader {
+  
+public :
+  DriverMED_R_SMESHDS_Document();
+  ~DriverMED_R_SMESHDS_Document();
+  void Read();
+  //void SetFile(string);
+
+private :
+  //Handle_SMESHDS_Document myDocument;
+  //string myFile; 
+
+};
+#endif
diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx
new file mode 100644 (file)
index 0000000..8e7ce6f
--- /dev/null
@@ -0,0 +1,544 @@
+#include "DriverMED_R_SMESHDS_Mesh.h"
+#include "DriverMED_R_SMDS_Mesh.h"
+#include "utilities.h"
+
+#include <stdlib.h>
+
+DriverMED_R_SMESHDS_Mesh::DriverMED_R_SMESHDS_Mesh() {
+  myFileId=-1;
+}
+
+DriverMED_R_SMESHDS_Mesh::~DriverMED_R_SMESHDS_Mesh() {
+;
+}
+
+void DriverMED_R_SMESHDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) {
+  //myMesh = Handle(SMESHDS_Mesh)::DownCast(aMesh);
+  myMesh = aMesh;
+}
+
+void DriverMED_R_SMESHDS_Mesh::SetFile(string aFile) {
+  myFile = aFile;
+}
+
+void DriverMED_R_SMESHDS_Mesh::SetFileId(med_idt aFileId) {
+  myFileId = aFileId;
+}
+
+void DriverMED_R_SMESHDS_Mesh::SetMeshId(int aMeshId) {
+  myMeshId = aMeshId;
+}
+
+void DriverMED_R_SMESHDS_Mesh::Read() {
+
+  string myClass = string("SMDS_Mesh");
+  string myExtension = string("MED");
+
+  DriverMED_R_SMDS_Mesh* myReader = new DriverMED_R_SMDS_Mesh;
+
+  myReader->SetMesh(myMesh);
+  myReader->SetMeshId(myMeshId);
+  myReader->SetFile(myFile);
+  myReader->SetFileId(-1);
+
+  myReader->Read();
+
+}
+
+void DriverMED_R_SMESHDS_Mesh::Add() {
+
+  string myClass = string("SMDS_Mesh");
+  string myExtension = string("MED");
+
+  DriverMED_R_SMDS_Mesh* myReader = new DriverMED_R_SMDS_Mesh;
+
+  myReader->SetMesh(myMesh);
+  myReader->SetMeshId(myMeshId);
+
+  SCRUTE(myFileId);
+  myReader->SetFileId(myFileId);
+
+  myReader->Read();
+
+}
+
+void DriverMED_R_SMESHDS_Mesh::ReadMySelf() {
+
+  med_err ret = 0;
+  int i,j,k,l;
+  int numero;
+  char message[200];
+  Standard_Boolean ok;
+  /* nombre d'objets MED */
+  char nom_universel[MED_TAILLE_LNOM+1];
+  med_int long_fichier_en_tete; 
+  char *fichier_en_tete;
+  char version_hdf[10];
+  char version_med[10];
+  med_int nmaa,mdim,nnoe;
+  med_int nmai[MED_NBR_GEOMETRIE_MAILLE],nfac[MED_NBR_GEOMETRIE_FACE];
+  med_int nare[MED_NBR_GEOMETRIE_ARETE];
+  /* nom du maillage */
+  char nommaa[MED_TAILLE_NOM+1];
+  /* noeuds */
+  med_float *coo;
+  char nomcoo[3*MED_TAILLE_PNOM+1];
+  char unicoo[3*MED_TAILLE_PNOM+1];
+  char *nomnoe;
+  med_int *numnoe;
+  med_int *nufano; 
+  med_repere rep;
+  med_booleen inonoe,inunoe;
+  med_mode_switch mode_coo;
+  char str[MED_TAILLE_PNOM+1];
+  /* elements */
+  med_int nsup;
+  med_int edim;
+  med_int taille;
+  med_int elem_id;
+  med_int cmpt = 0;
+  med_int *connectivite;
+  char *nomele;
+  med_int *numele;
+  med_int *nufael;
+  med_booleen inoele, inuele;
+  med_connectivite typ_con;
+  med_geometrie_element typgeo;
+  med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] = {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};
+  med_int desmai[MED_NBR_GEOMETRIE_MAILLE] = {0,2,3,3,3,4,4,4,4,6,6,5,5,5,5};
+  med_int nmailles[MED_NBR_GEOMETRIE_MAILLE];
+  char nommai[MED_NBR_GEOMETRIE_MAILLE] [MED_TAILLE_NOM+1] = {"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"};
+  med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] = {MED_TRIA3,MED_TRIA6,
+                                                MED_QUAD4,MED_QUAD8};
+  med_int desfac[MED_NBR_GEOMETRIE_FACE] = {3,3,4,4};
+  med_int nfaces[MED_NBR_GEOMETRIE_FACE];
+  char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM+1] = {"MED_TRIA3","MED_TRIA6",
+                                                      "MED_QUAD4","MED_QUAD8"};
+  med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] = {MED_SEG2,MED_SEG3};
+  med_int desare[MED_NBR_GEOMETRIE_ARETE] = {2,3};
+  med_int naretes[MED_NBR_GEOMETRIE_ARETE];
+  char nomare[MED_NBR_GEOMETRIE_ARETE] [MED_TAILLE_NOM+1] = {"MED_SEG2","MED_SEG3"};
+  /* familles */
+  med_int nfam;
+  med_int natt,ngro;
+  char *attdes,*gro;
+  med_int *attval,*attide;
+  char nomfam[MED_TAILLE_NOM+1];
+  med_int numfam;
+  char str1[MED_TAILLE_DESC+1];
+  char str2[MED_TAILLE_LNOM+1];
+  string fam;
+  string fam_type;
+  string fam_id;
+  
+  char* file2Read;
+  bool locally_managed;
+
+  if (myFileId==-1) 
+    locally_managed = true;
+  else
+    locally_managed = false;
+
+  if (locally_managed)
+    { 
+    file2Read = (char*)myFile.c_str();
+    myFileId = MEDouvrir(file2Read,MED_LECT);
+    if (myFileId < 0)
+      {
+       fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read);
+       exit(EXIT_FAILURE);
+      }
+    numero = 1;
+    }
+  else
+    numero = myMeshId;
+  sprintf(nommaa,"Mesh %d",myMeshId);//pour load
+  SCRUTE(nommaa);
+    
+  typ_con = MED_NOD;
+  mode_coo = MED_FULL_INTERLACE;
+  mdim = 3;
+
+  Handle(SMESHDS_Mesh) mySMESHDSMesh = Handle(SMESHDS_Mesh)::DownCast(myMesh);
+
+  //TopoDS_Shape myShape = mySMESHDSMesh->ShapeToMesh();
+
+  /****************************************************************************
+  *                       NOMBRES D'OBJETS MED                                *
+  ****************************************************************************/
+  fprintf(stdout,"\n(****************************)\n");
+  fprintf(stdout,"(* INFORMATIONS GENERALES : *)\n");
+  fprintf(stdout,"(****************************)\n");
+
+  /* lecture du nom et de la dimension du maillage */
+  /*!  fprintf(stdout,"%d %d\n",myFileId,numero);
+  ret = MEDmaaInfo(myFileId,numero,nommaa,&mdim);
+  fprintf(stdout,"%d\n",ret);
+  if (ret < 0)
+    {
+      fprintf(stderr,">> ERREUR : lecture du nom du maillage \n");
+      exit(EXIT_FAILURE);
+    }
+  fprintf(stdout,"- Nom du maillage : <<%s>>\n",nommaa);
+  fprintf(stdout,"- Dimension du maillage : %d\n",mdim);
+  */
+  /* Combien de noeuds ? */
+  nnoe = MEDnEntMaa(myFileId,nommaa,MED_COOR,MED_NOEUD,MED_POINT1,typ_con);
+  if (nnoe < 0)
+    {
+      fprintf(stderr,">> ERREUR : lecture du nombre de noeuds \n");
+      exit(EXIT_FAILURE);
+    }
+  fprintf(stdout,"- Nombre de noeuds : %d \n",nnoe);
+
+  /* Combien de mailles, faces ou aretes ? */
+  for (i=0;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+    {
+      nmailles[i] = MEDnEntMaa(myFileId,nommaa,MED_CONN,MED_MAILLE,typmai[i],
+                              typ_con);
+      if (nmailles[i] < 0)
+       {
+         fprintf(stderr,">> ERREUR : lecture du nombre de mailles \n");
+         exit(EXIT_FAILURE);
+       }
+      fprintf (stdout,"- Nombre de mailles de type %s : %d \n",nommai[i],nmailles[i]);
+    }
+
+  for (i=0;i<MED_NBR_GEOMETRIE_FACE;i++)
+    {
+      nfaces[i] = MEDnEntMaa(myFileId,nommaa,MED_CONN,MED_FACE,typfac[i],
+                            typ_con);
+      if (nfaces[i] < 0)
+       {
+         fprintf(stderr,">> ERREUR : lecture du nombre de faces \n");
+         exit(EXIT_FAILURE);
+       }
+      fprintf (stdout,"- Nombre de faces de type %s : %d \n",nomfac[i],nfaces[i]);
+    }    
+
+  for (i=0;i<MED_NBR_GEOMETRIE_ARETE;i++)
+    {
+      naretes[i] = MEDnEntMaa(myFileId,nommaa,MED_CONN,MED_ARETE,typare[i],
+                             typ_con); 
+      if (naretes[i] < 0)
+       {
+         fprintf(stderr,">> ERREUR : lecture du nombre d'aretes \n");
+         exit(EXIT_FAILURE);
+       }
+      fprintf (stdout,"- Nombre d'aretes de type %s : %d \n",nomare[i],naretes[i]);
+    }
+
+  /* nombre de familles */
+  nfam = MEDnFam(myFileId,nommaa,0,MED_FAMILLE);
+  if (nfam < 0)
+    {
+      fprintf(stderr,">> ERREUR : lecture du nombre de familles \n");
+      exit(EXIT_FAILURE);
+    }  
+  fprintf(stdout,"- Nombre de familles : %d \n",nfam);
+
+  vector<int> family[nfam];
+
+  /****************************************************************************
+  *                       LECTURE DES NOEUDS                                  *
+  ****************************************************************************/
+  fprintf(stdout,"\n(************************)\n");
+  fprintf(stdout,"(* NOEUDS DU MAILLAGE : *)\n");
+  fprintf(stdout,"(************************)\n");
+
+  /* Allocations memoires */
+  /* table des coordonnees 
+     profil : (dimension * nombre de noeuds ) */
+  coo = (med_float*) malloc(sizeof(med_float)*nnoe*mdim);
+  /* table  des numeros, des numeros de familles des noeuds
+     profil : (nombre de noeuds) */
+  numnoe = (med_int*) malloc(sizeof(med_int)*nnoe);
+  nufano = (med_int*) malloc(sizeof(med_int)*nnoe);
+  /* table des noms des noeuds 
+     profil : (nnoe*MED_TAILLE_PNOM+1) */
+  nomnoe = (char*) malloc(MED_TAILLE_PNOM*nnoe+1);
+
+  /* lecture des noeuds : 
+     - coordonnees
+     - noms (optionnel dans un fichier MED) 
+     - numeros (optionnel dans un fichier MED) 
+     - numeros des familles */
+  ret = MEDnoeudsLire(myFileId,nommaa,mdim,coo,mode_coo,&rep,
+                     nomcoo,unicoo,nomnoe,&inonoe,numnoe,&inunoe,
+                     nufano,nnoe);
+  if (ret < 0)
+    strcpy(message,">> ERREUR : lecture des noeuds \n");
+
+  if (inunoe) {
+    for (int i=0;i<nnoe;i++) {
+      ok = mySMESHDSMesh->AddNodeWithID(coo[i*3],coo[i*3+1],coo[i*3+2],numnoe[i]);
+      //fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],coo[i*3+2]);
+    }
+  }
+  else {
+    for (int i=0;i<nnoe;i++) {
+      ok = mySMESHDSMesh->AddNodeWithID(coo[i*3],coo[i*3+1],coo[i*3+2],i+1);
+      //fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],i);
+      family[*(nufano+i)].push_back(numnoe[i]);
+    }
+  }
+
+  fprintf(stdout,"\n- Numeros des familles des noeuds : \n");
+  for (i=0;i<nnoe;i++)
+    fprintf(stdout," %d ",*(nufano+i));
+  fprintf(stdout,"\n");
+
+  /* liberation memoire */
+  free(coo);
+  free(nomnoe);
+  free(numnoe);
+  free(nufano);
+
+  /****************************************************************************
+  *                       LECTURE DES ELEMENTS                                *
+  ****************************************************************************/
+  fprintf(stdout,"\n(**************************)\n");
+  fprintf(stdout,"(* ELEMENTS DU MAILLAGE : *)\n");
+  fprintf(stdout,"(**************************)");
+  //fprintf(Out,"CELLS\n");
+  /* Lecture des connectivites, noms, numeros des mailles */
+  //printf("%d %d %d %d\n",nmailles[3],nmailles[4],nmailles[5],nmailles[9]);
+
+  if (ret == 0)
+    for (i=0;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+      {
+       if (nmailles[i] > 0 && ret == 0)
+         {
+           /* dimension de la maille */
+           edim = typmai[i] / 100;
+           nsup = 0;
+           if (mdim  == 2 || mdim == 3)
+             if (edim == 1)
+               nsup = 1;
+           if (mdim == 3)
+             if (edim == 2)
+               nsup = 1;
+
+           taille = nsup+typmai[i]%100;
+           //taille = typmai[i]%100;
+           
+           /* allocation memoire */
+           connectivite = (med_int*)malloc(sizeof(med_int)*
+                                           taille*nmailles[i]);
+           nomele = (char*)malloc(sizeof(char)*MED_TAILLE_PNOM*
+                                  nmailles[i]+1);
+           numele = (med_int*)malloc(sizeof(med_int)*
+                                     nmailles[i]);
+           nufael = (med_int*)malloc(sizeof(med_int)*
+                                     nmailles[i]);
+           
+           /* lecture des donnĂ©es */
+           ret = MEDelementsLire(myFileId,nommaa,mdim,connectivite,mode_coo,
+                                 nomele,&inoele,numele,&inuele,nufael,
+                                 nmailles[i],MED_MAILLE,typmai[i],
+                                 typ_con);
+
+           switch (typmai[i])
+             {
+             case MED_TRIA3  : {
+               if (inuele) {
+                 for (j=0;j<nmailles[i];j++) {
+                   elem_id=*(numele+j);
+                   ok = mySMESHDSMesh->AddFaceWithID(*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),elem_id);
+                   //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2));
+                 }
+               }
+               else {
+                 for (j=0;j<nmailles[i];j++) {
+                   cmpt++;
+                   ok = mySMESHDSMesh->AddFaceWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),cmpt);
+                   //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2));
+                 }
+               }
+
+               break;
+             }
+             case MED_QUAD4  : {
+               if (inuele) {
+                 for (j=0;j<nmailles[i];j++) {
+                   elem_id=*(numele+j);
+                   ok = mySMESHDSMesh->AddFaceWithID(*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3),elem_id);
+                   //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3));
+                 }
+               }
+               else {
+                 for (j=0;j<nmailles[i];j++) {
+                   cmpt++;
+                   ok = myMesh->AddFaceWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),cmpt);
+                   //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3));
+                 }
+               }
+               break;
+             }
+             case MED_HEXA8  : {
+               if (inuele) {
+                 for (j=0;j<nmailles[i];j++) {
+                   elem_id=*(numele+j);
+                   ok = mySMESHDSMesh->AddVolumeWithID(*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3),*(connectivite+j*(taille-nsup)+4),*(connectivite+j*(taille-nsup)+5),*(connectivite+j*(taille-nsup)+6),*(connectivite+j*(taille-nsup)+7),elem_id);
+                   //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3),*(connectivite+j*(taille-nsup)+4),*(connectivite+j*(taille-nsup)+5),*(connectivite+j*(taille-nsup)+6),*(connectivite+j*(taille-nsup)+7));
+                 }
+               }
+               else {
+                 for (j=0;j<nmailles[i];j++) {
+                   cmpt++;
+                   ok = mySMESHDSMesh->AddVolumeWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),*(connectivite+j*(taille)+4),*(connectivite+j*(taille)+5),*(connectivite+j*(taille)+6),*(connectivite+j*(taille)+7),cmpt);
+                   //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),*(connectivite+j*(taille)+4),*(connectivite+j*(taille)+5),*(connectivite+j*(taille)+6),*(connectivite+j*(taille)+7));
+                 }
+               }
+               break;
+             }
+             default : {
+               break ;
+             }
+             }
+
+           fprintf(stdout,"\n  - NumĂ©ros de familles : \n");
+           for (j=0;j<nmailles[i];j++)
+             fprintf(stdout," %d ",*(nufael+j));
+           
+           /* liberation memoire */
+           free(connectivite);
+           free(nomele);
+           free(numele);
+           free(nufael);
+         }
+      }
+
+  /****************************************************************************
+   *                       LECTURE DES FAMILLES                                *
+   ****************************************************************************/
+  printf("\n(*************************)\n");
+  printf("(* FAMILLES DU MAILLAGE : *)\n");
+  printf("(*************************)\n");
+  if (ret == 0)
+    for (i=0;i<nfam;i++)
+      {
+       
+       /* nombre de groupes */
+       ngro = MEDnFam(myFileId,nommaa,i+1,MED_GROUPE);
+       if (ngro < 0)  
+         {
+           ret = -1;
+           strcpy(message,
+                  ">> ERREUR : lecture du nombre de groupes d'une famille \n");
+         }
+       
+       /* nombre d'attributs */
+       if (ret == 0)
+         {
+           natt = MEDnFam(myFileId,nommaa,i+1,MED_ATTR);
+           if (natt < 0)
+             {
+               ret = -1;
+               strcpy(message,
+                  ">> ERREUR : lecture du nombre d'attributs d'une famille\n");
+             }
+         }
+
+       if (ret == 0)
+         fprintf(stdout,"- Famille %d a %d attributs et %d groupes \n",i+1,natt,ngro); 
+
+       /* nom,numero,attributs,groupes */
+       if (ret == 0)
+         {
+           attide = (med_int*) malloc(sizeof(med_int)*natt);
+           attval = (med_int*) malloc(sizeof(med_int)*natt);       
+           attdes = (char *) malloc(MED_TAILLE_DESC*natt+1);
+           gro = (char*) malloc(MED_TAILLE_LNOM*ngro+1);
+           ret = MEDfamInfo(myFileId,nommaa,i+1,nomfam,&numfam,attide,attval,
+                            attdes,&natt,gro,&ngro);
+
+           fam = string(nomfam);
+           fam_type = fam.substr(1,1);
+           fam_id = fam.substr(2,1);
+           if ((fam_type==string("V"))||(fam_type==string("A"))||(fam_type==string("F")))
+             LinkMeshToShape(fam_type, fam_id, family[i]);
+
+           fprintf(stdout,"  - Famille de nom %s et de numero %d : \n",nomfam,numfam);
+           fprintf(stdout,"  - Attributs : \n");
+           for (j=0;j<natt;j++)
+             {
+               strncpy(str1,attdes+j*MED_TAILLE_DESC,MED_TAILLE_DESC);
+               str1[MED_TAILLE_DESC] = '\0';
+               fprintf(stdout,"   ide = %d - val = %d - des = %s\n",*(attide+j),
+                      *(attval+j),str1);
+             }
+            free(attide);
+           free(attval);
+            free(attdes);
+            fprintf(stdout,"  - Groupes :\n");
+           for (j=0;j<ngro;j++)
+             {
+               strncpy(str2,gro+j*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
+               str2[MED_TAILLE_LNOM] = '\0';
+               fprintf(stdout,"   gro = %s\n",str2);
+             }
+            free(gro);
+         }
+      }
+
+  if (locally_managed)
+    ret = MEDfermer(myFileId);
+
+}
+
+void DriverMED_R_SMESHDS_Mesh::LinkMeshToShape(string fam_type, string fam_id, vector<int> myNodes) {
+
+  Handle(SMESHDS_Mesh) mySMESHDSMesh = Handle(SMESHDS_Mesh)::DownCast(myMesh);
+
+  int id = atoi(fam_id.c_str());
+  if (fam_type==string("V")) { //Linked to a vertex
+    for (int i=0;i<myNodes.size();i++) {
+      Handle(SMDS_MeshElement) elem = mySMESHDSMesh->FindNode(myNodes[i]);
+      const Handle(SMDS_MeshNode)& node = mySMESHDSMesh->GetNode(1,elem);
+      //const TopoDS_Vertex& S;//le recuperer !!!
+      //mySMESHDSMesh->SetNodeOnVertex (node,S);
+    }
+  }
+  else 
+  if (fam_type==string("E")) { //Linked to an edge
+    for (int i=0;i<myNodes.size();i++) {
+      Handle(SMDS_MeshElement) elem = mySMESHDSMesh->FindNode(myNodes[i]);
+      const Handle(SMDS_MeshNode)& node = mySMESHDSMesh->GetNode(1,elem);
+      //const TopoDS_Edge& S;//le recuperer !!!
+      //mySMESHDSMesh->SetNodeOnEdge (node,S);
+    }
+  }
+  else 
+  if (fam_type==string("F")) { //Linked to a face
+    for (int i=0;i<myNodes.size();i++) {
+      Handle(SMDS_MeshElement) elem = mySMESHDSMesh->FindNode(myNodes[i]);
+      const Handle(SMDS_MeshNode)& node = mySMESHDSMesh->GetNode(1,elem);
+      //const TopoDS_Face& S;//le recuperer !!!
+      //mySMESHDSMesh->SetNodeOnFace (node,S);
+    }
+  }
+
+}
+
diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.h b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.h
new file mode 100644 (file)
index 0000000..bfbe24a
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef _INCLUDE_DRIVERMED_R_SMESHDS_MESH
+#define _INCLUDE_DRIVERMED_R_SMESHDS_MESH
+
+#include "SMESHDS_Mesh.hxx"
+#include "Mesh_Reader.h"
+
+#include <vector>
+extern "C"
+{
+#include <med.h>
+}
+
+class DriverMED_R_SMESHDS_Mesh : public Mesh_Reader {
+
+  public :
+    DriverMED_R_SMESHDS_Mesh();
+    ~DriverMED_R_SMESHDS_Mesh();
+
+    void Read();
+    void ReadMySelf();
+    void Add();
+
+    void SetMesh(Handle(SMDS_Mesh)& aMesh);
+    void SetFile(string);
+    void SetFileId(med_idt);
+    void SetMeshId(int);
+
+    void LinkMeshToShape(string , string , vector<int>);
+
+private :
+    Handle_SMDS_Mesh myMesh;
+    string myFile; 
+    med_idt myFileId;
+    int myMeshId;
+
+};
+#endif
diff --git a/src/DriverMED/DriverMED_W_SMDS_Mesh.cxx b/src/DriverMED/DriverMED_W_SMDS_Mesh.cxx
new file mode 100644 (file)
index 0000000..8e99c37
--- /dev/null
@@ -0,0 +1,352 @@
+#include "DriverMED_W_SMDS_Mesh.h"
+
+#include "SMDS_MeshElement.hxx"
+#include "SMDS_MeshNode.hxx"
+#include "SMDS_MeshFacesIterator.hxx"
+#include "SMDS_MeshNodesIterator.hxx"
+#include "SMDS_MeshVolumesIterator.hxx"
+
+#include "utilities.h"
+#include <vector>
+
+DriverMED_W_SMDS_Mesh::DriverMED_W_SMDS_Mesh() {
+;
+}
+
+DriverMED_W_SMDS_Mesh::~DriverMED_W_SMDS_Mesh() {
+;
+}
+
+void DriverMED_W_SMDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) {
+  myMesh = aMesh;
+}
+
+void DriverMED_W_SMDS_Mesh::SetFile(string aFile) {
+  myFile = aFile;
+}
+
+void DriverMED_W_SMDS_Mesh::SetFileId(med_idt aFileId) {
+  myFileId = aFileId;
+}
+
+void DriverMED_W_SMDS_Mesh::SetMeshId(int aMeshId) {
+  myMeshId = aMeshId;
+}
+
+void DriverMED_W_SMDS_Mesh::Add() {
+  ;
+}
+
+void DriverMED_W_SMDS_Mesh::Write() {
+
+  med_err ret = 0;
+  int i,j,k,l;
+  int numero;
+  char message[200];
+  Standard_Boolean ok;
+  /* nombre d'objets MED */
+  char nom_universel[MED_TAILLE_LNOM+1];
+  med_int long_fichier_en_tete; 
+  char *fichier_en_tete;
+  char version_hdf[10];
+  char version_med[10];
+  med_int nmaa,mdim,nnoe;
+  med_int nmai[MED_NBR_GEOMETRIE_MAILLE],nfac[MED_NBR_GEOMETRIE_FACE];
+  med_int nare[MED_NBR_GEOMETRIE_ARETE];
+  /* nom du maillage */
+  char nommaa[MED_TAILLE_NOM+1];
+  /* noeuds */
+  med_float *coo;
+  char nomcoo[3*MED_TAILLE_PNOM+1];
+  char unicoo[3*MED_TAILLE_PNOM+1];
+  char *nomnoe;
+  med_int *numnoe;
+  med_int *nufano; 
+  med_repere rep;
+  med_booleen inonoe,inunoe;
+  med_mode_switch mode_coo;
+  char str[MED_TAILLE_PNOM+1];
+  med_int nbNodes;
+  /* elements */
+  med_int nsup;
+  med_int edim;
+  med_int taille;
+  med_int elem_id,myId;
+  med_int *connectivite;
+  char *nomele;
+  med_int *numele;
+  med_int *nufael;
+  med_booleen inoele, inuele;
+  med_connectivite typ_con;
+  med_geometrie_element typgeo;
+  med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] = {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};
+  med_int desmai[MED_NBR_GEOMETRIE_MAILLE] = {0,2,3,3,3,4,4,4,4,6,6,5,5,5,5};
+  med_int nmailles[MED_NBR_GEOMETRIE_MAILLE];
+  char nommai[MED_NBR_GEOMETRIE_MAILLE] [MED_TAILLE_NOM+1] = {"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"};
+  med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] = {MED_TRIA3,MED_TRIA6,
+                                                MED_QUAD4,MED_QUAD8};
+  med_int desfac[MED_NBR_GEOMETRIE_FACE] = {3,3,4,4};
+  med_int nfaces[MED_NBR_GEOMETRIE_FACE];
+  char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM+1] = {"MED_TRIA3","MED_TRIA6",
+                                                      "MED_QUAD4","MED_QUAD8"};
+  med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] = {MED_SEG2,MED_SEG3};
+  med_int desare[MED_NBR_GEOMETRIE_ARETE] = {2,3};
+  med_int naretes[MED_NBR_GEOMETRIE_ARETE];
+  char nomare[MED_NBR_GEOMETRIE_ARETE] [MED_TAILLE_NOM+1] = {"MED_SEG2","MED_SEG3"};
+  /* familles */
+  med_int nfam;
+  med_int natt,ngro;
+  char *attdes,*gro;
+  med_int *attval,*attide;
+  char nomfam[MED_TAILLE_NOM+1];
+  med_int numfam;
+  char str1[MED_TAILLE_DESC+1];
+  char str2[MED_TAILLE_LNOM+1];
+
+  /****************************************************************************
+  *                      OUVERTURE DU FICHIER EN ECRITURE                      *
+  ****************************************************************************/
+  /*!  char* file2Read = (char*)myFile.c_str();
+  myFileId = MEDouvrir(file2Read,MED_REMP);
+  if (myFileId < 0)
+    {
+      fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read);
+      exit(EXIT_FAILURE);
+    }
+  */
+  typ_con = MED_NOD;
+  mode_coo = MED_FULL_INTERLACE;
+  numero = myMeshId;
+
+  /****************************************************************************
+  *                       NOMBRES D'OBJETS MED                                *
+  ****************************************************************************/
+  fprintf(stdout,"\n(****************************)\n");
+  fprintf(stdout,"(* INFORMATIONS GENERALES : *)\n");
+  fprintf(stdout,"(****************************)\n");
+
+  /* creation du maillage */
+  mdim=3;
+  //nommaa = QString("Mesh "+myMeshId).latin1();
+  //nommaa = "";
+  //plutot recuperer le nom du maillage dans l'etude
+  if (ret == 0)
+    ret = MEDmaaCr(myFileId,nommaa,mdim);
+  printf("%d\n",ret);
+
+      
+  /* Combien de noeuds ? */
+  nnoe = myMesh->NbNodes();
+  //SCRUTE(nnoe);
+  /* Combien de mailles, faces ou aretes ? */
+  for (i=0;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+    nmailles[i]=0;
+
+  SMDS_MeshFacesIterator itFaces(myMesh);
+  Standard_Integer nb_of_nodes, nb_of_faces;
+  nb_of_faces = myMesh->NbFaces();
+  //SCRUTE(nb_of_faces);
+
+  //med_int elem_Id[MED_NBR_GEOMETRIE_FACE][nb_of_faces];
+  vector<int> elem_Id[MED_NBR_GEOMETRIE_MAILLE];
+  //typedef vector<int> Integer_vector;
+  //vector<Integer_vector> elem_Id;
+  //elem_Id.resize(MED_NBR_GEOMETRIE_MAILLE);
+   
+  for (;itFaces.More();itFaces.Next()) {
+    const Handle(SMDS_MeshElement)& elem = itFaces.Value();
+
+    nb_of_nodes = elem->NbNodes();
+
+    switch (nb_of_nodes) {
+    case 3 : {
+      //elem_Id[3][nmailles[3]] = elem->GetID();
+      elem_Id[3].push_back(elem->GetID());
+      nmailles[3]++;
+      break;
+    }
+    case 4 : {
+      //elem_Id[5][nmailles[5]] = elem->GetID();
+      elem_Id[5].push_back(elem->GetID());
+      nmailles[5]++;
+      break;
+    }
+    case 6 : {
+      //elem_Id[4][nmailles[4]] = elem->GetID();
+      elem_Id[4].push_back(elem->GetID());
+      nmailles[4]++;
+      break;
+    }
+    }
+
+  }
+
+  SMDS_MeshVolumesIterator itVolumes(myMesh);
+   
+  for (;itVolumes.More();itVolumes.Next()) {
+    const Handle(SMDS_MeshElement)& elem = itVolumes.Value();
+
+    nb_of_nodes = elem->NbNodes();
+    switch (nb_of_nodes) {
+    case 8 : {
+      //elem_Id[9][nmailles[9]] = elem->GetID();
+      elem_Id[9].push_back(elem->GetID());
+      nmailles[9]++;
+      break;
+    }
+    }
+  }
+
+  /****************************************************************************
+  *                       ECRITURE DES NOEUDS                                  *
+  ****************************************************************************/
+  fprintf(stdout,"\n(************************)\n");
+  fprintf(stdout,"(* NOEUDS DU MAILLAGE : *)\n");
+  fprintf(stdout,"(************************)\n");
+
+  /* Allocations memoires */
+  /* table des coordonnees 
+     profil : (dimension * nombre de noeuds ) */
+  coo = (med_float*) malloc(sizeof(med_float)*nnoe*mdim);
+  /* table  des numeros, des numeros de familles des noeuds
+     profil : (nombre de noeuds) */
+  numnoe = (med_int*) malloc(sizeof(med_int)*nnoe);
+  nufano = (med_int*) malloc(sizeof(med_int)*nnoe);
+  /* table des noms des noeuds 
+     profil : (nnoe*MED_TAILLE_PNOM+1) */
+  nomnoe ="";
+
+  i = 0;
+  SMDS_MeshNodesIterator itNodes(myMesh);
+  for (;itNodes.More();itNodes.Next()) {
+    const Handle(SMDS_MeshElement)& elem = itNodes.Value();
+    const Handle(SMDS_MeshNode)& node = myMesh->GetNode(1,elem);
+    coo[i*3]=node->X();
+    coo[i*3+1]=node->Y();
+    coo[i*3+2]=node->Z();
+    numnoe[i]=node->GetID();
+    nufano[i]=0;
+    i++;
+  }
+    
+  /* ecriture des noeuds : 
+     - coordonnees
+     - noms (optionnel dans un fichier MED) 
+     - numeros (optionnel dans un fichier MED) 
+     - numeros des familles */
+  ret = MEDnoeudsEcr(myFileId,nommaa,mdim,coo,mode_coo,MED_CART,
+                      nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
+                      nufano,nnoe,MED_REMP);
+
+  /* liberation memoire */
+  free(coo);
+  //free(nomnoe);
+  free(numnoe);
+  free(nufano);
+
+  /****************************************************************************
+  *                       ECRITURE DES ELEMENTS                                *
+  ****************************************************************************/
+  fprintf(stdout,"\n(**************************)\n");
+  fprintf(stdout,"(* ELEMENTS DU MAILLAGE : *)\n");
+  fprintf(stdout,"(**************************)");
+  //fprintf(Out,"CELLS\n");
+  /* Ecriture des connectivites, noms, numeros des mailles */
+
+  if (ret == 0)
+    for (i=0;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+      {
+       if (nmailles[i] > 0 && ret == 0)
+         {
+           MESSAGE ( " Start "<<typmai[i]);
+           /* dimension de la maille */
+           edim = typmai[i] / 100;
+           nsup = 0;
+           if (mdim  == 2 || mdim == 3)
+             if (edim == 1)
+               nsup = 1;
+           if (mdim == 3)
+             if (edim == 2)
+               nsup = 1;
+
+           taille = nsup+typmai[i]%100;
+           //taille = typmai[i]%100;
+           
+           /* allocation memoire */
+           connectivite = (med_int*)malloc(sizeof(med_int)*
+                                           taille*nmailles[i]);
+           nomele = (char*)malloc(sizeof(char)*MED_TAILLE_PNOM*
+                                  nmailles[i]+1);
+           numele = (med_int*)malloc(sizeof(med_int)*
+                                     nmailles[i]);
+           nufael = (med_int*)malloc(sizeof(med_int)*
+                                     nmailles[i]);
+           nomele="";
+           nbNodes=typmai[i]%100;
+
+           //penser a mater les (taille-nsup)
+           for (j=0;j<nmailles[i];j++) {
+             myId = elem_Id[i][j];
+             const Handle(SMDS_MeshElement)& elem = myMesh->FindElement(myId);
+             *(numele+j) = myId;
+             //elem_id=*(numele+j);
+             //fprintf(stdout,"%d \n",myId);
+
+             for (k=0; k<nbNodes; k++) {
+               //*(connectivite+j*(taille-1)+k)=cnx[k];
+               *(connectivite+j*(taille-nsup)+k) = elem->GetConnection(k+1);
+               //fprintf(stdout,"%d ",*(connectivite+j*(taille-nsup)+k));
+             }
+             nufael[j]=0;
+             //fprintf(stdout,"\n");
+           }
+
+           /* ecriture des donnĂ©es */
+
+           ret=MEDelementsEcr(myFileId,nommaa,mdim,connectivite,mode_coo,nomele,MED_FAUX,numele,MED_VRAI,nufael,nmailles[i],MED_MAILLE,typmai[i],typ_con,MED_REMP);
+
+           if (ret < 0)
+             MESSAGE(">> ERREUR : lecture des mailles \n");
+
+           /* liberation memoire */
+           free(connectivite);
+           //free(nomele);
+           free(numele);
+           free(nufael);
+           MESSAGE ( " End "<<typmai[i]);
+         }
+      }
+
+  /****************************************************************************
+  *                      FERMETURE DU FICHIER                                 *
+  ****************************************************************************/
+
+           /*!  ret = MEDfermer(myFileId);
+
+  if (ret != 0)
+    fprintf(stderr,">> ERREUR : erreur a la fermeture du fichier %s\n",file2Read);
+           */
+
+}
diff --git a/src/DriverMED/DriverMED_W_SMDS_Mesh.h b/src/DriverMED/DriverMED_W_SMDS_Mesh.h
new file mode 100644 (file)
index 0000000..050c1a4
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef _INCLUDE_DRIVERMED_W_SMDS_MESH
+#define _INCLUDE_DRIVERMED_W_SMDS_MESH
+
+#include "SMDS_Mesh.hxx"
+#include "Mesh_Writer.h"
+
+#include <string>
+
+extern "C"
+{
+#include <med.h>
+}
+
+class DriverMED_W_SMDS_Mesh : public Mesh_Writer {
+
+  public :
+    DriverMED_W_SMDS_Mesh();
+    ~DriverMED_W_SMDS_Mesh();
+
+    void Add(); 
+    void Write();
+    void SetMesh(Handle(SMDS_Mesh)& aMesh);
+    void SetFile(string);
+
+    void SetFileId(med_idt);
+    void SetMeshId(int);
+
+private :
+    Handle_SMDS_Mesh myMesh;
+    string myFile; 
+    med_idt myFileId;
+    int myMeshId;
+
+};
+#endif
diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Document.cxx b/src/DriverMED/DriverMED_W_SMESHDS_Document.cxx
new file mode 100644 (file)
index 0000000..e880074
--- /dev/null
@@ -0,0 +1,73 @@
+#include "DriverMED_W_SMESHDS_Document.h"
+#include "DriverMED_W_SMESHDS_Mesh.h"
+#include "utilities.h"
+
+#include <stdio.h>
+
+extern "C" 
+{
+  Document_Writer* Wmaker() {
+    return new DriverMED_W_SMESHDS_Document;
+  }
+}
+
+DriverMED_W_SMESHDS_Document::DriverMED_W_SMESHDS_Document() {
+;
+}
+
+DriverMED_W_SMESHDS_Document::~DriverMED_W_SMESHDS_Document() {
+;
+}
+
+//void DriverMED_W_SMESHDS_Document::SetFile(string aFile) {
+//myFile = aFile;
+//}
+
+//void DriverMED_W_SMESHDS_Document::SetDocument(Handle(SMESHDS_Document)& aDocument) {
+//myDocument = aDocument;
+//}
+
+void DriverMED_W_SMESHDS_Document::Write() {
+
+  med_err ret = 0;
+  med_idt fid;
+  med_int nmaa,numero,nb_of_meshes;
+  med_mode_switch mode_coo;
+  med_connectivite typ_con;
+
+  SCRUTE(myFile);
+  Handle(SMESHDS_Mesh) myMesh;
+
+  /******** Nombre de maillages ********/
+  nb_of_meshes = myDocument->NbMeshes(); //voir avec Yves
+  MESSAGE("nb_of_meshes = "<<nb_of_meshes<<"\n");
+  SCRUTE(nb_of_meshes);
+  //nb_of_meshes = 1;
+  numero = 0;
+
+  string myClass = string("SMESHDS_Mesh");
+  string myExtension = string("MED");
+
+  //while (numero<nb_of_meshes) {
+  //numero++;
+  //myMesh = myDocument->GetMesh(numero);
+
+  myDocument->InitMeshesIterator();
+  if (nb_of_meshes!=0)
+  for (;myDocument->MoreMesh();myDocument->NextMesh()) {
+    numero++;
+    myMesh = myDocument->CurrentMesh();
+
+    DriverMED_W_SMESHDS_Mesh* myWriter = new DriverMED_W_SMESHDS_Mesh;
+
+    myWriter->SetMesh(myMesh);
+    myWriter->SetFile(myFile);
+    //myWriter->SetFileId(fid);
+    myWriter->SetMeshId(numero);
+
+    //myWriter->Write();
+    myWriter->Add();
+  }
+
+
+}
diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Document.h b/src/DriverMED/DriverMED_W_SMESHDS_Document.h
new file mode 100644 (file)
index 0000000..ae3e87e
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef _INCLUDE_DRIVERMED_W_SMESHDS_DOCUMENT
+#define _INCLUDE_DRIVERMED_W_SMESHDS_DOCUMENT
+
+#include "SMESHDS_Document.hxx"
+#include "Document_Writer.h"
+
+#include <string>
+
+extern "C"
+{
+#include <med.h>
+}
+
+class DriverMED_W_SMESHDS_Document : public Document_Writer {
+  
+public :
+  DriverMED_W_SMESHDS_Document();
+  ~DriverMED_W_SMESHDS_Document();
+  void Write();
+  //void SetFile(string);
+  //void SetDocument(Handle(SMESHDS_Document)&);
+
+private :
+  //Handle_SMESHDS_Document myDocument;
+  //string myFile; 
+
+};
+#endif
diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx
new file mode 100644 (file)
index 0000000..312870e
--- /dev/null
@@ -0,0 +1,562 @@
+#include "DriverMED_W_SMESHDS_Mesh.h"
+#include "DriverMED_W_SMDS_Mesh.h"
+
+#include "SMDS_MeshElement.hxx"
+#include "SMDS_MeshNode.hxx"
+#include "SMDS_MeshFacesIterator.hxx"
+#include "SMDS_MeshEdgesIterator.hxx"
+#include "SMDS_MeshNodesIterator.hxx"
+#include "SMDS_MeshVolumesIterator.hxx"
+#include "SMESHDS_SubMesh.hxx"
+#include "SMDS_MapIteratorOfExtendedMap.hxx"
+#include "SMDS_MapOfMeshElement.hxx"
+#include "SMDS_Position.hxx"
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_CompSolid.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+
+
+#include <map>
+#include <set>
+#include <vector>
+#include "utilities.h"
+
+DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh() {
+  ;
+}
+
+DriverMED_W_SMESHDS_Mesh::~DriverMED_W_SMESHDS_Mesh() {
+  ;
+}
+
+void DriverMED_W_SMESHDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) {
+  myMesh = aMesh;
+}
+
+void DriverMED_W_SMESHDS_Mesh::SetFile(string aFile) {
+  myFile = aFile;
+}
+
+void DriverMED_W_SMESHDS_Mesh::SetFileId(med_idt aFileId) {
+  myFileId = aFileId;
+}
+
+void DriverMED_W_SMESHDS_Mesh::SetMeshId(int aMeshId) {
+  myMeshId = aMeshId;
+}
+
+void DriverMED_W_SMESHDS_Mesh::Write() {
+
+  string myClass = string("SMDS_Mesh");
+  string myExtension = string("MED");
+
+  DriverMED_W_SMDS_Mesh* myWriter = new DriverMED_W_SMDS_Mesh;
+
+  myWriter->SetMesh(myMesh);
+  //  myWriter->SetFile(myFile);
+  myWriter->SetMeshId(myMeshId);
+  myWriter->SetFileId(myFileId);
+
+  myWriter->Write();
+
+
+}
+
+void DriverMED_W_SMESHDS_Mesh::Add() {
+
+  med_err ret = 0;
+  int i,j,k,l;
+  int numero;
+  char message[200];
+  Standard_Boolean ok;
+  /* nombre d'objets MED */
+  char nom_universel[MED_TAILLE_LNOM+1];
+  med_int long_fichier_en_tete;
+  char *fichier_en_tete;
+  char version_hdf[10];
+  char version_med[10];
+  med_int nmaa,mdim,nnoe;
+  med_int nmai[MED_NBR_GEOMETRIE_MAILLE],nfac[MED_NBR_GEOMETRIE_FACE];
+  med_int nare[MED_NBR_GEOMETRIE_ARETE];
+  /* nom du maillage */
+  char nommaa[MED_TAILLE_NOM+1];
+  /* noeuds */
+  med_float *coo;
+  // PN : Initilialisation de nomcoo et unicoo pour lisibilite du maillage
+  char nomcoo[3*MED_TAILLE_PNOM+1]="x       y        z      ";
+  char unicoo[3*MED_TAILLE_PNOM+1]="m       m        m     ";
+  char *nomnoe;
+  med_int *numnoe;
+  med_int *nufano;
+  med_repere rep;
+  med_booleen inonoe,inunoe;
+  med_mode_switch mode_coo;
+  char str[MED_TAILLE_PNOM+1];
+  med_int nbNodes;
+  /* elements */
+  med_int nsup;
+  med_int edim;
+  med_int taille;
+  med_int elem_id,myId;
+  med_int *connectivite;
+  char *nomele;
+  med_int *numele;
+  med_int *nufael;
+  med_booleen inoele, inuele;
+  med_connectivite typ_con;
+  med_geometrie_element typgeo;
+  med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] = {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};
+  med_int desmai[MED_NBR_GEOMETRIE_MAILLE] = {0,2,3,3,3,4,4,4,4,6,6,5,5,5,5};
+  med_int nmailles[MED_NBR_GEOMETRIE_MAILLE];
+  char nommai[MED_NBR_GEOMETRIE_MAILLE] [MED_TAILLE_NOM+1] = {"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"};
+  med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] = {MED_TRIA3,MED_TRIA6,
+                                                         MED_QUAD4,MED_QUAD8};
+  med_int desfac[MED_NBR_GEOMETRIE_FACE] = {3,3,4,4};
+  med_int nfaces[MED_NBR_GEOMETRIE_FACE];
+  char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM+1] = {"MED_TRIA3","MED_TRIA6",
+                                                          "MED_QUAD4","MED_QUAD8"};
+  med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] = {MED_SEG2,MED_SEG3};
+  med_int desare[MED_NBR_GEOMETRIE_ARETE] = {2,3};
+  med_int naretes[MED_NBR_GEOMETRIE_ARETE];
+  char nomare[MED_NBR_GEOMETRIE_ARETE] [MED_TAILLE_NOM+1] = {"MED_SEG2","MED_SEG3"};
+
+  typ_con = MED_NOD;
+  mode_coo = MED_FULL_INTERLACE;
+  numero = myMeshId;
+
+  //---- provisoire : switch pour ecrire les familles de mailles
+  int besoinfamilledemaille=1;
+  //---- provisoire : switch pour ecrire les familles de mailles
+
+  /****************************************************************************
+   *                      OUVERTURE DU FICHIER EN ECRITURE                    *
+   ****************************************************************************/
+  char* file2Read = (char*)myFile.c_str();
+
+  MESSAGE ( " file2Read " << file2Read )
+
+    myFileId = MEDouvrir(file2Read,MED_REMP);
+  if (myFileId < 0)
+    {
+      fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read);
+      exit(EXIT_FAILURE);
+    }
+
+  /****************************************************************************
+   *                       NOMBRES D'OBJETS MED                               *
+   ****************************************************************************/
+  fprintf(stdout,"\n(****************************)\n");
+  fprintf(stdout,"(* INFORMATIONS GENERALES : *)\n");
+  fprintf(stdout,"(****************************)\n");
+
+  /* calcul de la dimension */
+  mdim=2;
+  double epsilon=0.00001;
+  SMDS_MeshNodesIterator myItNodes(myMesh);
+  for (;myItNodes.More();myItNodes.Next()) {
+    const Handle(SMDS_MeshElement)& elem = myItNodes.Value();
+    const Handle(SMDS_MeshNode)& node = myMesh->GetNode(1,elem);
+    if ( fabs(node->Z()) > epsilon ) {
+      mdim=3;
+      break;
+    }
+  }
+  MESSAGE ( " mdim " << mdim );
+
+  /* creation du maillage */
+  //mdim=3;
+  sprintf(nommaa,"Mesh %d",numero);
+  SCRUTE(nommaa);
+  ret = MEDmaaCr(myFileId,nommaa,mdim);
+
+  ASSERT(ret == 0);
+  SCRUTE( ret );
+
+  /* Combien de noeuds ? */
+  nnoe = myMesh->NbNodes();
+  //SCRUTE(nnoe);
+  /* Combien de mailles, faces ou aretes ? */
+  for (i=0;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+    nmailles[i]=0;
+
+  Standard_Integer nb_of_nodes, nb_of_faces, nb_of_edges;
+  vector<int> elem_Id[MED_NBR_GEOMETRIE_MAILLE];
+
+  SMDS_MeshEdgesIterator itEdges(myMesh);
+  nb_of_edges = myMesh->NbEdges();
+  for (;itEdges.More();itEdges.Next()) {
+    const Handle(SMDS_MeshElement)& elem = itEdges.Value();
+
+    nb_of_nodes = elem->NbNodes();
+
+    switch (nb_of_nodes) {
+    case 2 : {
+      elem_Id[1].push_back(elem->GetID());
+      nmailles[1]++;
+      break;
+    }
+    case 3 : {
+      elem_Id[2].push_back(elem->GetID());
+      nmailles[2]++;
+      break;
+    }
+    }
+  }
+
+
+  SMDS_MeshFacesIterator itFaces(myMesh);
+  nb_of_faces = myMesh->NbFaces();
+  for (;itFaces.More();itFaces.Next()) {
+    const Handle(SMDS_MeshElement)& elem = itFaces.Value();
+
+    nb_of_nodes = elem->NbNodes();
+
+    switch (nb_of_nodes) {
+    case 3 : {
+      elem_Id[3].push_back(elem->GetID());
+      nmailles[3]++;
+      break;
+    }
+    case 4 : {
+      elem_Id[5].push_back(elem->GetID());
+      nmailles[5]++;
+      break;
+    }
+    case 6 : {
+      elem_Id[4].push_back(elem->GetID());
+      nmailles[4]++;
+      break;
+    }
+    }
+
+  }
+
+  SMDS_MeshVolumesIterator itVolumes(myMesh);
+  for (;itVolumes.More();itVolumes.Next()) {
+    const Handle(SMDS_MeshElement)& elem = itVolumes.Value();
+
+    nb_of_nodes = elem->NbNodes();
+    switch (nb_of_nodes) {
+    case 8 : {
+      elem_Id[9].push_back(elem->GetID());
+      nmailles[9]++;
+      break;
+    }
+    }
+  }
+
+
+
+  /****************************************************************************
+   *                       ECRITURE DES NOEUDS                                *
+   ****************************************************************************/
+  fprintf(stdout,"\n(************************)\n");
+  fprintf(stdout,"(* NOEUDS DU MAILLAGE : *)\n");
+  fprintf(stdout,"(************************)\n");
+
+  /* Allocations memoires */
+  /* table des coordonnees
+     profil : (dimension * nombre de noeuds ) */
+  coo = (med_float*) malloc(sizeof(med_float)*nnoe*mdim);
+  /* table  des numeros, des numeros de familles des noeuds
+     profil : (nombre de noeuds) */
+  numnoe = (med_int*) malloc(sizeof(med_int)*nnoe);
+  nufano = (med_int*) malloc(sizeof(med_int)*nnoe);
+  /* table des noms des noeuds
+     profil : (nnoe*MED_TAILLE_PNOM+1) */
+  nomnoe ="";
+
+  /* PN  pour aster, il faut une famille 0 pour les noeuds et une autre pour les elements*/
+  /* PN : Creation de la famille 0 */
+  char * nomfam="FAMILLE_0";
+  char *attdes="";
+  char *gro=0;
+  med_int ngro=0;
+  med_int natt=1;
+  med_int attide = 0;
+  med_int attval=0;
+  med_int numfam = 0;
+  med_int attvalabs=1;
+  ret = MEDfamCr(myFileId,nommaa,nomfam,numfam, &attide,&attval,attdes,natt,gro,ngro);
+  ASSERT(ret == 0);
+
+
+  /* PN : FIN Creation de la famille 0 */
+
+  map < int, int > mapNoeud;
+  typedef pair<set<int>::iterator, bool> IsFamily;
+  int nbFamillesNoeud;
+
+
+  i = 0;
+  set<int> FamilySet;
+  nbFamillesNoeud = 0;
+  int verifienbnoeuds = 0;
+  med_int* rien=0;
+
+  SMDS_MeshNodesIterator itNodes(myMesh);
+  for (;itNodes.More();itNodes.Next())
+    {
+      const Handle(SMDS_MeshElement)& elem = itNodes.Value();
+      const Handle(SMDS_MeshNode)& node = myMesh->GetNode(1,elem);
+
+      if(mdim==3){
+       coo[i*3]=node->X();
+       coo[i*3+1]=node->Y();
+       coo[i*3+2]=node->Z();
+      } else {
+       coo[i*2]=node->X();
+       coo[i*2+1]=node->Y();
+      }
+      mapNoeud[node->GetID()] = i+1;
+
+      // renvoie 0 pour les noeuds internes du volume
+      int numfamille=node->GetPosition()->GetShapeId();
+      nufano[i]=numfamille;
+
+      //SCRUTE(i);
+      //SCRUTE(nufano[i]);
+      //SCRUTE(coo[i*3]);
+      //SCRUTE(coo[i*3+1]);
+      //SCRUTE(coo[i*3+2]);
+      if ( nufano[i] != 0 )
+       {
+         IsFamily deja = FamilySet.insert(nufano[i]); // insert if new, or gives existant
+         if (deja.second)                                    // actually inserted
+           {
+             char famille[MED_TAILLE_NOM+1];
+             sprintf(famille,"F%d",nufano[i]);
+             //              CreateFamily(strdup(nommaa),strdup(famille),nufano[i],attvalabs++);
+             attvalabs++;
+             CreateFamily(strdup(nommaa),strdup(famille),nufano[i],numfamille);
+             //MESSAGE("---famille-noeud--- "<<nbFamillesNoeud<<" "<<nufano[i]);
+             nbFamillesNoeud++;
+           }
+       }
+
+      i++;
+      verifienbnoeuds ++;
+    }
+  ret = MEDnoeudsEcr(myFileId,nommaa,mdim,coo,mode_coo,MED_CART,
+                    nomcoo,unicoo,nomnoe,MED_FAUX,rien,MED_FAUX,
+                    nufano,nnoe,MED_REMP);
+  ASSERT(ret == 0);
+  MESSAGE("--- Creation de " << verifienbnoeuds << " noeuds");
+  ASSERT(verifienbnoeuds == nnoe);
+  MESSAGE("--- Creation de " << nbFamillesNoeud << " familles de noeuds");
+
+  /* liberation memoire */
+  free(coo);
+  free(numnoe);
+  free(nufano);
+
+  /****************************************************************************
+   *                       ECRITURE DES ELEMENTS                              *
+   ****************************************************************************/
+  fprintf(stdout,"\n(**************************)\n");
+  fprintf(stdout,"(* ELEMENTS DU MAILLAGE : *)\n");
+  fprintf(stdout,"(**************************)\n");
+
+  /* Ecriture des connectivites, noms, numeros des mailles */
+
+  if (ret == 0)
+    {
+      int nbFamillesElts =0;
+      Handle(SMESHDS_Mesh) mySMESHDSMesh = Handle(SMESHDS_Mesh)::DownCast(myMesh);
+      TopTools_IndexedMapOfShape myIndexToShape;
+      TopExp::MapShapes(mySMESHDSMesh->ShapeToMesh(),myIndexToShape);
+
+      map < int, int > mapFamille;
+
+      if (besoinfamilledemaille == 1)
+       {
+         int t;
+         for (t =1; t <= myIndexToShape.Extent(); t++)
+           {
+             const TopoDS_Shape S = myIndexToShape(t);
+             if (mySMESHDSMesh->HasMeshElements(S))
+               {
+                 //MESSAGE ("********* Traitement de la Famille "<<-t);
+               
+                 Handle(SMESHDS_SubMesh) SM = mySMESHDSMesh->MeshElements(S);
+                 const TColStd_ListOfInteger& indElt = SM->GetIDElements();
+                 TColStd_ListIteratorOfListOfInteger ite(indElt);
+               
+                 bool plein=false;
+                 for (; ite.More(); ite.Next())
+                   {
+                     int eltId = ite.Value();
+                     mapFamille [eltId] = - t;
+                     plein=true;
+                   }
+                 if (plein)
+                   {
+                     nbFamillesElts++;
+                     char famille[MED_TAILLE_NOM+1];
+                     sprintf(famille,"E%d",t);
+                     CreateFamily(strdup(nommaa),strdup(famille),-t,attvalabs++);
+                   }
+               }
+           }
+       }
+
+      int indice=1;
+      for (i=0;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+       {
+         if (nmailles[i] > 0 && ret == 0)
+           {
+             MESSAGE ( " Start "<<typmai[i]);
+       
+             /* dimension de la maille */
+             edim = typmai[i] / 100;
+             nsup = 0;
+             if (mdim  == 2 || mdim == 3)
+               if (edim == 1) nsup = 1;
+             if (mdim == 3)
+               if (edim == 2) nsup = 1;
+             //SCRUTE(nsup);
+       
+             taille = nsup+typmai[i]%100;
+             //SCRUTE(taille);
+       
+             /* allocation memoire */
+             connectivite = (med_int*)malloc(sizeof(med_int)* taille*nmailles[i]);
+             nomele = (char*)malloc(sizeof(char)*MED_TAILLE_PNOM* nmailles[i]+1);
+             numele = (med_int*)malloc(sizeof(med_int)* nmailles[i]);
+             nufael = (med_int*)malloc(sizeof(med_int)* nmailles[i]);
+             nomele="";
+             nbNodes=typmai[i]%100;
+       
+             for (j=0;j<nmailles[i];j++)
+               {
+                 myId = elem_Id[i][j];
+                 const Handle(SMDS_MeshElement)& elem = myMesh->FindElement(myId);
+                 //*(numele+j) = myId;
+                 *(numele+j) = indice ++;
+               
+                 for (k=0; k<nbNodes; k++)
+                   {
+                     *(connectivite+j*taille+k) = mapNoeud[elem->GetConnection(k+1)];
+                     //SCRUTE(*(connectivite+j*taille+k));
+                   }
+                 if (nsup) *(connectivite+j*taille + nbNodes) = 0;
+               
+                 if (besoinfamilledemaille == 1)
+                   {
+                     if (mapFamille.find(myId)!=mapFamille.end())
+                       {
+                         nufael[j]=mapFamille[myId];
+                       }
+                     else
+                       {
+                         nufael[j]=0;
+                       }
+                   }
+                 else
+                   {
+                     nufael[j]=0;
+                   }
+               
+                 //SCRUTE(myId);
+                 //SCRUTE(j);
+                 //SCRUTE(nufael[j]);
+               }
+       
+             /* ecriture des donnĂ©es */
+               
+                   med_int* rien=0;
+                   ret=MEDelementsEcr( myFileId,nommaa,mdim,connectivite,mode_coo,nomele,MED_FAUX,numele,
+                                       MED_VRAI,nufael,nmailles[i],MED_MAILLE,typmai[i],typ_con,MED_REMP);
+                   ASSERT(ret == 0);
+                   //SCRUTE(ret);
+               
+                   if (ret < 0) MESSAGE(">> ERREUR : ecriture des mailles \n");
+               
+                   /* liberation memoire */
+                   free(connectivite);
+                   free(numele);
+                   free(nufael);
+                   MESSAGE ( " End "<<typmai[i]);
+           }
+      };
+         MESSAGE("--- Creation de " << nbFamillesElts << " familles d elements");
+
+    }
+
+      /****************************************************************************
+      *                      FERMETURE DU FICHIER                                *
+      ****************************************************************************/
+
+      ret = MEDfermer(myFileId);
+
+      if (ret != 0)
+       fprintf(stderr,">> ERREUR : erreur a la fermeture du fichier %s\n",file2Read);
+      MESSAGE ("fichier ferme");
+
+
+}
+
+void DriverMED_W_SMESHDS_Mesh::CreateFamily(char* nommaa, char* famille, int i,med_int k) {
+
+  med_int ngro=0;
+  med_int natt;
+
+  natt=1;
+  char attdes[MED_TAILLE_DESC+1];
+  char gro[MED_TAILLE_LNOM+1];
+  char fam2[MED_TAILLE_LNOM+1];
+
+  strcpy(attdes,"");
+  strcpy(gro,"");
+  strcpy(fam2,famille);
+
+  med_int * attide=new med_int[1];
+  med_int * attval=new med_int[1];
+  attide[0] = k;
+  attval[0] = k;
+
+
+  //MESSAGE("-------- Creation de la Famille : "<< famille << "numero " << i << " --------------");
+  med_int ret = MEDfamCr(myFileId, nommaa, fam2, i, attide, attval, attdes, natt, gro, ngro);
+  ASSERT(ret==0);
+  delete [] attide;
+  delete [] attval;
+
+}
+
+
+
diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.h b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.h
new file mode 100644 (file)
index 0000000..a5385d7
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef _INCLUDE_DRIVERMED_W_SMESHDS_MESH
+#define _INCLUDE_DRIVERMED_W_SMESHDS_MESH
+
+#include "SMESHDS_Mesh.hxx"
+#include "Mesh_Writer.h"
+
+#include <string>
+
+extern "C"
+{
+#include <med.h>
+}
+
+class DriverMED_W_SMESHDS_Mesh : public Mesh_Writer {
+
+  public :
+    DriverMED_W_SMESHDS_Mesh();
+    ~DriverMED_W_SMESHDS_Mesh();
+
+    void Add(); 
+    void Write();
+    void SetMesh(Handle(SMDS_Mesh)& aMesh);
+    void SetFile(string);
+
+    void SetFileId(med_idt);
+    void SetMeshId(int);
+
+    void CreateFamily(char*, char*, int, med_int);
+
+private :
+    Handle_SMDS_Mesh myMesh;
+    string myFile; 
+    med_idt myFileId;
+    int myMeshId;
+
+};
+#endif
diff --git a/src/DriverMED/Makefile.in b/src/DriverMED/Makefile.in
new file mode 100644 (file)
index 0000000..c3d9880
--- /dev/null
@@ -0,0 +1,39 @@
+# -* Makefile *- 
+#
+# Author : Marc Tajchman (CEA)
+# Date : 5/07/2001
+# $Header$
+#
+
+# source path
+top_srcdir=@top_srcdir@
+top_builddir=../../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@
+
+
+@COMMENCE@
+
+# header files 
+EXPORT_HEADERS= DriverMED_R_SMDS_Mesh.h DriverMED_R_SMESHDS_Mesh.h DriverMED_R_SMESHDS_Document.h DriverMED_W_SMDS_Mesh.h DriverMED_W_SMESHDS_Mesh.h DriverMED_W_SMESHDS_Document.h 
+
+# Libraries targets
+LIB = libMeshDriverMED.la
+LIB_SRC = DriverMED_R_SMDS_Mesh.cxx DriverMED_R_SMESHDS_Mesh.cxx DriverMED_R_SMESHDS_Document.cxx DriverMED_W_SMDS_Mesh.cxx DriverMED_W_SMESHDS_Mesh.cxx DriverMED_W_SMESHDS_Document.cxx 
+
+LIB_CLIENT_IDL =
+
+LIB_SERVER_IDL =
+
+# additionnal information to compil and link file
+CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES)
+CXXFLAGS += $(OCC_CXXFLAGS) $(MED2_INCLUDES) 
+LDFLAGS  += $(OCC_LIBS) $(MED2_LIBS) -lMeshDriver -lmed
+
+%_moc.cxx: %.h
+       $(MOC) $< -o $@
+
+@CONCLUDE@
+
+
+