_MEDmeshnEntity236.c

Aller à la documentation de ce fichier.
00001 /*  This file is part of MED.
00002  *
00003  *  COPYRIGHT (C) 1999 - 2011  EDF R&D, CEA/DEN
00004  *  MED is free software: you can redistribute it and/or modify
00005  *  it under the terms of the GNU Lesser General Public License as published by
00006  *  the Free Software Foundation, either version 3 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  MED is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Lesser General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Lesser General Public License
00015  *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 
00019 #include <med.h>
00020 #include "med_config.h"
00021 #include "med_outils.h"
00022 
00023 #include <2.3.6/med23v30.h>
00024 #include <2.3.6/med23v30_proto.h>
00025 #include "2.3.6/med23v30_misc.h"
00026 
00027 #include "med_versioned.h"
00028 
00029 #include <string.h>
00030 #include <stdlib.h>
00031 
00032 void
00033 _MEDmeshnEntity236(int dummy, ...)
00034 {
00035 
00036    med_int          _ret=-1,_n=0,_tmpn=0;
00037    med_size         _nn =0;
00038    med_data_type    _meddatatype;
00039    med_int          _nfaces=0;
00040    char             _meshpath[MED_TAILLE_MAA+MED_TAILLE_NOM+1]=MED_MAA;
00041    med_idt          _meshid=0,_datagroup1=0;
00042    char             _datagroupname1[MED_TAILLE_NOM_ENTITE+1]="";
00043    med_err          _err =0;
00044    med_bool         _datagroupexist=MED_FALSE;
00045    med_bool         _isasoftlink   =MED_FALSE;
00046    int              _cmodeit=0, _ncmode=1;
00047    med_connectivite _cmode[2] = { MED_NO_CMODE, MED_NO_CMODE };
00048  
00049   MED_VARGS_DECL(const, med_idt                , , fid           );
00050   MED_VARGS_DECL(const, char * , const           , meshname      );
00051   MED_VARGS_DECL(const, med_int                , , numdt         );
00052   MED_VARGS_DECL(const, med_int                , , numit         );
00053   MED_VARGS_DECL(const, med_entity_type        , , entitytype    );
00054   MED_VARGS_DECL(const, med_geometry_type      , , geotype       );
00055   MED_VARGS_DECL(const, med_data_type          , , meddatatype   );
00056   MED_VARGS_DECL(const, med_connectivity_mode  , , cmode         );
00057   MED_VARGS_DECL(const, med_storage_mode       , , storagemode   );
00058   MED_VARGS_DECL(, char     *, const       , profilename         );
00059   MED_VARGS_DECL(, med_int  *, const       , profilesize         );
00060   MED_VARGS_DECL(, med_bool *, const       , changement          );
00061   MED_VARGS_DECL(, med_bool *, const       , transformation      );
00062   MED_VARGS_DECL(, med_int  *             ,, fret                );
00063 
00064   va_list params;
00065   va_start(params,dummy);
00066 
00067   MED_VARGS_DEF(const, med_idt                , , fid           );
00068   MED_VARGS_DEF(const, char * , const           , meshname      );
00069   MED_VARGS_DEF(const, med_int                , , numdt         );
00070   MED_VARGS_DEF(const, med_int                , , numit         );
00071   MED_VARGS_DEF(const, med_entity_type        , , entitytype    );
00072   MED_VARGS_DEF(const, med_geometry_type      , , geotype       );
00073   MED_VARGS_DEF(const, med_data_type          , , meddatatype   );
00074   MED_VARGS_DEF(const, med_connectivity_mode  , , cmode         );
00075   MED_VARGS_DEF(const, med_storage_mode       , , storagemode   );
00076   MED_VARGS_DEF(, char     *, const       , profilename         );
00077   MED_VARGS_DEF(, med_int  *, const       , profilesize         );
00078   MED_VARGS_DEF(, med_bool *, const       , changement          );
00079   MED_VARGS_DEF(, med_bool *, const       , transformation      );
00080   MED_VARGS_DEF(, med_int  *             ,, fret                );
00081 
00082   _meddatatype=meddatatype;
00083    
00084  
00085   if ( (numdt != MED_NO_DT) || (numit != MED_NO_IT) ) {
00086     MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_COMPUTINGSTEP,MED_ERR_MESH_MSG);
00087     SSCRUTE(meshname);ISCRUTE(numdt);ISCRUTE(numit);
00088     goto ERROR;
00089   }
00090 
00091   _cmode[0]= (med_connectivite) cmode;
00092 
00093   if ( entitytype == MED_UNDEF_ENTITY_TYPE ) goto SORTIE;
00094 
00095   /*
00096    * Gestion entitytype == MED_ALL_ENTITY_TYPE
00097    */
00098   if ( entitytype == MED_ALL_ENTITY_TYPE ) {
00099 
00100     strcat(_meshpath,meshname);
00101     if ((_meshid = _MEDdatagroupOuvrir(fid,_meshpath)) < 0) {
00102       MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_meshpath);
00103       ISCRUTE_id(_meshid);goto ERROR;
00104     }
00105 
00106     if( _MEDdatagroupExist(_meshid,MED_NOM_NOE,&_datagroupexist,&_isasoftlink) < 0 ) {
00107       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDdatagroupExist");
00108       SSCRUTE(MED_NOM_NOE);goto ERROR;
00109     }
00110     if ( _datagroupexist ) _nn++;
00111 
00112     if( _MEDdatagroupExist(_meshid,MED_NOM_MAI,&_datagroupexist,&_isasoftlink) < 0 ) {
00113       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDdatagroupExist");
00114       SSCRUTE(MED_NOM_MAI);goto ERROR;
00115     }
00116     if ( _datagroupexist ) _nn++;
00117 
00118     if( _MEDdatagroupExist(_meshid,MED_NOM_FAC,&_datagroupexist,&_isasoftlink) < 0 ) {
00119       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDdatagroupExist");
00120       SSCRUTE(MED_NOM_FAC);goto ERROR;
00121     }
00122     if ( _datagroupexist ) _nn++;
00123 
00124     if( _MEDdatagroupExist(_meshid,MED_NOM_ARE,&_datagroupexist,&_isasoftlink) < 0 ) {
00125       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDdatagroupExist");
00126       SSCRUTE(MED_NOM_ARE);goto ERROR;
00127     }
00128     if ( _datagroupexist ) _nn++;
00129 
00130 /* En 2.3.6 les familles, les équivalences ... sont stockées dans le groupe <meshname>*/
00131 /*     _err=_MEDnObjects(_meshid,".",&_nn); */
00132 /*     if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) { */
00133 /*       MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,_meshid); */
00134 /*       goto ERROR; */
00135 /*     } */
00136     _n = _nn;
00137     goto SORTIE;
00138   }
00139 
00140   if ( geotype == MED_GEO_ALL ) {
00141 
00142       strcat(_meshpath,meshname);
00143       if ((_meshid = _MEDdatagroupOuvrir(fid,_meshpath)) < 0) {
00144         MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_meshpath);
00145         ISCRUTE_id(_meshid);goto ERROR;
00146       }
00147 
00148       if (_MEDgetEntityTypeName(_datagroupname1,entitytype) < 0) {
00149         MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ENTITY,MED_ERR_VALUE_MSG);
00150         ISCRUTE_int(entitytype);SSCRUTE(meshname);goto ERROR;
00151       }
00152 
00153       if ((_datagroup1 = _MEDdatagroupOuvrir(_meshid,_datagroupname1)) < 0) {
00154         _n=0;_datagroup1=0;
00155         goto SORTIE;
00156       }
00157 
00158       _err=_MEDnObjects(_datagroup1,".",&_nn);
00159       if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) {
00160         MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,_datagroupname1);
00161         goto ERROR;
00162       }
00163 /*       SSCRUTE(_datagroupname1);ISCRUTE_long(_nn); */
00164       if ( ( entitytype == MED_NODE ) && (_nn > 0) ) _nn=1;
00165 /*       SSCRUTE(_datagroupname1);ISCRUTE_long(_nn); */
00166       _n = _nn;
00167       goto SORTIE;
00168 
00169   }
00170 
00171 
00172   switch( meddatatype )
00173     {
00174     case MED_GLOBAL_NUMBER:
00175     case MED_NAME:
00176     case MED_NUMBER:
00177     case MED_FAMILY_NUMBER:
00178 
00179       switch (entitytype) {
00180       case MED_NODE:
00181         /*Pour connaître le nombre d'entités des attributs optionnels,
00182           on se base sur le tableau de coordonnées */
00183 /*      _meddatatype = MED_COORDINATE; */
00184         break;
00185       case MED_CELL:
00186       case MED_DESCENDING_FACE:
00187       case MED_DESCENDING_EDGE:
00188         /*Pour connaître le nombre d'entités des attributs optionnels,
00189           on se base sur le tableau de connectivité */
00190 /*      _meddatatype = MED_CONNECTIVITY; */
00191 
00192         /*
00193          * Positionne un mode de connectivité _cmode si le meddatatype demandé
00194          * est autre chose que des coordonnées ou des connectivités et le cmode non
00195          * positionné.
00196          * Cette Information est necessaire pour construire le nom du datatset.
00197          */
00198         if ( _cmode[0] == MED_NO_CMODE ) {
00199           _ncmode =2;_cmode[0]=MED_NOD;_cmode[1]=MED_DESC;
00200         }
00201         break;
00202       default:
00203         MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_ENTITY,MED_ERR_VALUE_MSG);
00204         ISCRUTE_int(entitytype);goto ERROR;
00205       }
00206       goto CALL_NENT;
00207 
00208     case MED_COORDINATE: /*Par extension au CONNECTIVITY mais ne devrait pas être utilisé.*/
00209     case MED_CONNECTIVITY:
00210       if ( geotype == MED_POLYGON ) {
00211           if ( MEDpolygoneInfo( fid,(char *)meshname, (med_entite_maillage) entitytype, (med_connectivite) _cmode[0],
00212                                 &_n) < 0) {
00213 /*          MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDpolygoneInfo");SSCRUTE(meshname); */
00214 /*          ISCRUTE(meddatatype);ISCRUTE(entitytype);ISCRUTE(geotype);goto ERROR; */
00215             _n=0;
00216           }
00217           break;
00218       }
00219 
00220       if ( geotype == MED_POLYHEDRON ) {
00221         if (    MEDpolyedreInfo(fid,(char *) meshname, (med_connectivite) _cmode[0]
00222                                 ,&_nfaces,&_n) < 0) {
00223 /*        MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDpolyedreInfo");SSCRUTE(meshname); */
00224 /*        ISCRUTE(meddatatype);ISCRUTE(entitytype);ISCRUTE(geotype);goto ERROR; */
00225           _n=0;
00226         }
00227         break;
00228       }
00229       goto CALL_NENT;
00230 
00231     case MED_INDEX_FACE:
00232       if ( geotype == MED_POLYHEDRON ) {
00233 
00234         _meddatatype = MED_CONNECTIVITY;
00235         _n=1 ;
00236 
00237         goto CALL_NENT;
00238 
00239 /*      if ( (_n = MEDnEntMaa(fid,meshname,(med_table) MED_CONNECTIVITY, (med_entite_maillage) MED_CELL, */
00240 /*                            (med_geometrie_element) MED_POLYHEDRON, (med_connectivite) MED_NOD)) < 0) { */
00241 /*        MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDnEntMaa");SSCRUTE(meshname); */
00242 /*        ISCRUTE(meddatatype);ISCRUTE(entitytype);ISCRUTE(geotype);goto ERROR; */
00243 /*      } */
00244 
00245         _n+=1;
00246         break;
00247       } else {
00248         MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_GEOMETRIC,MED_ERR_VALUE_MSG);
00249         ISCRUTE_int(geotype);
00250         goto ERROR;
00251       }
00252     case MED_INDEX_NODE:
00253       if ( geotype == MED_POLYHEDRON ) {
00254         if ( MEDpolyedreInfo(fid,(char *) meshname, (med_connectivite) _cmode[0],&_nfaces, &_n) < 0) {
00255 /*        MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDpolyedreInfo");SSCRUTE(meshname); */
00256 /*        ISCRUTE(meddatatype);ISCRUTE(entitytype);ISCRUTE(geotype);goto ERROR; */
00257           _nfaces=0;
00258         }
00259         _n=_nfaces;
00260         break;
00261       } else
00262         if ( geotype == MED_POLYGON) {
00263           _meddatatype = MED_CONNECTIVITY;
00264           _n = 1;
00265         } else {
00266           MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_GEOMETRIC,MED_ERR_VALUE_MSG);
00267           ISCRUTE_int(geotype);goto ERROR;
00268         }
00269     case MED_COORDINATE_AXIS1:
00270     case MED_COORDINATE_AXIS2:
00271     case MED_COORDINATE_AXIS3:
00272 
00273     CALL_NENT:
00274 
00275       for (_cmodeit=0; _cmodeit < _ncmode; ++_cmodeit)
00276         if ( (_tmpn =  MEDnEntMaa( fid, (char *) meshname,
00277                                    (med_table)             _meddatatype,
00278                                    (med_entite_maillage)   entitytype,
00279                                    (med_geometrie_element) geotype,
00280                                    (med_connectivite)      _cmode[_cmodeit]) ) > 0 )
00281           break;
00282 
00283       if ( _tmpn < 0 ) {
00284         MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDnEntMaa");SSCRUTE(meshname);
00285         ISCRUTE_int(_meddatatype);ISCRUTE_int(entitytype);ISCRUTE_int(geotype);goto ERROR;
00286       }
00287 
00288       _n+=_tmpn;
00289       break;
00290 
00291     default:
00292       MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_MEDDATATYPE,MED_ERR_VALUE_MSG);
00293       ISCRUTE_int(meddatatype);goto ERROR;
00294 
00295     }
00296 
00297  SORTIE:
00298 
00299  *transformation = MED_FALSE;
00300  /*TODO : 3.0.1 : Tester la présence d'autres datasets
00301   que les coord/conn/index pour positionner chgt TRUE uniquement
00302  dans ce cas de figure.*/
00303  *changement     = MED_TRUE;
00304  *profilesize    = 0;
00305  profilename[0]  = '\0';
00306 
00307   _ret = _n;
00308 
00309  ERROR:
00310   if (_datagroup1>0)     if (_MEDdatagroupFermer(_datagroup1) < 0) {
00311     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_datagroupname1);
00312     ISCRUTE_id(_datagroup1);
00313   }
00314 
00315   if (_meshid>0)            if (_MEDdatagroupFermer(_meshid) < 0) {
00316     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_meshpath);
00317     ISCRUTE_id(_meshid);
00318   }
00319 
00320   *fret = _ret;
00321   va_end(params);
00322   return;
00323 }

Généré le Mon Nov 7 16:21:23 2011 pour MED fichier par  doxygen 1.6.1