# MAJ_236_300_entites.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 #ifndef MESGERR
    00020 #define MESGERR 1
    00021 #endif
    00022
    00023 #include "med_config.h"
    00024 #include "med_outils.h"
    00025 #include "med_versioned.h"
    00026 #include <string.h>
    00027
    00028
    00029 #include "MAJ_236_300.h"
    00030
    00031 int MAJ_236_300_entites(med_idt fid,
    00032                         char * const _pathi,
    00033                         char * const _pathf,
    00034                         const char * const meshname,
    00035                         const med_entity_type enttype)
    00036 {
    00037   med_err           _fret =-1,_ret=-1,ret=-1;
    00038   int dummy=0;
    00039   med_idt           _datagroupi=0,_datagroupf=0;
    00040   char              _enttypename[MED_TAILLE_NOM_ENTITE+1]="";
    00041   char              _geotypename[MED_TAILLE_NOM_ENTITE+1]="";
    00042   med_geometry_type _geotype    = MED_UNDEF_GEOMETRY_TYPE;
    00043   med_int           _intgeotype = MED_UNDEF_GEOMETRY_TYPE;
    00044   med_int           _ngeotype  = 0;
    00045   int               _itgeotype = 0;
    00046   int               _itmplen=0,_isavlen=0;
    00047   int               _ftmplen=0,_fsavlen=0;
    00048   int               _tmplen = 0;
    00049   med_int           _1 = 1;
    00050   med_bool          _chgt=MED_FALSE, _trsf=MED_FALSE;
    00051   char                   _profilename[MED_NAME_SIZE+1]="";
    00052   med_int                _profilesize=0;
    00053
    00054     /*
    00055      * Remarque : Cette procédure modifie le contenue des paramètres _pathi et pathf
    00056      */
    00057
    00058     /* read how many geotype element there is in the mesh for each entitytype */
    00059   _MEDmeshnEntity236(dummy,fid, meshname, (med_int) MED_NO_DT, (med_int) MED_NO_IT, enttype, MED_GEO_ALL,
    00060                        MED_UNDEF_DATATYPE, MED_NO_CMODE,MED_UNDEF_INTERLACE,
    00061                        _profilename, &_profilesize,&_chgt, &_trsf,&_ngeotype);
    00062     if ( _ngeotype < 0) {
    00063       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
    00064       SSCRUTE(meshname);SSCRUTE(MED_GET_ENTITY_TYPENAME[enttype+1]);
    00065       goto ERROR;
    00066     }
    00067
    00068 /*     ISCRUTE(_ngeotype); */
    00069     if (_ngeotype == 0) goto SORTIE;
    00070
    00071     if (_MEDgetEntityTypeName(_enttypename,enttype) < 0) goto ERROR;
    00072
    00073 /*     SSCRUTE(_enttypename); */
    00074
    00075     _itmplen=strlen(_pathi);
    00076     _ftmplen=strlen(_pathf);
    00077     _tmplen = strlen(_enttypename);
    00078
    00079     strcpy(&_pathi[_itmplen],_enttypename);
    00080     strcpy(&_pathf[_ftmplen],_enttypename);
    00081     _itmplen += _tmplen;
    00082     _ftmplen += _tmplen;;
    00083
    00084 /*     SSCRUTE(_pathi); */
    00085 /*     SSCRUTE(_pathf); */
    00086 /*     ISCRUTE(_itmplen); */
    00087 /*     ISCRUTE(_ftmplen); */
    00088 /*     ISCRUTE(_tmplen); */
    00089
    00090
    00091     /*
    00092      * Creation/Ecriture de l'attribut MED_NOM_CGT sur le datagroup <entite>
    00093      */
    00094     if ( _MEDattributeNumWrByName(fid,_pathi,MED_NOM_CGT,
    00095                                   MED_INTERNAL_INT,(const unsigned char * const) &_1 ) < 0 ) {
    00096       MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
    00097       SSCRUTE(_pathi);SSCRUTE(MED_GET_ENTITY_TYPENAME[enttype+1]);
    00098       goto ERROR;
    00099     }
    00100
    00101     if (enttype != MED_NODE ) {
    00102       _pathi[_itmplen]='/';++_itmplen;_pathi[_itmplen]='\0';
    00103       _pathf[_ftmplen]='/';++_ftmplen;_pathf[_ftmplen]='\0';
    00104     }
    00105     _isavlen=_itmplen;
    00106     _fsavlen=_ftmplen;
    00107
    00108 /*     SSCRUTE(_pathi); */
    00109 /*     SSCRUTE(_pathf); */
    00110
    00111     for ( _itgeotype=1; _itgeotype <= _ngeotype; ++_itgeotype) {
    00112
    00113 /*       ISCRUTE_int(_itgeotype); */
    00114       /* read the geotype */
    00115       _MEDmeshEntityInfo236(dummy,fid, meshname, MED_NO_DT, MED_NO_IT, enttype,_itgeotype,
    00116                             _geotypename,&_geotype,&_fret);
    00117       if (_fret  < 0) {
    00118         MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshEntityInfo");
    00119         SSCRUTE(meshname);SSCRUTE(MED_GET_ENTITY_TYPENAME[enttype+1]);ISCRUTE_int(_itgeotype);
    00120         goto ERROR;
    00121       }
    00122
    00123       _tmplen = strlen(_geotypename);
    00124       strcpy(&_pathi[_isavlen],_geotypename);
    00125       strcpy(&_pathf[_fsavlen],_geotypename);
    00126
    00127 /*       _itmplen += _tmplen; */
    00128 /*       _ftmplen += _tmplen; */
    00129 /*       SSCRUTE(_pathi); */
    00130 /*       SSCRUTE(_pathf); */
    00131
    00132       /*
    00133        * Creation/Ecriture de l'attribut MED_NOM_GEO sur le datagroup <typegeo>
    00134        */
    00135       _intgeotype = (med_int) _geotype;
    00136       if (enttype != MED_NODE )
    00137         if ( _MEDattributeNumWrByName(fid,_pathi,MED_NOM_GEO,MED_INTERNAL_INT,
    00138                                       (const unsigned char * const) &_intgeotype) < 0 ) {
    00139           MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
    00140           SSCRUTE(_pathi);SSCRUTE(MED_GET_ENTITY_TYPENAME[enttype+1]);ISCRUTE_int(_itgeotype);
    00141           ISCRUTE(_intgeotype);
    00142           goto ERROR;
    00143         }
    00144
    00145       /*
    00146        * Creation/Ecriture de l'attribut MED_NOM_PFL sur le datagroup <typegeo>
    00147        */
    00148       if ( _MEDattributeStringWrByName(fid,_pathi,MED_NOM_PFL,MED_NAME_SIZE,MED_NO_PROFILE_INTERNAL) < 0) {
    00149         MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
    00150         SSCRUTE(meshname);SSCRUTE(MED_GET_ENTITY_TYPENAME[enttype+1]);ISCRUTE_int(_itgeotype);
    00151         ISCRUTE(_intgeotype);SSCRUTE(MED_NOM_PFL);SSCRUTE(MED_NO_PROFILE_INTERNAL);
    00152         goto ERROR;
    00153       }
    00154
    00155       /*
    00156        * Creation/Ecriture de l'attribut MED_NOM_CGT sur le datagroup <typegeo>
    00157        */
    00158       /* Le modify ne fonctionne pas dans _MEDattributeNumWrByName à cause hdf5 ? */
    00159       if (enttype != MED_NODE )
    00160         if ( _MEDattributeNumWrByName(fid,_pathi,MED_NOM_CGT,MED_INTERNAL_INT,
    00161                                       (const unsigned char * const) &_1 ) < 0 ) {
    00162           MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
    00163           SSCRUTE(_pathi);SSCRUTE(MED_GET_ENTITY_TYPENAME[enttype+1]);
    00164           goto ERROR;
    00165         }
    00166
    00167       /*
    00168        * Creation/Ecriture de l'attribut MED_NOM_CGT sur le dataset
    00169        * Creation/Ecriture de l'attribut MED_NOM_CGS sur le datagroup
    00170        */
    00171
    00172       if ( MAJ_236_300_mesh_datasets(fid, _pathi, _pathf, meshname, enttype, _geotype)< 0) {
    00173         MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MAJ_236_300_mesh_datasets");
    00174         SSCRUTE(_pathi);
    00175         goto ERROR;
    00176       }
    00177
    00178     }
    00179
    00180
    00181     /* Déplacement de toute la branche du type de l'entité.*/
    00182     _pathi[_isavlen]='\0';
    00183     _pathf[_fsavlen]='\0';
    00184 /*     SSCRUTE(_pathf); */
    00185 /*     SSCRUTE(_pathi); */
    00186     ret = H5Gmove(fid, _pathi, _pathf  );
    00187     EXIT_IF(ret < 0,"Déplacement des entités de type",MED_GET_ENTITY_TYPENAME[enttype+1]);
    00188
    00189  SORTIE:
    00190   _ret=0;
    00191  ERROR:
    00192   return (int) _ret;
    00193 }