00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 #include <med.h>
00026 #define MESGERR 1
00027 #include <med_utils.h>
00028 
00029 
00030 #ifdef DEF_LECT_ECR
00031 #define MODE_ACCES MED_ACC_RDWR
00032 #elif DEF_LECT_AJOUT
00033 #define MODE_ACCES MED_ACC_RDEXT
00034 #else
00035 #define MODE_ACCES MED_ACC_CREAT
00036 #endif
00037 
00038 int main (int argc, char **argv)
00039 
00040 
00041 {
00042   med_err ret = 0;
00043   med_idt fid = 0;
00044   char    maa[MED_NAME_SIZE+1]="";
00045   med_int mdim=0,sdim=0;
00046   med_int nequ=0,ncor=0,nstep=0,nocstpncor=0;
00047   med_int *cor;
00048   char equ[MED_NAME_SIZE+1]   ="";
00049   char des[MED_COMMENT_SIZE+1]="";
00050 
00051   int i,j,k;
00052   med_mesh_type type;
00053   med_sorting_type sort;
00054   char desc[MED_COMMENT_SIZE+1];
00055   char dtunit[MED_SNAME_SIZE+1]="";
00056   char nomcoo[3*MED_SNAME_SIZE+1];
00057   char unicoo[3*MED_SNAME_SIZE+1];
00058   med_axis_type rep;
00059 
00060   med_geometry_type *typmai = MED_GET_CELL_GEOMETRY_TYPE;
00061   med_geometry_type *typfac = MED_GET_FACE_GEOMETRY_TYPE;
00062   med_geometry_type *typare = MED_GET_EDGE_GEOMETRY_TYPE;
00063 
00064   if (argc != 2) {
00065     MESSAGE("Il faut passer un fichier MED en paramètre");
00066     return -1;
00067   }
00068 
00069   
00070   if ((fid = MEDfileOpen(argv[1],MED_ACC_RDONLY)) < 0) {
00071     MESSAGE("Erreur a l'ouverture du fichier : "); SSCRUTE(argv[1]);
00072     return -1;
00073   }
00074 
00075   if ((sdim=MEDmeshnAxis(fid, 1)) <0) {
00076     MESSAGE("Erreur a la lecture de la dimension de l'espace du maillage :");
00077     SSCRUTE(maa);
00078     return -1;
00079   }
00080 
00081   
00082   if ( MEDmeshInfo( fid, 1,  maa, &sdim, &mdim, &type, desc, dtunit, &sort,
00083                     &nstep,  &rep, nomcoo,unicoo) < 0 ) {
00084     MESSAGE("Erreur a la lecture des informations sur le maillage : ");SSCRUTE(maa);
00085     return -1;
00086   } else {
00087     printf("Maillage de nom : |%s| , de dimension : "IFORMAT" , et de type %d\n",maa,mdim,type);
00088     printf("\t -Dimension de l'espace : "IFORMAT"\n",sdim);
00089     printf("\t -Description du maillage : %s\n",desc);
00090     printf("\t -Noms des axes : |%s|\n",nomcoo);
00091     printf("\t -Unités des axes : |%s|\n",unicoo);
00092     printf("\t -Type de repère : %d\n",rep);
00093     printf("\t -Nombre d'étapes de calcul : "IFORMAT"\n",nstep);
00094     printf("\t -Unité des dates : |%s|\n",dtunit);
00095   }
00096 
00097   
00098   if ((nequ = MEDnEquivalence(fid,maa)) < 0) {
00099     MESSAGE("Erreur a la lecture du nombre d'equivalence");
00100     return -1;
00101   }
00102   printf("Nombre d'equivalences : "IFORMAT" \n",nequ);
00103 
00104   
00105   if (nequ > 0)
00106     for (i = 0;i<nequ;i++) {
00107       printf("Equivalence numero : %d \n",i+1);
00108 
00109       
00110       if (MEDequivalenceInfo(fid,maa,i+1,equ,des,&nstep,&nocstpncor) < 0) {
00111         MESSAGE("Erreur a la lecture de l'equivalence d'indice");
00112         ISCRUTE_int(i+1);
00113         return -1;
00114       }
00115       printf("Nom de l'equivalence: |%s| \n",equ);
00116       printf("Description de l'equivalence : |%s| \n",des);
00117       printf("Nombre d'étapes de calcul : "IFORMAT" \n",nstep);
00118       printf("Nombre de correspondances pour l'étape de calcul MED_NO_DT,MED_NO_IT : "IFORMAT" \n",nocstpncor);
00119 
00120       
00121 
00122       
00123       if ( MEDequivalenceCorrespondenceSize(fid,maa,equ,MED_NO_DT,MED_NO_IT,MED_NODE,MED_NONE,&ncor) < 0) {
00124         MESSAGE("Erreur a la lecture du nombre de correspondance sur les noeuds");
00125         return -1;
00126       }
00127       printf("Il y a "IFORMAT" correspondances sur les noeuds \n",ncor);
00128       if (ncor > 0) {
00129         cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
00130         if (MEDequivalenceCorrespondenceRd(fid,maa,equ,MED_NO_DT,MED_NO_IT,
00131                                            MED_NODE,MED_NONE,cor) < 0) {
00132           MESSAGE("Erreur a la lecture des correspondances sur les noeuds");
00133           ret = -1;
00134         }
00135         if (ret == 0)
00136           for (j=0;j<ncor;j++)
00137             printf("Correspondance %d : "IFORMAT" et "IFORMAT" \n",j+1,*(cor+2*j),
00138                    *(cor+2*j+1));
00139         free(cor);
00140       }
00141 
00142       
00143       if (ret == 0)
00144         for (j=1;j<=MED_N_CELL_FIXED_GEO;j++) {
00145 
00146           if ( MEDequivalenceCorrespondenceSize(fid,maa,equ,MED_NO_DT,MED_NO_IT,MED_CELL,typmai[j],&ncor) < 0) {
00147             MESSAGE("Erreur a la lecture du nombre de correspondance sur les mailles : ");
00148             SSCRUTE(MED_GET_CELL_GEOMETRY_TYPENAME[j]);
00149             return -1;
00150           }
00151           printf("Il y a "IFORMAT" correspondances sur les mailles %s \n",ncor,
00152                  MED_GET_CELL_GEOMETRY_TYPENAME[j]);
00153           if (ncor > 0) {
00154             cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
00155             if (MEDequivalenceCorrespondenceRd(fid,maa,equ,MED_NO_DT,MED_NO_IT,
00156                                                MED_CELL,typmai[j],cor) < 0) {
00157               MESSAGE("Erreur a la lecture des correspondances sur les mailles : ");
00158               SSCRUTE(MED_GET_CELL_GEOMETRY_TYPENAME[j]);
00159               ret = -1;
00160             }
00161             if (ret == 0)
00162               for (k=0;k<ncor;k++)
00163                 printf("Correspondance %d : "IFORMAT" et "IFORMAT" \n",k+1,*(cor+2*k),
00164                        *(cor+2*k+1));
00165             free(cor);
00166           }
00167         }
00168 
00169       
00170       if (ret == 0)
00171         for (j=1;j<=MED_N_FACE_FIXED_GEO;j++) {
00172           if ( MEDequivalenceCorrespondenceSize(fid,maa,equ,MED_NO_DT,MED_NO_IT,
00173                                                 MED_DESCENDING_FACE,typfac[j],&ncor) < 0) {
00174             MESSAGE("Erreur a la lecture du nombre de correspondance sur les faces : ");
00175             SSCRUTE(MED_GET_FACE_GEOMETRY_TYPENAME[j]);
00176             return -1;
00177           }
00178           printf("Il y a "IFORMAT" correspondances sur les faces %s \n",ncor,
00179                  MED_GET_FACE_GEOMETRY_TYPENAME[j]);
00180           if (ncor > 0) {
00181             cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
00182             if (MEDequivalenceCorrespondenceRd(fid,maa,equ,MED_NO_DT,MED_NO_IT,
00183                                                MED_DESCENDING_FACE,typfac[j],cor) < 0) {
00184               MESSAGE("Erreur a la lecture des correspondances sur les faces : ");
00185               SSCRUTE(MED_GET_FACE_GEOMETRY_TYPENAME[j]);
00186               ret = -1;
00187             }
00188             if (ret == 0)
00189               for (k=0;k<ncor;k++)
00190                 printf("Correspondance %d : "IFORMAT" et "IFORMAT" \n",k+1,*(cor+2*k),
00191                        *(cor+2*k+1));
00192             free(cor);
00193           }
00194         }
00195 
00196       
00197       if (ret == 0)
00198         for (j=1;j<=MED_N_EDGE_FIXED_GEO;j++) {
00199           if ( MEDequivalenceCorrespondenceSize(fid,maa,equ,MED_NO_DT,MED_NO_IT,
00200                                                 MED_DESCENDING_EDGE,typare[j],&ncor) < 0) {
00201             MESSAGE("Erreur a la lecture du nombre de correspondance sur les aretes : ");
00202             SSCRUTE(MED_GET_EDGE_GEOMETRY_TYPENAME[j]);
00203             return -1;
00204           }
00205           printf("Il y a "IFORMAT" correspondances sur les aretes %s \n",ncor,
00206                  MED_GET_EDGE_GEOMETRY_TYPENAME[j]);
00207           if (ncor > 0) {
00208             cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
00209             if (MEDequivalenceCorrespondenceRd(fid,maa,equ,MED_NO_DT,MED_NO_IT,
00210                                                MED_DESCENDING_EDGE,typare[j],cor) < 0) {
00211              MESSAGE("Erreur a la lecture des correspondances sur les faces : ");
00212              SSCRUTE(MED_GET_EDGE_GEOMETRY_TYPENAME[j]);
00213              ret = -1;
00214            }
00215            if (ret == 0)
00216              for (k=0;k<ncor;k++)
00217                printf("Correspondance %d : "IFORMAT" et "IFORMAT" \n",k+1,*(cor+2*k),
00218                       *(cor+2*k+1));
00219            free(cor);
00220           }
00221         }
00222 
00223     }
00224 
00225   
00226   if (MEDfileClose(fid) < 0) {
00227     MESSAGE("Erreur a la fermeture du fichier ");
00228     return -1;
00229   }
00230 
00231   return ret;
00232 }
00233 
00234 
00235 
00236