MEDpolyedreConnEcr.c

Aller à la documentation de ce fichier.
00001 /*  This file is part of MED.
00002  *
00003  *  COPYRIGHT (C) 1999 - 2015  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 
00026 med_err
00027 MEDpolyedreConnEcr(med_idt fid,char *maa,med_int *indexp,med_int np,med_int *indexf,med_int nf,
00028                    med_int *con,med_connectivite type_conn)
00029 {
00030   med_err ret;
00031   med_idt maaid, entid, geoid, dataset;
00032   char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1];  
00033   char nom_ent[MED_TAILLE_NOM_ENTITE+1];
00034   char nom_geo[MED_TAILLE_NOM_ENTITE+1];
00035   char nom_dataset1[MED_TAILLE_NOM_ENTITE+1];
00036   char nom_dataset2[MED_TAILLE_NOM_ENTITE+1];
00037   char nom_dataset3[MED_TAILLE_NOM_ENTITE+1];
00038   med_geometrie_element type_geo;
00039   med_entite_maillage type_ent;
00040   med_int n;
00041   med_size dimd[1];
00042   med_int consize;
00043 
00044   /*
00045    * On inhibe le gestionnaire d'erreur HDF 5
00046    */
00047   _MEDmodeErreurVerrouiller();
00048 if (MEDcheckVersion(fid) < 0) return -1;
00049 
00050 
00051   /*
00052    * Si le maillage n'existe pas => erreur
00053    */
00054   strcpy(chemin,MED_MAA);
00055   strcat(chemin,maa);
00056   if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
00057       return -1;
00058 
00059   /*
00060    * On met a jour le nom du groupe HDF representant
00061    * le type des entites
00062    */
00063   type_ent = MED_MAILLE;
00064    if ((ret = _MEDnomEntite(nom_ent,type_ent)) < 0)
00065      return -1;
00066 
00067    /*
00068     * Si le groupe HDF  des entites n'existe pas on le cree
00069     */
00070    if ((entid = _MEDdatagroupOuvrir(maaid,nom_ent)) < 0)
00071      if ((entid = _MEDdatagroupCreer(maaid,nom_ent)) < 0)
00072        return -1;
00073 
00074    /*
00075     * On cree s'il n'existe pas le groupe HDF du type geometrique
00076     */
00077    type_geo = MED_POLYEDRE;
00078    if ((ret = _MEDnomGeometrie(nom_geo,type_geo)) < 0)
00079      return -1;
00080    if ((geoid = _MEDdatagroupOuvrir(entid,nom_geo)) < 0)
00081      if ((geoid = _MEDdatagroupCreer(entid,nom_geo)) < 0)
00082        return -1;
00083 
00084    /*
00085     * On regarde si le dataset HDF existe et on le cree sinon
00086     */
00087    switch(type_conn)
00088      {
00089      case MED_NOD :
00090        strcpy(nom_dataset1,MED_NOM_INN);
00091        strcpy(nom_dataset2,MED_NOM_IFN);
00092        strcpy(nom_dataset3,MED_NOM_NOD);
00093        consize = indexf[nf-1] - indexf[0];
00094        break;
00095 
00096      case MED_DESC :
00097        strcpy(nom_dataset1,MED_NOM_IND);
00098        strcpy(nom_dataset2,MED_NOM_IFD);
00099        strcpy(nom_dataset3,MED_NOM_DES);
00100        consize = nf;
00101        break;
00102        
00103      default :
00104        return -1;
00105      }
00106 
00107 #if defined(HAVE_F77INT64)
00108    dimd[0] = np;
00109    if ((ret = _MEDdatasetNumEcrire(geoid,nom_dataset1,MED_INT64,MED_NO_INTERLACE,1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,0,MED_NOPG,dimd,
00110                                    (unsigned char*) indexp)) < 0)
00111      return -1;
00112    dimd[0] = nf;
00113    if ((ret = _MEDdatasetNumEcrire(geoid,nom_dataset2,MED_INT64,MED_NO_INTERLACE,1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,0,MED_NOPG,dimd,
00114                                    (unsigned char*) indexf)) < 0)
00115      return -1;
00116    dimd[0] = consize;
00117    if ((ret = _MEDdatasetNumEcrire(geoid,nom_dataset3,MED_INT64,MED_NO_INTERLACE,1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,0,MED_NOPG,dimd,
00118                                    (unsigned char*) con)) < 0)
00119      return -1;
00120 #else
00121    dimd[0] = np;
00122    if ((ret = _MEDdatasetNumEcrire(geoid,nom_dataset1,MED_INT32,MED_NO_INTERLACE,1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,0,MED_NOPG,dimd,
00123                                    (unsigned char*) indexp)) < 0)
00124      return -1;
00125    dimd[0] = nf;
00126    if ((ret = _MEDdatasetNumEcrire(geoid,nom_dataset2,MED_INT32,MED_NO_INTERLACE,1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,0,MED_NOPG,dimd,
00127                                    (unsigned char*) indexf)) < 0)
00128      return -1;
00129    dimd[0] = consize;
00130    if ((ret = _MEDdatasetNumEcrire(geoid,nom_dataset3,MED_INT32,MED_NO_INTERLACE,1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,0,MED_NOPG,dimd,
00131                                    (unsigned char*) con)) < 0)
00132      return -1;
00133 #endif
00134 
00135   /*
00136    * On stocke le nombre de polyedre : (np-1)
00137    */
00138    n = np - 1;
00139    if ((dataset = _MEDdatasetOuvrir(geoid,nom_dataset3)) < 0)
00140      return -1;
00141    if ((ret = _MEDattrEntierEcrire(dataset,MED_NOM_NBR,&n)) < 0)
00142      return -1;
00143    if ((ret = _MEDdatasetFermer(dataset)) < 0)
00144      return -1;
00145 
00146    /*
00147     * On stocke la taille du tableau indexf (nf)
00148     */
00149    n = nf;
00150    if ((dataset = _MEDdatasetOuvrir(geoid,nom_dataset3)) < 0)
00151      return -1;
00152    if ((ret = _MEDattrEntierEcrire(dataset,MED_NOM_TTI,&n)) < 0)
00153      return -1;
00154    if ((ret = _MEDdatasetFermer(dataset)) < 0)
00155      return -1;
00156 
00157    /*
00158     * On stocke la taille du tableau conn (consize)
00159     */
00160    n = consize;
00161    if ((dataset = _MEDdatasetOuvrir(geoid,nom_dataset3)) < 0)
00162      return -1;
00163    if ((ret = _MEDattrEntierEcrire(dataset,MED_NOM_TAI,&n)) < 0)
00164      return -1;
00165    if ((ret = _MEDdatasetFermer(dataset)) < 0)
00166      return -1;
00167 
00168    /*
00169     * On ferme tout 
00170     */
00171    if ((ret = _MEDdatagroupFermer(geoid)) < 0)
00172      return -1;
00173    if ((ret = _MEDdatagroupFermer(entid)) < 0)
00174      return -1;
00175    if ((ret = _MEDdatagroupFermer(maaid)) < 0)
00176      return -1;
00177 
00178   return ret;
00179 }

Généré le Thu Oct 8 14:26:16 2015 pour MED fichier par  doxygen 1.6.1