# MEDmeshPolyhedronWr.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.h>
    00020 #include <med_config.h>
    00021 #include <med_outils.h>
    00022 #include <string.h>
    00023 #include <stdlib.h>
    00024
    00046 med_err
    00047 MEDmeshPolyhedronWr(const med_idt               fid,
    00048                     const char*  const          meshname,
    00049                     const med_int               numdt,
    00050                     const med_int               numit,
    00051                     const med_float             dt,
    00052                     const med_entity_type       entitype,
    00053                     const med_connectivity_mode cmode,
    00054                     const med_int               faceindexsize,
    00055                     const med_int * const       faceindex,
    00056                     const med_int               nodeindexsize,
    00057                     const med_int * const       nodeindex,
    00058                     const med_int * const       connectivity )
    00059 {
    00060   med_access_mode _MED_ACCESS_MODE;
    00061   med_idt         _meshid=0;
    00062   med_err         _ret         = -1;
    00063   med_data_type   _datatype    = MED_UNDEF_DATATYPE;
    00064   med_int         _connectivitysize = 0;
    00065   /*
    00066    * On inhibe le gestionnaire d'erreur HDF 5
    00067    */
    00068   _MEDmodeErreurVerrouiller();
    00069  if (_MEDcheckVersion30(fid) < 0) goto ERROR;
    00070
    00071   if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
    00072     MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
    00073     goto ERROR;
    00074   }
    00075
    00076   if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
    00077     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
    00078     ISCRUTE_int(_MED_ACCESS_MODE);
    00079     goto ERROR;
    00080   }
    00081
    00082
    00083   /* Tester le type d'entité ?
    00084    * MAILLE Ok
    00085    * FACE   OK
    00086    * ARETE  ?
    00087    * NOEUD  KO
    00088    * NOEUD_MAILLE  ?
    00089    */
    00090
    00091   switch(cmode)
    00092     {
    00093      case MED_NODAL :
    00094        _connectivitysize = nodeindex[nodeindexsize-1] - nodeindex[0];
    00095        break;
    00096
    00097      case MED_DESCENDING :
    00098        _connectivitysize = nodeindexsize;
    00099        break;
    00100
    00101      default :
    00102        return -1;
    00103      }
    00104
    00105   if (_MEDmeshAdvancedWr(fid,
    00106                          meshname,
    00107                          MED_CONNECTIVITY,
    00108                          MED_NO_NAME,
    00109                          MED_INTERNAL_UNDEF,
    00110                          numdt,
    00111                          numit,
    00112                          dt,
    00113                          entitype,
    00114                          MED_POLYHEDRON,
    00115                          cmode,
    00116                          MED_UNDEF_PFLMODE,
    00117                          MED_NO_PROFILE,
    00118                          MED_FULL_INTERLACE,
    00119                          MED_ALL_CONSTITUENT,
    00120                          NULL,
    00121                          _connectivitysize,
    00122                          connectivity) < 0 ) {
    00123     MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAdvancedWr (MED_CONNECTIVITY) ");
    00124     goto ERROR;
    00125   }
    00126
    00127   if (_MEDmeshAdvancedWr(fid,
    00128                          meshname,
    00129                          MED_INDEX_NODE,
    00130                          MED_NO_NAME,
    00131                          MED_INTERNAL_UNDEF,
    00132                          numdt,
    00133                          numit,
    00134                          dt,
    00135                          entitype,
    00136                          MED_POLYHEDRON,
    00137                          cmode,
    00138                          MED_UNDEF_PFLMODE,
    00139                          MED_SAME_PROFILE_INTERNAL,
    00140                          MED_FULL_INTERLACE,
    00141                          MED_ALL_CONSTITUENT,
    00142                          NULL,
    00143                          nodeindexsize,
    00144                          nodeindex) < 0 ) {
    00145     MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAdvancedWr (MED_INDEX_NODE) ");
    00146     goto ERROR;
    00147   }
    00148
    00149   if (_MEDmeshAdvancedWr(fid,
    00150                          meshname,
    00151                          MED_INDEX_FACE,
    00152                          MED_NO_NAME,
    00153                          MED_INTERNAL_UNDEF,
    00154                          numdt,
    00155                          numit,
    00156                          dt,
    00157                          entitype,
    00158                          MED_POLYHEDRON,
    00159                          cmode,
    00160                          MED_UNDEF_PFLMODE,
    00161                          MED_SAME_PROFILE_INTERNAL,
    00162                          MED_FULL_INTERLACE,
    00163                          MED_ALL_CONSTITUENT,
    00164                          NULL,
    00165                          faceindexsize,
    00166                          faceindex) < 0 ) {
    00167     MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAdvancedWr (MED_INDEX_FACE) ");
    00168     goto ERROR;
    00169   }
    00170
    00171   _ret = 0;
    00172
    00173  ERROR:
    00174
    00175   return _ret;
    00176
    00177 }