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 #ifdef DEF_LECT_ECR
00030 #define MODE_ACCES MED_LECTURE_ECRITURE
00031 #elif DEF_LECT_AJOUT
00032 #define MODE_ACCES MED_LECTURE_AJOUT
00033 #else
00034 #define MODE_ACCES MED_CREATION
00035 #endif
00036
00037
00038
00039 #define MED_NBR_MAILLE_EQU 8
00040
00041 int main (int argc, char **argv)
00042
00043
00044 {
00045 med_err ret = 0;
00046 med_idt fid;
00047 char maa[MED_TAILLE_NOM+1];
00048 med_int mdim;
00049 med_int nequ,ncor;
00050 med_int *cor;
00051 char equ[MED_TAILLE_NOM+1];
00052 char des[MED_TAILLE_DESC+1];
00053 med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE+1] = {MED_POINT1,MED_SEG2,
00054 MED_SEG3,MED_TRIA3,
00055 MED_TRIA6,MED_QUAD4,
00056 MED_QUAD8,MED_POLYGONE};
00057 med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE+1] = {MED_TRIA3,MED_TRIA6,
00058 MED_QUAD4,MED_QUAD8,
00059 MED_POLYGONE};
00060 med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] = {MED_SEG2,MED_SEG3};
00061 int i,j,k;
00062 med_maillage 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 = MEDouvrir(argv[1],MED_LECTURE)) < 0) {
00071 MESSAGE("Erreur a l'ouverture du fichier : "); SSCRUTE(argv[1]);
00072 return -1;
00073 }
00074
00075
00076 if (MEDmaaInfo(fid,1,maa,&mdim,&type,des) < 0) {
00077 MESSAGE("Erreur a lecture des infos sur le 1er maillage");
00078 return -1;
00079 }
00080 printf("Maillage de nom %s et de dimension "IFORMAT" \n",maa,mdim);
00081
00082
00083 if ((nequ = MEDnEquiv(fid,maa)) < 0) {
00084 MESSAGE("Erreur a la lecture du nombre d'equivalence");
00085 return -1;
00086 }
00087 printf("Nombre d'equivalences : "IFORMAT" \n",nequ);
00088
00089
00090 if (nequ > 0)
00091 for (i = 0;i<nequ;i++) {
00092 printf("Equivalence numero : %d \n",i+1);
00093
00094
00095 if (MEDequivInfo(fid,maa,i+1,equ,des) < 0) {
00096 MESSAGE("Erreur a la lecture de l'equivalence d'indice");
00097 ISCRUTE_int(i+1);
00098 return -1;
00099 }
00100 printf("Nom de l'equivalence: %s \n",equ);
00101 printf("Description de l'equivalence : %s \n",des);
00102
00103
00104
00105
00106 if ((ncor = MEDnCorres(fid,maa,equ,MED_NOEUD,0)) < 0) {
00107 MESSAGE("Erreur a la lecture du nombre de correspondance sur les noeuds");
00108 return -1;
00109 }
00110 printf("Il y a "IFORMAT" correspondances sur les noeuds \n",ncor);
00111 if (ncor > 0) {
00112 cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
00113 if (MEDequivLire(fid,maa,equ,cor,ncor,MED_NOEUD,0) < 0) {
00114 MESSAGE("Erreur a la lecture des correspondances sur les noeuds");
00115 ret = -1;
00116 }
00117 if (ret == 0)
00118 for (j=0;j<ncor;j++)
00119 printf("Correspondance %d : "IFORMAT" et "IFORMAT" \n",j+1,*(cor+2*j),
00120 *(cor+2*j+1));
00121 free(cor);
00122 }
00123
00124
00125 if (ret == 0)
00126 for (j=0;j<MED_NBR_MAILLE_EQU;j++) {
00127
00128 if ((ncor = MEDnCorres(fid,maa,equ,MED_MAILLE,typmai[j])) < 0) {
00129 MESSAGE("Erreur a la lecture du nombre de correspondance sur les mailles : ");
00130 ISCRUTE_int(typmai[j]);
00131 return -1;
00132 }
00133 printf("Il y a "IFORMAT" correspondances sur les mailles %d \n",ncor,
00134 typmai[j]);
00135 if (ncor > 0) {
00136 cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
00137 if (MEDequivLire(fid,maa,equ,cor,ncor,MED_MAILLE,
00138 typmai[j]) < 0) {
00139 MESSAGE("Erreur a la lecture des correspondances sur les mailles : ");
00140 ISCRUTE_int(typmai[j]);
00141 ret = -1;
00142 }
00143 if (ret == 0)
00144 for (k=0;k<ncor;k++)
00145 printf("Correspondance %d : "IFORMAT" et "IFORMAT" \n",k+1,*(cor+2*k),
00146 *(cor+2*k+1));
00147 free(cor);
00148 }
00149 }
00150
00151
00152 if (ret == 0)
00153 for (j=0;j<MED_NBR_GEOMETRIE_FACE+1;j++) {
00154 if ((ncor = MEDnCorres(fid,maa,equ,MED_FACE,typfac[j])) < 0) {
00155 MESSAGE("Erreur a la lecture du nombre de correspondance sur les faces : ");
00156 ISCRUTE_int(typfac[j]);
00157 return -1;
00158 }
00159 printf("Il y a %d correspondances sur les faces "IFORMAT" \n",ncor,
00160 typfac[j]);
00161 if (ncor > 0) {
00162 cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
00163 if (MEDequivLire(fid,maa,equ,cor,ncor,MED_FACE,
00164 typfac[j]) < 0) {
00165 MESSAGE("Erreur a la lecture des correspondances sur les faces : ");
00166 ISCRUTE_int(typfac[j]);
00167 ret = -1;
00168 }
00169 if (ret == 0)
00170 for (k=0;k<ncor;k++)
00171 printf("Correspondance %d : "IFORMAT" et "IFORMAT" \n",k+1,*(cor+2*k),
00172 *(cor+2*k+1));
00173 free(cor);
00174 }
00175 }
00176
00177
00178 if (ret == 0)
00179 for (j=0;j<MED_NBR_GEOMETRIE_ARETE;j++) {
00180 if ((ncor = MEDnCorres(fid,maa,equ,MED_ARETE,typare[j])) < 0) {
00181 MESSAGE("Erreur a la lecture du nombre de correspondance sur les aretes : ");
00182 ISCRUTE_int(typare[j]);
00183 return -1;
00184 }
00185 printf("Il y a "IFORMAT" correspondances sur les aretes %d \n",ncor,
00186 typare[j]);
00187 if (ncor > 0) {
00188 cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
00189 if (MEDequivLire(fid,maa,equ,cor,ncor,MED_ARETE,
00190 typare[j]) < 0) {
00191 MESSAGE("Erreur a la lecture des correspondances sur les faces : ");
00192 ISCRUTE_int(typare[j]);
00193 ret = -1;
00194 }
00195 if (ret == 0)
00196 for (k=0;k<ncor;k++)
00197 printf("Correspondance %d : "IFORMAT" et "IFORMAT" \n",k+1,*(cor+2*k),
00198 *(cor+2*k+1));
00199 free(cor);
00200 }
00201 }
00202
00203 }
00204
00205
00206 if (MEDfermer(fid) < 0) {
00207 MESSAGE("Erreur a la fermeture du fichier ");
00208 return -1;
00209 }
00210
00211 return ret;
00212 }
00213
00214
00215
00216