# MEDjointnCorres.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
    00026 extern int mode_interlace;
    00027
    00028 med_int
    00029 MEDjointnCorres (med_idt fid, char *maa, char *jn,
    00030                  med_entite_maillage type_ent_local,   med_geometrie_element typ_geo_local,
    00031                  med_entite_maillage type_ent_distant, med_geometrie_element typ_geo_distant)
    00032 {
    00033   med_entite_maillage _type_ent_local   = (med_entite_maillage) ( (int)(type_ent_local) % 10 );
    00034   med_entite_maillage _type_ent_distant = (med_entite_maillage) ( (int)(type_ent_distant) % 10 );
    00035   med_idt datagroup1=0,datagroup2=0;
    00036   med_int n=0, ret=-1;
    00037
    00038   char chemin[MED_TAILLE_MAA+MED_TAILLE_JNT+2*MED_TAILLE_NOM+1];
    00039   char nomdatagroup[MED_TAILLE_NOM_ENTITE*4+3+1];
    00040   char tmp[MED_TAILLE_NOM_ENTITE+1];
    00041   med_size dimd[1];
    00042
    00043 /*   if (typ_geo_local   == MED_TETRA4 || typ_geo_local    == MED_TETRA10 || */
    00044 /*       typ_geo_local   == MED_HEXA8  || typ_geo_local    == MED_HEXA20  || */
    00045 /*       typ_geo_local   == MED_PENTA6 || typ_geo_local    == MED_PENTA15 || */
    00046 /*       typ_geo_local   == MED_PYRA5  || typ_geo_local    == MED_PYRA13  || */
    00047 /*       typ_geo_distant == MED_TETRA4 || typ_geo_distant == MED_TETRA10 || */
    00048 /*       typ_geo_distant == MED_HEXA8  || typ_geo_distant == MED_HEXA20  || */
    00049 /*       typ_geo_distant == MED_PENTA6 || typ_geo_distant == MED_PENTA15 || */
    00050 /*       typ_geo_distant == MED_PYRA5  || typ_geo_distant == MED_PYRA13) */
    00051 /*     return -1; */
    00052
    00053   /*
    00054    * On inhibe le gestionnaire d'erreur HDF 5
    00055    */
    00056   _MEDmodeErreurVerrouiller();
    00057 if (MEDcheckVersion(fid) < 0) return -1;
    00058
    00059
    00060   /*
    00061    * Si le Data Group de "JNT/Corres" n'existe pas => erreur
    00062    */
    00063   strcpy(chemin,MED_MAA);
    00064   strcat(chemin,maa);
    00065   strcat(chemin,MED_JNT);
    00066   strcat(chemin,jn);
    00067
    00068
    00069   if ((datagroup1 = _MEDdatagroupOuvrir(fid,chemin)) < 0) {
    00070     MESSAGE("Impossible d'ouvrir le datagroup  : ");
    00071     SSCRUTE(chemin);
    00072     goto ERREUR;
    00073   }
    00074
    00075   /*
    00076    * Ecriture de la correspondance
    00077    *   construction du tag HDF "reperant" la correspondance
    00078    *
    00079    */
    00080   if ( _MEDnomEntite(nomdatagroup,_type_ent_local) < 0)
    00081     goto ERREUR;
    00082   if ((_type_ent_local != MED_NOEUD)) {
    00083     if ( _MEDnomGeometrie30(tmp,typ_geo_local) < 0) goto ERREUR;
    00084     strcat(nomdatagroup,".");
    00085     strcat(nomdatagroup,tmp);
    00086   }
    00087
    00088
    00089   if ( _MEDnomEntite(tmp,_type_ent_distant) < 0)  goto ERREUR;
    00090   strcat(nomdatagroup,".");
    00091   strcat(nomdatagroup,tmp);
    00092   if ((_type_ent_distant != MED_NOEUD)) {
    00093     if ( _MEDnomGeometrie30(tmp,typ_geo_distant) < 0) goto ERREUR;
    00094     strcat(nomdatagroup,".");
    00095     strcat(nomdatagroup,tmp);
    00096   }
    00097
    00098
    00099   /* le couple d'entite n'existe pas, on renvoie 0 */
    00100
    00101   if ((datagroup2 = _MEDdatagroupOuvrir(datagroup1,nomdatagroup)) < 0 ) goto SORTIE;
    00102
    00103   /* erreur : le couple d'entite existe mais on
    00104      ne peut lire l'attribut NBR */
    00105
    00106   if ( _MEDattrEntierLire(datagroup2,MED_NOM_NBR,&n) < 0) {
    00107     MESSAGE("Impossible de lire l'attribut NBR : ");
    00108     SSCRUTE(chemin);SSCRUTE(MED_NOM_NBR); goto ERREUR;
    00109   }
    00110
    00111   /*
    00112    * On ferme tout
    00113    */
    00114
    00115  SORTIE:
    00116   ret= n;
    00117  ERREUR:
    00118
    00119   if (datagroup2 > 0 ) if ( _MEDdatagroupFermer(datagroup2) < 0) {
    00120     MESSAGE("Impossible de fermer le groupe  : ");
    00121     SSCRUTE(chemin);SSCRUTE(nomdatagroup);ret=-1;
    00122   }
    00123
    00124   if (datagroup1 > 0 ) if ( _MEDdatagroupFermer(datagroup1) < 0) {
    00125     MESSAGE("Impossible de fermer le groupe  : ");
    00126     SSCRUTE(chemin);ret= -1;
    00127   }
    00128
    00129   return (med_int) ret;
    00130
    00131 }
    00132
    00133
    00134