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 int afficheCorres(med_idt fid, char *maa, char *jnt,
00038                  med_entite_maillage typ_ent_local,   med_geometrie_element typ_geo_local,
00039                  med_entite_maillage typ_ent_distant, med_geometrie_element typ_geo_distant,
00040                  char *type);
00041 
00042 int main (int argc, char **argv)
00043 
00044 
00045 {
00046   med_err ret = 0;
00047   med_idt fid;
00048   char maa[MED_TAILLE_NOM+1],maa_dist[MED_TAILLE_NOM+1];
00049   med_int mdim;
00050   med_int njnt,ncor,ndom,nc;
00051   char jnt[MED_TAILLE_NOM+1],corr[MED_TAILLE_NOM+1];
00052   char des[MED_TAILLE_DESC+1];
00053   med_entite_maillage typ_ent_local,typ_ent_distant;
00054   med_geometrie_element typ_geo_local,typ_geo_distant;
00055 
00056   int i,j,k;
00057   med_maillage type;
00058 
00059   if (argc != 2) {
00060     MESSAGE("Il faut passer un fichier MED en paramètre");
00061     return -1;
00062   }
00063 
00064   
00065   if ((fid = MEDouvrir(argv[1],MED_LECTURE)) < 0) {
00066     MESSAGE("Erreur a l'ouverture du fichier : "); SSCRUTE(argv[1]);
00067     return -1;
00068   }
00069   
00070   
00071   if (MEDmaaInfo(fid,1,maa,&mdim,&type,des) < 0) {
00072     MESSAGE("Erreur a lecture des infos sur le 1er maillage"); 
00073     return -1;
00074   }
00075   printf("Maillage de nom %s et de dimension "IFORMAT" \n",maa,mdim);
00076 
00077   
00078   if ((njnt = MEDnJoint(fid,maa)) < 0) {
00079     MESSAGE("Erreur a la lecture du nombre de joints"); 
00080     return -1;
00081   }
00082   printf("Nombre de joints : "IFORMAT" \n",njnt);
00083 
00084   
00085   if (njnt > 0)
00086     for (i = 0;i<njnt;i++) {
00087       printf("Joint numero : %d \n",i+1);
00088 
00089       
00090       if (MEDjointInfo(fid,maa,i+1,jnt,des,&ndom,maa_dist) < 0) {
00091         MESSAGE("Erreur a la lecture du joint d'indice");
00092         ISCRUTE_int(i+1);
00093         return -1;
00094       }
00095       printf("Nom du joint: %s \n",jnt);
00096       printf("Description du joint      : %s \n",des);
00097       printf("Domaine en regard         : "IFORMAT" \n",ndom);
00098       printf("Maillage distant          : %s \n",maa_dist);
00099 
00100 
00101 
00102       
00103 
00104 
00105       
00106       afficheCorres(fid,maa,jnt,MED_NOEUD,0,MED_NOEUD,0,"noeud/noeud");
00107   
00108       
00109       afficheCorres(fid,maa,jnt,MED_NOEUD,0,MED_MAILLE,MED_TRIA3,"noeud/TRIA3");
00110 
00111 
00112       
00113 
00114 
00115 
00116       ncor=1;
00117 
00118       while (MEDjointTypeCorres(fid,maa,jnt,ncor,
00119                                 &typ_ent_local,&typ_geo_local,&typ_ent_distant,&typ_geo_distant)>=0) {
00120 
00121         
00122         afficheCorres(fid,maa,jnt,typ_ent_local,typ_geo_local,typ_ent_distant,typ_geo_distant,"noeud/noeud");
00123         
00124         ncor++;
00125       }
00126 
00127 
00128             
00129     }                       
00130 
00131   
00132   if (MEDfermer(fid) < 0) {
00133     MESSAGE("Erreur a la fermeture du fichier ");
00134     return -1;
00135   }
00136 
00137   return ret;
00138 }
00139 
00140 
00141 
00142 
00143 int afficheCorres(med_idt fid, char *maa, char *jnt,
00144                  med_entite_maillage typ_ent_local,   med_geometrie_element typ_geo_local,
00145                  med_entite_maillage typ_ent_distant, med_geometrie_element typ_geo_distant,
00146                  char *type)
00147 {
00148   med_int nc;
00149   med_int *cortab;
00150   int k,ncor,ret=0;
00151 
00152   if ((nc = MEDjointnCorres(fid,maa,jnt,typ_ent_local,typ_geo_local,typ_ent_distant,typ_geo_distant)) < 0) {
00153     MESSAGE("Erreur a la lecture des infos sur le nombre d'entite en regard de type");
00154     SSCRUTE(type);
00155     return -1;
00156   }
00157         
00158   printf("nb de couples d'entites en regard %s: "IFORMAT" \n",type,nc);
00159   
00160   if (nc > 0) {
00161     cortab = (med_int*) malloc(sizeof(med_int)*nc*2);
00162     if ((ret=MEDjointLire(fid,maa,jnt,cortab,nc*2,
00163                           typ_ent_local,typ_geo_local,typ_ent_distant,typ_geo_distant)) < 0) {
00164       MESSAGE("Erreur a la lecture des correspondances sur ");
00165       SSCRUTE(type);
00166       ret = -1;
00167     }
00168     if (ret == 0)
00169       for (k=0;k<nc;k++)
00170         printf("Correspondance %d : "IFORMAT" et "IFORMAT" \n",k+1,*(cortab+2*k),
00171                *(cortab+2*k+1));
00172     free(cortab);
00173   }
00174   return ret;
00175 }
00176