_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 <string.h>
00028 #include <stdlib.h>
00029 
00030 void
00031 _MEDmeshnEntity236(int dummy, ...)
00032 {
00033 
00034   va_list params;
00035   va_start(params,dummy);
00036 
00037   const med_idt                fid           = va_arg(params, const med_idt               );
00038   const char * const           meshname      = va_arg(params, const char * const          );
00039   const med_int                numdt         = va_arg(params, const med_int               );
00040   const med_int                numit         = va_arg(params, const med_int               );
00041   const med_entity_type        entitytype    = va_arg(params, const med_entity_type       );
00042   const med_geometry_type      geotype       = va_arg(params, const med_geometry_type     );
00043   const med_data_type          meddatatype   = va_arg(params, const med_data_type         );
00044   const med_connectivity_mode  cmode         = va_arg(params, const med_connectivity_mode );
00045   const med_storage_mode       storagemode   = va_arg(params, const med_storage_mode      );
00046         char     * const       profilename   = va_arg(params, char * const                );
00047         med_int  * const       profilesize   = va_arg(params, med_int * const             );
00048         med_bool * const       changement    = va_arg(params, med_bool * const            );
00049         med_bool * const       transformation= va_arg(params, med_bool * const            );
00050         med_int  *             fret          = va_arg(params, med_int *);
00051 
00052    med_int          _ret=-1,_n=0,_tmpn=0;
00053    med_size         _nn =0;
00054    med_data_type    _meddatatype = meddatatype;
00055    med_int          _nfaces=0;
00056    char             _meshpath[MED_TAILLE_MAA+MED_TAILLE_NOM+1]=MED_MAA;
00057    med_idt          _meshid=0,_datagroup1=0;
00058    char             _datagroupname1[MED_TAILLE_NOM_ENTITE+1]="";
00059    med_err          _err =0;
00060    med_bool         _datagroupexist=MED_FALSE;
00061    med_bool         _isasoftlink   =MED_FALSE;
00062    int              _cmodeit=0, _ncmode=1;
00063    med_connectivite _cmode[2] = { MED_NO_CMODE, MED_NO_CMODE };
00064    
00065  
00066   if ( (numdt != MED_NO_DT) || (numit != MED_NO_IT) ) {
00067     MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_COMPUTINGSTEP,MED_ERR_MESH_MSG);
00068     SSCRUTE(meshname);ISCRUTE(numdt);ISCRUTE(numit);
00069     goto ERROR;
00070   }
00071 
00072   _cmode[0]= (med_connectivite) cmode;
00073 
00074   if ( entitytype == MED_UNDEF_ENTITY_TYPE ) goto SORTIE;
00075 
00076   /*
00077    * Gestion entitytype == MED_ALL_ENTITY_TYPE
00078    */
00079   if ( entitytype == MED_ALL_ENTITY_TYPE ) {
00080 
00081     strcat(_meshpath,meshname);
00082     if ((_meshid = _MEDdatagroupOuvrir(fid,_meshpath)) < 0) {
00083       MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_meshpath);
00084       ISCRUTE_id(_meshid);goto ERROR;
00085     }
00086 
00087     if( _MEDdatagroupExist(_meshid,MED_NOM_NOE,&_datagroupexist,&_isasoftlink) < 0 ) {
00088       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDdatagroupExist");
00089       SSCRUTE(MED_NOM_NOE);goto ERROR;
00090     }
00091     if ( _datagroupexist ) _nn++;
00092 
00093     if( _MEDdatagroupExist(_meshid,MED_NOM_MAI,&_datagroupexist,&_isasoftlink) < 0 ) {
00094       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDdatagroupExist");
00095       SSCRUTE(MED_NOM_MAI);goto ERROR;
00096     }
00097     if ( _datagroupexist ) _nn++;
00098 
00099     if( _MEDdatagroupExist(_meshid,MED_NOM_FAC,&_datagroupexist,&_isasoftlink) < 0 ) {
00100       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDdatagroupExist");
00101       SSCRUTE(MED_NOM_FAC);goto ERROR;
00102     }
00103     if ( _datagroupexist ) _nn++;
00104 
00105     if( _MEDdatagroupExist(_meshid,MED_NOM_ARE,&_datagroupexist,&_isasoftlink) < 0 ) {
00106       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDdatagroupExist");
00107       SSCRUTE(MED_NOM_ARE);goto ERROR;
00108     }
00109     if ( _datagroupexist ) _nn++;
00110 
00111 /* En 2.3.6 les familles, les équivalences ... sont stockées dans le groupe <meshname>*/
00112 /*     _err=_MEDnObjects(_meshid,".",&_nn); */
00113 /*     if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) { */
00114 /*       MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,_meshid); */
00115 /*       goto ERROR; */
00116 /*     } */
00117     _n = _nn;
00118     goto SORTIE;
00119   }
00120 
00121   if ( geotype == MED_GEO_ALL ) {
00122 
00123       strcat(_meshpath,meshname);
00124       if ((_meshid = _MEDdatagroupOuvrir(fid,_meshpath)) < 0) {
00125         MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_meshpath);
00126         ISCRUTE_id(_meshid);goto ERROR;
00127       }
00128 
00129       if (_MEDgetEntityTypeName(_datagroupname1,entitytype) < 0) {
00130         MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ENTITY,MED_ERR_VALUE_MSG);
00131         ISCRUTE_int(entitytype);SSCRUTE(meshname);goto ERROR;
00132       }
00133 
00134       if ((_datagroup1 = _MEDdatagroupOuvrir(_meshid,_datagroupname1)) < 0) {
00135         _n=0;_datagroup1=0;
00136         goto SORTIE;
00137       }
00138 
00139       _err=_MEDnObjects(_datagroup1,".",&_nn);
00140       if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) {
00141         MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,_datagroupname1);
00142         goto ERROR;
00143       }
00144 /*       SSCRUTE(_datagroupname1);ISCRUTE_long(_nn); */
00145       if ( ( entitytype == MED_NODE ) && (_nn > 0) ) _nn=1;
00146 /*       SSCRUTE(_datagroupname1);ISCRUTE_long(_nn); */
00147       _n = _nn;
00148       goto SORTIE;
00149 
00150   }
00151 
00152 
00153   switch( meddatatype )
00154     {
00155     case MED_GLOBAL_NUMBER:
00156     case MED_NAME:
00157     case MED_NUMBER:
00158     case MED_FAMILY_NUMBER:
00159 
00160       switch (entitytype) {
00161       case MED_NODE:
00162         /*Pour connaître le nombre d'entités des attributs optionnels,
00163           on se base sur le tableau de coordonnées */
00164 /*      _meddatatype = MED_COORDINATE; */
00165         break;
00166       case MED_CELL:
00167       case MED_DESCENDING_FACE:
00168       case MED_DESCENDING_EDGE:
00169         /*Pour connaître le nombre d'entités des attributs optionnels,
00170           on se base sur le tableau de connectivité */
00171 /*      _meddatatype = MED_CONNECTIVITY; */
00172 
00173         /*
00174          * Positionne un mode de connectivité _cmode si le meddatatype demandé
00175          * est autre chose que des coordonnées ou des connectivités et le cmode non
00176          * positionné.
00177          * Cette Information est necessaire pour construire le nom du datatset.
00178          */
00179         if ( _cmode[0] == MED_NO_CMODE ) {
00180           _ncmode =2;_cmode[0]=MED_NOD;_cmode[1]=MED_DESC;
00181         }
00182         break;
00183       default:
00184         MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_ENTITY,MED_ERR_VALUE_MSG);
00185         ISCRUTE_int(entitytype);goto ERROR;
00186       }
00187       goto CALL_NENT;
00188 
00189     case MED_COORDINATE: /*Par extension au CONNECTIVITY mais ne devrait pas être utilisé.*/
00190     case MED_CONNECTIVITY:
00191       if ( geotype == MED_POLYGON ) {
00192           if ( MEDpolygoneInfo( fid,(char *)meshname, (med_entite_maillage) entitytype, (med_connectivite) _cmode[0],
00193                                 &_n) < 0) {
00194 /*          MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDpolygoneInfo");SSCRUTE(meshname); */
00195 /*          ISCRUTE(meddatatype);ISCRUTE(entitytype);ISCRUTE(geotype);goto ERROR; */
00196             _n=0;
00197           }
00198           break;
00199       }
00200 
00201       if ( geotype == MED_POLYHEDRON ) {
00202         if (    MEDpolyedreInfo(fid,(char *) meshname, (med_connectivite) _cmode[0]
00203                                 ,&_nfaces,&_n) < 0) {
00204 /*        MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDpolyedreInfo");SSCRUTE(meshname); */
00205 /*        ISCRUTE(meddatatype);ISCRUTE(entitytype);ISCRUTE(geotype);goto ERROR; */
00206           _n=0;
00207         }
00208         break;
00209       }
00210       goto CALL_NENT;
00211 
00212     case MED_INDEX_FACE:
00213       if ( geotype == MED_POLYHEDRON ) {
00214 
00215         _meddatatype = MED_CONNECTIVITY;
00216         _n=1 ;
00217 
00218         goto CALL_NENT;
00219 
00220 /*      if ( (_n = MEDnEntMaa(fid,meshname,(med_table) MED_CONNECTIVITY, (med_entite_maillage) MED_CELL, */
00221 /*                            (med_geometrie_element) MED_POLYHEDRON, (med_connectivite) MED_NOD)) < 0) { */
00222 /*        MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDnEntMaa");SSCRUTE(meshname); */
00223 /*        ISCRUTE(meddatatype);ISCRUTE(entitytype);ISCRUTE(geotype);goto ERROR; */
00224 /*      } */
00225 
00226         _n+=1;
00227         break;
00228       } else {
00229         MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_GEOMETRIC,MED_ERR_VALUE_MSG);
00230         ISCRUTE_int(geotype);
00231         goto ERROR;
00232       }
00233     case MED_INDEX_NODE:
00234       if ( geotype == MED_POLYHEDRON ) {
00235         if ( MEDpolyedreInfo(fid,(char *) meshname, (med_connectivite) _cmode[0],&_nfaces, &_n) < 0) {
00236 /*        MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDpolyedreInfo");SSCRUTE(meshname); */
00237 /*        ISCRUTE(meddatatype);ISCRUTE(entitytype);ISCRUTE(geotype);goto ERROR; */
00238           _nfaces=0;
00239         }
00240         _n=_nfaces;
00241         break;
00242       } else
00243         if ( geotype == MED_POLYGON) {
00244           _meddatatype = MED_CONNECTIVITY;
00245           _n = 1;
00246         } else {
00247           MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_GEOMETRIC,MED_ERR_VALUE_MSG);
00248           ISCRUTE_int(geotype);goto ERROR;
00249         }
00250     case MED_COORDINATE_AXIS1:
00251     case MED_COORDINATE_AXIS2:
00252     case MED_COORDINATE_AXIS3:
00253 
00254     CALL_NENT:
00255 
00256       for (_cmodeit=0; _cmodeit < _ncmode; ++_cmodeit)
00257         if ( (_tmpn =  MEDnEntMaa( fid, (char *) meshname,
00258                                    (med_table)             _meddatatype,
00259                                    (med_entite_maillage)   entitytype,
00260                                    (med_geometrie_element) geotype,
00261                                    (med_connectivite)      _cmode[_cmodeit]) ) > 0 )
00262           break;
00263 
00264       if ( _tmpn < 0 ) {
00265         MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDnEntMaa");SSCRUTE(meshname);
00266         ISCRUTE_int(_meddatatype);ISCRUTE_int(entitytype);ISCRUTE_int(geotype);goto ERROR;
00267       }
00268 
00269       _n+=_tmpn;
00270       break;
00271 
00272     default:
00273       MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_MEDDATATYPE,MED_ERR_VALUE_MSG);
00274       ISCRUTE_int(meddatatype);goto ERROR;
00275 
00276     }
00277 
00278  SORTIE:
00279 
00280  *transformation = MED_FALSE;
00281  /*TODO : 3.0.1 : Tester la présence d'autres datasets
00282   que les coord/conn/index pour positionner chgt TRUE uniquement
00283  dans ce cas de figure.*/
00284  *changement     = MED_TRUE;
00285  *profilesize    = 0;
00286  profilename[0]  = '\0';
00287 
00288   _ret = _n;
00289 
00290  ERROR:
00291   if (_datagroup1>0)     if (_MEDdatagroupFermer(_datagroup1) < 0) {
00292     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_datagroupname1);
00293     ISCRUTE_id(_datagroup1);
00294   }
00295 
00296   if (_meshid>0)            if (_MEDdatagroupFermer(_meshid) < 0) {
00297     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_meshpath);
00298     ISCRUTE_id(_meshid);
00299   }
00300 
00301   *fret = _ret;
00302   va_end(params);
00303   return;
00304 }

Généré le Mon May 16 17:10:22 2011 pour MED fichier par  doxygen 1.6.1