Test_MEDmeshStructElementVarAttRd.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 #define MESGERR 1
00021 #include <med_utils.h>
00022 #include <string.h>
00023 
00024 #ifdef DEF_LECT_ECR
00025 #define MODE_ACCES MED_ACC_RDWR
00026 #elif DEF_LECT_AJOUT
00027 #define MODE_ACCES MED_ACC_RDEXT
00028 #else
00029 #define MODE_ACCES MED_ACC_CREAT
00030 #endif
00031 
00032 int main (int argc, char **argv)
00033 
00034 {
00035   med_err           _ret=0;
00036   med_idt           _fid=0;
00037   med_geometry_type _geotype=MED_NONE;
00038   int               _i=0;
00039 
00040   const char        _elementname1[]="MED_BILLE";
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048   const char                _varattname1_1[MED_NAME_SIZE+1]="MED_VFOO_ATR1_1";
00049  
00050 
00051   const med_int             _varatrvalue1_1[3]={ 22 , 24, 25 };
00052         med_int             _read_varatrvalue1_1[3];
00053 
00054 
00055 
00056 
00057 
00058 
00059 
00060 
00061 
00062   const char   _meshname[]="maa1";
00063   const med_int _nentity = 3;
00064 
00065   const med_int _con[3]={ 2, 4 ,5}; 
00066   med_int       _read_con[3];
00067 
00068   
00069   _fid = MEDfileOpen("current.med",MED_ACC_RDONLY);
00070   if (_fid < 0) {
00071     MESSAGE("Erreur à l'ouverture du fichier current.med");
00072     return -1;
00073   }
00074 
00075   _geotype = MEDstructElementGeotype(_fid,_elementname1);
00076 
00077   
00078   if ( MEDmeshElementConnectivityRd(_fid,_meshname, MED_NO_DT, MED_NO_IT,
00079                                     MED_STRUCT_ELEMENT, _geotype, MED_NODAL,
00080                                     MED_FULL_INTERLACE, _read_con) < 0 ) {
00081     MESSAGE("Impossible de lire la connectivité des billes: ");
00082     return -1;
00083   }
00084   for ( _i=0; _i < _nentity; ++_i ) {
00085     fprintf(stdout,"Connectivité[%d]=%d.\n",_i,_read_con[_i]);
00086     if ( _read_con[_i]!=_con[_i] ) {fprintf(stderr,"Erreur de cohérence de la connectivité lue.\n");return -1;}
00087   }
00088 
00089   if (MEDmeshStructElementVarAttRd(_fid,
00090                                    _meshname,
00091                                    MED_NO_DT,
00092                                    MED_NO_IT,
00093                                    _geotype,
00094                                    _varattname1_1,
00095                                    _read_varatrvalue1_1
00096                                    ) < 0 ) {
00097     return -1;
00098   }
00099 
00100   for ( _i=0; _i < _nentity; ++_i ) {
00101     fprintf(stdout,"Vattr[%d]=%d.\n",_i,_read_varatrvalue1_1[_i]);
00102     if ( _read_varatrvalue1_1[_i]!=_varatrvalue1_1[_i] ) {
00103       fprintf(stderr,"Erreur de cohérence des valeurs"
00104               " de l'attribut variable %s.\n",_varattname1_1);
00105       return -1;}
00106   }
00107 
00108   return _ret;
00109 
00110 }
00111