MED23v30axesInfo.c
Aller à la documentation de ce fichier.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <med.h>
00020 #include <med_config.h>
00021 #include <med_outils.h>
00022
00023 #include <string.h>
00024 #include <stdlib.h>
00025
00026
00027 med_err
00028 MED23v30axesInfo(med_idt fid, char *maa, med_repere *type_rep,
00029 char *nom, char *unit)
00030 {
00031 med_err _ret=-1;
00032 med_idt maaid=0, noeid=0;
00033 med_idt dataset[3]= {0} ;
00034 char *griddatasetname[3]={MED_NOM_IN1,MED_NOM_IN2,MED_NOM_IN3};
00035 med_int _ndataset=1;
00036 char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1];
00037 med_int type_rep_int;
00038 med_int _spacedim=0,_meshdim=0,_nsubstring=0;
00039 med_int att=0;
00040 med_maillage maillage_type;
00041 med_type_grille type;
00042 int _i=0,len=0,_p=0;
00043 char* _ptmp=NULL;
00044 med_booleen _nomlenwas0=MED_FAUX,_unitlenwas0=MED_FAUX;
00045
00046
00047
00048 _MEDmodeErreurVerrouiller();
00049 if (MEDcheckVersion(fid) < 0) return -1;
00050
00051
00052
00053
00054
00055
00056 strcpy(chemin,MED_MAA);
00057 strcat(chemin,maa);
00058 if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) { goto ERROR;}
00059
00060
00061
00062
00063 if ( _MEDattrEntierLire(maaid,MED_NOM_DIM,&_meshdim) < 0) { goto ERROR;}
00064
00065 if ( (_spacedim = MEDdimEspaceLire(fid, maa) < 0 ) ) _spacedim=_meshdim;
00066 _nsubstring = _spacedim;
00067
00068
00069
00070
00071 if ((noeid = _MEDdatagroupOuvrir(maaid,MED_NOM_NOE)) < 0) { goto ERROR;}
00072
00073
00074
00075
00076 if ( _MEDattrEntierLire(maaid,MED_NOM_TYP,&att) < 0) { goto ERROR;}
00077 maillage_type = (med_maillage) att;
00078
00079 if (maillage_type == MED_NON_STRUCTURE) {
00080
00081
00082
00083 if ((dataset[0] = _MEDdatasetOuvrir(noeid,MED_NOM_COO)) < 0) { goto ERROR;}
00084
00085 } else {
00086
00087
00088
00089 if ( _MEDattrEntierLire(maaid,MED_NOM_GTY,&att) < 0) goto ERROR;
00090 type = (med_type_grille) att;
00091
00092 if (type != MED_GRILLE_STANDARD) {
00093 _ndataset=_meshdim;
00094 _nsubstring = 1;
00095
00096 for (_i= 0; _i<_ndataset; ++_i) {
00097 if ((dataset[_i] = _MEDdatasetOuvrir(noeid,griddatasetname[_i])) < 0) { goto ERROR;}
00098 }
00099 } else {
00100
00101
00102
00103 if ((dataset[0] = _MEDdatasetOuvrir(noeid,MED_NOM_COO)) < 0) { goto ERROR;}
00104 }
00105
00106 }
00107
00108
00109
00110
00111
00112 if ( (maillage_type == MED_STRUCTURE) && (type != MED_GRILLE_STANDARD) ) {
00113 *type_rep = MED_CART;
00114 } else
00115 if ( _MEDattrEntierLire(dataset[0],MED_NOM_REP,&type_rep_int) < 0 )
00116 { goto ERROR;}
00117 else
00118 *type_rep = (med_repere) type_rep_int;
00119
00120 for (_i= 0; _i<_ndataset; ++_i) {
00121
00122
00123
00124
00125 _ptmp =&nom[MED_TAILLE_PNOM*_i];
00126 if ( _MEDattrStringLire(dataset[_i],MED_NOM_NOM,_nsubstring*MED_TAILLE_PNOM,
00127 _ptmp) < 0)
00128 { goto ERROR;}
00129
00130 len=strlen(_ptmp);
00131 if ( len == 0 ) _nomlenwas0=MED_VRAI;
00132 if ( (len > 0 ) && _nomlenwas0 ) {
00133 MESSAGE("Un des noms d'axes est vide et d'autres non!");
00134 }
00135 if ( (len < MED_TAILLE_PNOM ) && (len > 0) ) {
00136 for (_p=(MED_TAILLE_PNOM-1); _p>=len; --_p) *( _ptmp + _p)=' ';
00137 *(_ptmp+MED_TAILLE_PNOM)='\0';
00138 }
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 _ptmp =&unit[MED_TAILLE_PNOM*_i];
00149 if ( _MEDattrStringLire(dataset[_i],MED_NOM_UNI,_nsubstring*MED_TAILLE_PNOM,
00150 _ptmp) < 0)
00151 { goto ERROR;}
00152
00153 len=strlen(_ptmp);
00154 if ( len == 0 ) _unitlenwas0=MED_VRAI;
00155 if ( (len > 0 ) && _unitlenwas0 ) {
00156 MESSAGE("Un des noms d'unité d'axes est vide et d'autres non!");
00157 }
00158 if ( (len < MED_TAILLE_PNOM) && (len > 0) ) {
00159 for (_p=(MED_TAILLE_PNOM-1); _p>=len; --_p) *( _ptmp + _p)=' ';
00160 *(_ptmp+MED_TAILLE_PNOM)='\0';
00161 }
00162
00163 }
00164
00165
00166
00167
00168
00169 _ret = 0;
00170 ERROR:
00171
00172 for (_i= 0; _i<_ndataset; ++_i)
00173 if (dataset[_i] > 0 )
00174 if ( _MEDdatasetFermer(dataset[_i]) < 0)
00175 _ret= -1;
00176
00177 if (noeid > 0 )
00178 if ( _MEDdatagroupFermer(noeid) < 0)
00179 _ret= -1;
00180 if (maaid > 0 )
00181 if ( _MEDdatagroupFermer(maaid) < 0)
00182 _ret= -1;
00183
00184 return _ret;
00185 }