MEDchampRefInfo.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 #include <string.h>
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 med_err
00043 MEDchampRefInfo(med_idt fid,char *champ,
00044 med_entite_maillage type_ent, med_geometrie_element type_geo,
00045 int indice, med_int numdt, med_int numo,
00046 char * maa, med_booleen * local, med_int *ngauss)
00047 {
00048
00049 med_err ret=-1;
00050 int num;
00051 med_idt datagroup3=0,gid_maa=0,gid_lien=0;
00052 char chemin[(MED_TAILLE_CHA+MED_TAILLE_NOM+1)+(2*MED_TAILLE_NOM_ENTITE+2)+(2*MED_MAX_PARA+1)+(MED_TAILLE_NOM)+1]="";
00053 char chemin_maa[MED_TAILLE_MAA+MED_TAILLE_NOM+1]="";
00054 char chemin_lien[MED_TAILLE_LIENS+MED_TAILLE_NOM+1]="";
00055 char nomdatagroup1[2*MED_TAILLE_NOM_ENTITE+2]="";
00056 char nomdatagroup2[2*MED_MAX_PARA+1]="";
00057 char tmp1 [MED_TAILLE_NOM_ENTITE+1]="";
00058
00059
00060
00061
00062 _MEDmodeErreurVerrouiller();
00063 if (MEDcheckVersion(fid) < 0) return -1;
00064
00065
00066
00067
00068
00069 strcpy(chemin,MED_CHA);
00070 strcat(chemin,champ);
00071 strcat(chemin,"/");
00072
00073
00074
00075
00076
00077
00078 if (_MEDnomEntite(nomdatagroup1,type_ent) < 0)
00079 goto ERROR;
00080 if ((type_ent != MED_NOEUD)) {
00081 if (_MEDnomGeometrie30(tmp1,type_geo) < 0)
00082 goto ERROR;
00083 strcat(nomdatagroup1,".");
00084 strcat(nomdatagroup1,tmp1);
00085 }
00086 strcat(chemin,nomdatagroup1);
00087 strcat(chemin,"/");
00088
00089
00090
00091
00092 sprintf(nomdatagroup2,"%*li%*li",MED_MAX_PARA,(long ) numdt,MED_MAX_PARA,(long ) numo);
00093
00094 strcat(chemin,nomdatagroup2);
00095 strcat(chemin,"/");
00096
00097
00098
00099
00100
00101 num = indice - 1;
00102 if (_MEDobjetIdentifier(fid,chemin,num,maa) < 0) {
00103 MESSAGE("Impossible de trouver un groupe à l'indice spécifié : ");
00104 SSCRUTE(chemin); ISCRUTE_int(num); goto ERROR;
00105 };
00106 strcat(chemin,maa);
00107
00108
00109
00110
00111
00112
00113 if ((datagroup3 = _MEDdatagroupOuvrir(fid,chemin)) < 0) {
00114 MESSAGE("Erreur d'ouverture du datagroup lien au maillage : ");
00115 SSCRUTE(chemin); goto ERROR;
00116 };
00117
00118
00119
00120 if (_MEDattrEntierLire(datagroup3,MED_NOM_NGA,ngauss) < 0) {
00121 MESSAGE("Erreur à la lecture de l'attribut MED_NOM_NGA : ");
00122 ISCRUTE(*ngauss);goto ERROR;
00123 };
00124
00125
00126
00127 strcpy(chemin_maa,MED_MAA);
00128 strcat(chemin_maa,maa);
00129
00130 if ( (gid_maa = _MEDdatagroupOuvrir(fid,chemin_maa)) < 0) {
00131
00132
00133 strcpy(chemin_lien,MED_LIENS);
00134 strcat(chemin_lien,maa);
00135 if ((gid_lien = _MEDdatagroupOuvrir(fid,chemin_lien)) < 0) {
00136
00137
00138 *local = MED_FAUX;
00139 }
00140
00141 *local = MED_FAUX;
00142
00143 } else
00144 *local = MED_VRAI;
00145
00146
00147
00148
00149
00150
00151 ret = 0;
00152
00153 ERROR:
00154
00155 if (datagroup3>0) if (_MEDdatagroupFermer(datagroup3) < 0) {
00156 MESSAGE("Impossible de fermer le datagroup : ");
00157 ISCRUTE_int(datagroup3); ret = -1;
00158 }
00159
00160 if (gid_maa>0) if (_MEDdatagroupFermer(gid_maa) < 0) {
00161 MESSAGE("Impossible de fermer le datagroup : ");
00162 ISCRUTE_id(gid_maa); ret = -1;
00163 }
00164
00165 if (gid_lien>0) if (_MEDdatagroupFermer(gid_lien) < 0) {
00166 MESSAGE("Impossible de fermer le datagroup : ");
00167 SSCRUTE(chemin_lien); ret = -1;
00168 }
00169
00170 return ret;
00171 }