# MAJ_236_300_entites.c

Aller à la documentation de ce fichier.

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