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
00026
00027 #include <med.h>
00028 #define MESGERR 1
00029 #include "med_utils.h"
00030 #include <string.h>
00031
00032 #ifdef DEF_LECT_ECR
00033 #define MODE_ACCES MED_ACC_RDWR
00034 #elif DEF_LECT_AJOUT
00035 #define MODE_ACCES MED_ACC_RDEXT
00036 #else
00037 #define MODE_ACCES MED_ACC_CREAT
00038 #endif
00039
00040 int main (int argc, char **argv)
00041
00042
00043 {
00044 med_err ret = 0;
00045 med_idt fid = 0;
00046 med_int mdim=0,sdim=0;
00047
00048 char maa[MED_NAME_SIZE+1];
00049
00050 med_int nnoe = 0;
00051
00052 med_float *coo;
00053
00054 char nomcoo[3*MED_SNAME_SIZE+1]="";
00055 char unicoo[3*MED_SNAME_SIZE+1]="";
00056
00057
00058 char *nomnoe;
00059 med_int *numnoe;
00060 med_int *nufano;
00061 med_bool inonoe,inunoe,inufam;
00062 med_bool chgt=MED_FALSE, trsf=MED_FALSE;
00063 char str [MED_SNAME_SIZE+1] ="";
00064 char desc [MED_COMMENT_SIZE+1]="";
00065 char dtunit[MED_SNAME_SIZE+1] ="";
00066 med_mesh_type type;
00067 med_sorting_type sort;
00068 med_axis_type rep;
00069 med_int nstep=0;
00070 med_int i;
00071
00072
00073 if ((fid = MEDfileOpen(argv[1],MED_ACC_RDONLY)) < 0) {
00074 MESSAGE("Erreur a l'ouverture du fichier.");
00075 return -1;
00076 }
00077 if ((sdim=MEDmeshnAxis(fid, 1)) <0) {
00078 MESSAGE("Erreur a la lecture de la dimension de l'espace du maillage :");
00079 SSCRUTE(maa);
00080 return -1;
00081 }
00082
00083
00084 if ( MEDmeshInfo( fid, 1, maa, &sdim, &mdim, &type, desc, dtunit, &sort,
00085 &nstep, &rep, nomcoo,unicoo) < 0 ) {
00086 MESSAGE("Erreur a la lecture des informations sur le maillage : ");SSCRUTE(maa);
00087 return -1;
00088 } else {
00089 printf("Maillage de nom : |%s| , de dimension : "IFORMAT" , et de type %d\n",maa,mdim,type);
00090 printf("\t -Dimension de l'espace : "IFORMAT"\n",sdim);
00091 printf("\t -Description du maillage : |%s|\n",desc);
00092 printf("\t -Noms des axes : |%s|\n",nomcoo);
00093 printf("\t -Unités des axes : |%s|\n",unicoo);
00094 printf("\t -Type de repère : %d\n",rep);
00095 printf("\t -Nombre d'étapes de calcul : "IFORMAT"\n",nstep);
00096 printf("\t -Unité des dates : |%s|\n",dtunit);
00097 }
00098
00099
00100 if ((nnoe = MEDmeshnEntity(fid, maa, MED_NO_DT, MED_NO_IT,
00101 MED_NODE, MED_NODE,MED_COORDINATE, MED_NO_CMODE,
00102 &chgt, &trsf)) < 0) {
00103 MESSAGE("Erreur a la lecture du nombre de noeuds");
00104 return -1;
00105 }
00106 printf("Nombre de noeuds : "IFORMAT" \n",nnoe);
00107
00108
00109
00110
00111 if (nnoe > 0) {
00112 coo = (med_float*) malloc(sizeof(med_float)*nnoe*mdim);
00113
00114
00115 numnoe = (med_int*) malloc(sizeof(med_int)*nnoe);
00116 nufano = (med_int*) calloc(nnoe,sizeof(med_int));
00117
00118
00119 nomnoe = (char*) malloc(MED_SNAME_SIZE*nnoe+1);
00120
00121
00122
00123
00124
00125
00126 if (MEDmeshNodeRd(fid,maa,MED_NO_DT,MED_NO_IT,MED_FULL_INTERLACE,
00127 coo,&inonoe,nomnoe,&inunoe,numnoe,&inufam,nufano) < 0) {
00128 MESSAGE("Erreur a la lecture des noeuds du maillage");
00129 ret = -1;
00130 }
00131
00132
00133 if (ret == 0) {
00134 printf("Type de repere : %d \n",rep);
00135 printf("Nom des coordonnees : \n");
00136 for (i=0;i<mdim;i++) {
00137 strncpy(str,nomcoo+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
00138 str[MED_SNAME_SIZE] = '\0';
00139 printf("|%s| ",str);
00140 }
00141 printf("\nUnites des coordonnees : \n");
00142 for (i=0;i<mdim;i++) {
00143 strncpy(str,unicoo+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
00144 str[MED_SNAME_SIZE] = '\0';
00145 printf("|%s| ",str);
00146 }
00147 printf("\nCoordonnees des noeuds : \n");
00148 for (i=0;i<nnoe*mdim;i++)
00149 printf("%f ",*(coo+i));
00150 if (inonoe) {
00151 printf("\nNoms des noeuds : \n");
00152 for (i=0;i<nnoe;i++) {
00153 strncpy(str,nomnoe+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
00154 str[MED_SNAME_SIZE] = '\0';
00155 printf(" |%s| ",str);
00156 }
00157 }
00158 if (inunoe) {
00159 printf("\nNumeros des noeuds : \n");
00160 for (i=0;i<nnoe;i++)
00161 printf(""IFORMAT" ",*(numnoe+i));
00162 }
00163
00164 printf("\nPrésence de numeros des familles des noeuds : %d\n",inufam);
00165 printf("\nNumeros des familles des noeuds : \n");
00166 for (i=0;i<nnoe;i++)
00167 printf(IFORMAT" ",*(nufano+i));
00168 printf("\n");
00169 }
00170
00171
00172 free(coo);
00173 free(nomnoe);
00174 free(numnoe);
00175 free(nufano);
00176 }
00177
00178
00179 if (MEDfileClose(fid) < 0) {
00180 MESSAGE("Erreur a la fermeture du fichier");
00181 return -1;
00182 }
00183
00184 return ret;
00185 }
00186
00187
00188
00189