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 <stdlib.h>
00024 #include <string.h>
00025 
00048 med_err
00049 MEDstructElementInfoByName(const med_idt             fid,
00050                            const char *        const modelname,
00051                            med_geometry_type * const mgeotype,
00052                            med_int*            const modeldim,
00053                            char*               const supportmeshname,
00054                            med_entity_type*    const sentitytype,
00055                            med_int*            const snnode,
00056                            med_int*            const sncell,
00057                            med_geometry_type*  const sgeotype,
00058                            med_int*            const nconstantattribute,
00059                            med_bool*           const anyprofile,
00060                            med_int*            const nvariableattribute
00061                            )
00062 {
00063 
00064   med_err           _ret=-1;
00065   med_idt            _elemid=0, _cstid=0;
00066   char              _path[MED_TAILLE_STRCT+MED_NAME_SIZE+1]=MED_STRCT;
00067   char              __profilename   [MED_NAME_SIZE+1]=MED_NO_PROFILE_INTERNAL;
00068   const char*       _profilename   = __profilename;
00069   med_int           _intentitytype = MED_UNDEF_ENTITY_TYPE;
00070   med_int           _nentity       = 0;
00071   med_size          _tmpn          = 0;
00072   med_bool          _chgt=MED_FALSE,_trsf=MED_FALSE;
00073   med_int           _medintmgeotype = MED_NONE;
00074   med_int           _medintsgeotype = MED_NONE;
00075   med_int           _intanyprofile  = 0;
00076 
00077   strcat(_path,modelname);
00078 
00079   
00080 
00081 
00082   if ((_elemid = _MEDdatagroupOpen(fid,_path)) < 0)  {
00083     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
00084     goto ERROR;
00085   }
00086 
00087   
00088 
00089 
00090   if ( _MEDattrEntierLire(_elemid,MED_NOM_NEO,&_medintmgeotype) < 0 ) {
00091     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
00092     SSCRUTE(MED_NOM_NEO);ISCRUTE(_medintmgeotype);
00093     goto ERROR;
00094   }
00095   *mgeotype=_medintmgeotype;
00096 
00097   
00098 
00099 
00100   if ( _MEDattrEntierLire(_elemid,MED_NOM_DIM,modeldim) < 0 ) {
00101     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
00102     SSCRUTE(MED_NOM_DIM);ISCRUTE(*modeldim);
00103     goto ERROR;
00104   }
00105 
00106   
00107 
00108 
00109   
00110   if ( _MEDattrStringLire(_elemid,MED_NOM_NOM,MED_NAME_SIZE,supportmeshname) < 0) {
00111     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
00112     SSCRUTE(MED_NOM_NOM);SSCRUTE(supportmeshname);
00113     goto ERROR;
00114   }
00115 
00116   
00117 
00118 
00119   if ( _MEDattrEntierLire(_elemid,MED_NOM_ENT,&_intentitytype) < 0 ) {
00120     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
00121     SSCRUTE(MED_NOM_ENT);ISCRUTE(_intentitytype);
00122     goto ERROR;
00123   }
00124 
00125   *sentitytype = (med_entity_type) _intentitytype;
00126 
00127   
00128 
00129 
00130   if ( _MEDattrEntierLire(_elemid,MED_NOM_GEO,&_medintsgeotype) < 0 ) {
00131     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
00132     SSCRUTE(MED_NOM_GEO);ISCRUTE(_medintsgeotype);
00133     goto ERROR;
00134   }
00135   *sgeotype=_medintsgeotype;
00136 
00137   
00138 
00139 
00140   if (strlen(supportmeshname)) {
00141     if ( (*snnode = MEDmeshnEntity(fid,supportmeshname,MED_NO_DT,MED_NO_IT,
00142                                      MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,
00143                                      &_chgt,&_trsf) )  <= 0) {
00144       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
00145       ISCRUTE(*snnode);goto ERROR;
00146     }
00147   } else {
00148     *snnode=1;
00149   }
00150   
00151 
00152 
00153 
00154   if (strlen(supportmeshname)) {
00155     if ( (*sncell = MEDmeshnEntity(fid,supportmeshname,MED_NO_DT,MED_NO_IT,
00156                                      MED_CELL,*sgeotype,MED_CONNECTIVITY,MED_NODAL,
00157                                      &_chgt,&_trsf) )  < 0) {
00158       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
00159       ISCRUTE(*sncell);goto ERROR;
00160     }
00161   } else {
00162     *sncell=0;
00163   }
00164 
00165 
00166   _MEDnObjects(_elemid,MED_CSTATR_NOM,&_tmpn);
00167 
00168   if ( _tmpn > 0) {
00169 
00170     if ((_cstid = _MEDdatagroupOpen(_elemid,MED_CSTATR_NOM)) < 0) {
00171       MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_CSTATR_NOM);
00172       SSCRUTE(_path);goto ERROR;
00173     }
00174 
00175     if ( _MEDattrEntierLire(_cstid,MED_NOM_PFU,&_intanyprofile) < 0) {
00176       MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_STRUCT_MSG);
00177       SSCRUTE(modelname);SSCRUTE(MED_NOM_PFU);
00178       goto ERROR;
00179     }
00180     *anyprofile=_intanyprofile;
00181 
00182     *nconstantattribute = (med_int) _tmpn;
00183 
00184   } else {
00185     *anyprofile = MED_FALSE;
00186     *nconstantattribute = 0;
00187   }
00188 
00189   _MEDnObjects(_elemid,MED_VARATR_NOM,&_tmpn);
00190   if ( _tmpn > 0)
00191     *nvariableattribute = (med_int) _tmpn;
00192   else
00193     *nvariableattribute = (med_int) 0;
00194 
00195   _ret=0;
00196 
00197  ERROR:
00198 
00199   if (_cstid>0)            if (_MEDdatagroupFermer(_cstid) < 0) {
00200     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_CSTATR_NOM);
00201     ISCRUTE_id(_cstid);
00202   }
00203 
00204   if (_elemid>0)            if (_MEDdatagroupFermer(_elemid) < 0) {
00205     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,modelname);
00206     ISCRUTE_id(_elemid);
00207   }
00208 
00209   return _ret;
00210 }