_MEDequivalenceCorrespondenceRd30.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 <string.h>
00024 #include <stdlib.h>
00025 void
00026 _MEDequivalenceCorrespondenceRd30(int dummy, ...) {
00027 
00028   va_list params;
00029   va_start(params,dummy);
00030 
00031   const med_idt            fid            = va_arg(params,const med_idt             );
00032   const char * const       meshname       = va_arg(params,const char * const        );
00033   const char * const       equivname      = va_arg(params,const char * const        );
00034   const med_int            numdt          = va_arg(params,const med_int             );
00035   const med_int            numit          = va_arg(params,const med_int             );
00036   const med_entity_type    entitype       = va_arg(params,const med_entity_type     );
00037   const med_geometry_type  geotype        = va_arg(params,const med_geometry_type   );
00038   med_int * const          correspondence = va_arg(params,med_int * const           );
00039   med_err *                fret           = va_arg(params,med_err *);
00040 
00041 
00042   med_idt            _root=0,_eqid=0,_meshid=0,_cstpid=0,_datagroup2=0;
00043   med_idt            _dataset=0;
00044   med_err            _ret=-1;
00045   char               _path[MED_TAILLE_EQS+2*MED_NAME_SIZE+2]=MED_EQS;
00046   char               _computationstepname[2*MED_MAX_PARA+1]="";
00047   char               _datagroupname2[2*MED_TAILLE_NOM_ENTITE+2]="";
00048   char               _geotypename   [MED_TAILLE_NOM_ENTITE+1]="";
00049   med_sorting_type   _sortingtype=0;
00050   med_filter         _filter        = MED_FILTER_INIT;
00051   med_geometry_type  _geotype=MED_NONE;
00052   med_int            _nentity=0;
00053 
00054   if ( entitype == MED_NODE_ELEMENT ) _geotype=MED_NODE ;
00055 
00056   if ( (geotype / 100 ) > 2 )  {
00057     MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_GEOMETRIC,MED_ERR_EQUIVALENCE_MSG);
00058     SSCRUTE(equivname);ISCRUTE_int(geotype);
00059     goto ERROR;
00060   }
00061 
00062   if ( entitype != MED_NODE ) _geotype=geotype ;
00063 
00064   /*
00065    * On inhibe le gestionnaire d'erreur
00066    */
00067   _MEDmodeErreurVerrouiller();
00068 
00069  
00070   /*
00071    * Ouverture du dataGroup /EQS/
00072    */
00073   if ((_root = _MEDdatagroupOuvrir(fid,_path)) < 0) {
00074     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
00075     goto ERROR;
00076   }
00077 
00078   /*
00079    * Ouverture du dataGroup <meshname>
00080    */
00081   if ((_meshid = _MEDdatagroupOuvrir(_root,meshname)) < 0) {
00082     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,meshname);
00083     SSCRUTE(_path);goto ERROR;
00084   }
00085 
00086   strcat(_path,meshname);
00087 
00088   /*
00089    * Si le Data Group "/EQS/<meshname>/<equivname>" n'existe pas, on le cree
00090    */
00091   if ((_eqid = _MEDdatagroupOuvrir(_meshid,equivname)) < 0) {
00092       MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,equivname);
00093       SSCRUTE(_path);goto ERROR;
00094   }
00095 
00096   strcat(_path,"/");
00097   strcat(_path,equivname);
00098 
00099   if ( MEDmeshSortingTypeRd(fid,meshname,&_sortingtype) < 0 ) {
00100     MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API," MEDmeshSortingTypeRd");
00101     SSCRUTE(meshname);ISCRUTE_int(_sortingtype);goto ERROR;
00102   }
00103 
00104   _MEDgetComputationStepName(_sortingtype,numdt,numit,_computationstepname);
00105 
00106   if ((_cstpid = _MEDdatagroupOuvrir(_eqid,_computationstepname)) < 0) {
00107     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_computationstepname);
00108     SSCRUTE(_path);goto ERROR;
00109   }
00110 
00111 
00112   /*
00113    *  Ouverture du datagroup de niveau <entitype>[.<geotype>]
00114    */
00115   if (_MEDgetEntityTypeName(_datagroupname2,entitype) < 0) {
00116     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ENTITY,MED_ERR_VALUE_MSG);
00117     ISCRUTE_int(entitype);SSCRUTE(equivname);goto ERROR;
00118   }
00119   if ( entitype != MED_NODE ) {
00120     if ( _MEDgetGeometryTypeName(_geotypename,geotype) < 0) {
00121       MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_GEOMETRIC,MED_ERR_VALUE_MSG);
00122       ISCRUTE_int(geotype);SSCRUTE(equivname);goto ERROR;
00123     }
00124       strcat(_datagroupname2,".");
00125       strcat(_datagroupname2,_geotypename);
00126   }
00127 
00128   if ( (_datagroup2 = _MEDdatagroupOuvrir(_cstpid,_datagroupname2)) < 0) {
00129     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_datagroupname2);
00130     SSCRUTE(_path);SSCRUTE(equivname);goto ERROR;
00131   }
00132 
00133 
00134   if ((_dataset = _MEDdatasetOuvrir(_datagroup2,MED_NOM_COR)) < 0) {
00135     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATASET,MED_NOM_COR);
00136     SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);SSCRUTE(_datagroupname2);
00137     goto ERROR;
00138   }
00139 
00140   if ( _MEDattrEntierLire(_dataset,MED_NOM_NBR,&_nentity) < 0) {
00141     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_EQUIVALENCE_MSG);
00142     SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);SSCRUTE(_datagroupname2);
00143     SSCRUTE(MED_NOM_NBR);ISCRUTE(_nentity);goto ERROR;
00144   }
00145 
00146   if ( MEDfilterEntityCr(fid, _nentity, 1, 2, MED_ALL_CONSTITUENT,
00147                          MED_NO_INTERLACE,MED_UNDEF_PFLMODE,
00148                          MED_NO_PROFILE, MED_UNDEF_SIZE, NULL, &_filter) < 0 ) {
00149     MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,MED_ERR_INTERNAL_MSG);
00150     goto ERROR;
00151   }
00152 
00153   if ( _MEDdatasetRd(_datagroup2,MED_NOM_COR,MED_INTERNAL_INT,&_filter, (unsigned char *) correspondence) < 0) {
00154     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_DATASET,MED_NOM_COR);
00155     SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);
00156     goto ERROR;
00157   }
00158 
00159   if ( MEDfilterClose(&_filter) < 0 ) {
00160     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,MED_ERR_EQUIVALENCE_MSG);
00161     SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);
00162     goto ERROR;
00163   }
00164 
00165   _ret=0;
00166  ERROR:
00167 
00168   if (_dataset>0)     if (_MEDdatasetFermer(_dataset) < 0) {
00169     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATASET,MED_NOM_COR);
00170     ISCRUTE_id(_dataset);
00171   }
00172 
00173   if (_datagroup2>0)            if (_MEDdatagroupFermer(_datagroup2) < 0) {
00174     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_datagroupname2);
00175     ISCRUTE_id(_datagroup2);SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);
00176   }
00177 
00178   if (_cstpid>0)            if (_MEDdatagroupFermer(_cstpid) < 0) {
00179     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_computationstepname);
00180     ISCRUTE_id(_cstpid);SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);
00181   }
00182 
00183   if (_eqid>0)            if (_MEDdatagroupFermer(_eqid) < 0) {
00184     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,equivname);
00185     ISCRUTE_id(_eqid);SSCRUTE(_path);
00186   }
00187 
00188   if (_meshid>0)            if (_MEDdatagroupFermer(_meshid) < 0) {
00189     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,meshname);
00190     ISCRUTE_id(_eqid);
00191   }
00192 
00193   if (_root>0)            if (_MEDdatagroupFermer(_root) < 0) {
00194     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_EQS);
00195     ISCRUTE_id(_eqid);
00196   }
00197 
00198   va_end(params);
00199   *fret = _ret;
00200 
00201   return;
00202 }

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