MEDmeshNodeCoordinateWithProfileWr.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 #include <string.h>
00023 #include <stdlib.h>
00024 
00046 med_err MEDmeshNodeCoordinateWithProfileWr(const med_idt               fid,
00047                                            const char*  const          meshname,
00048                                            const med_int               numdt,
00049                                            const med_int               numit,
00050                                            const med_float             dt,
00051                                            const med_storage_mode      storagemode,
00052                                            const char * const          profilename,
00053                                            const med_switch_mode       switchmode,
00054                                            const med_int               dimselect,
00055                                            const med_int               nentity,
00056                                            const med_float* const  coordinate)
00057 {
00058   med_err         _ret         = -1;
00059   med_idt         _meshid      = 0,_datagroup1=0,_datagroup_trsf=0;
00060   med_idt         _dataset_trsf = 0;
00061   med_int         _intmeshtype = 0;
00062   char            _meshpath   [MED_TAILLE_SUP_MAA+MED_NAME_SIZE+1]="";
00063   char            _datagroup_trsfname[MED_TAILLE_NOM_ENTITE+MED_TAILLE_COOTRF+1]=MED_NOM_NOE MED_COOTRF;
00064   med_bool        _isasupportmesh=MED_FALSE,_isasoftlink=MED_FALSE;
00065 
00066 if (_MEDcheckVersion30(fid) < 0) goto ERROR;
00067 
00068   /* Maillage de calcul ou maillage support */
00069   if ((_meshid=_MEDmeshDatagroupOpen(fid,meshname,_meshpath,&_isasupportmesh)) < 0) {
00070     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_MESH_MSG);
00071     SSCRUTE(_meshpath); goto ERROR;
00072   }
00073 
00074   /* Lecture de l'attribut du type de maillage MED_NOM_TYP  */
00075   if (_MEDattrEntierLire(_meshid,MED_NOM_TYP,&_intmeshtype) < 0) {
00076     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
00077     SSCRUTE(meshname);SSCRUTE(MED_NOM_TYP);ISCRUTE(_intmeshtype);goto ERROR;
00078   }
00079 
00080   /* Accès (création éventuelle non attendue) du datagroup numdt,numit */
00081   if ( _isasupportmesh ) {
00082     if (( numdt != MED_NO_DT) && (numit != MED_NO_IT) ) {
00083       MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_PARAMETER,MED_ERR_MESH_MSG);
00084       SSCRUTE(meshname);ISCRUTE(numdt);ISCRUTE(numit);goto ERROR;
00085     }
00086   } else
00087     if ( (_datagroup1 =_MEDmeshAssociatedGroupCr(fid, MED_MAA,
00088                                                  meshname, numdt, numit, dt, MED_FALSE,
00089                                                  "." ) ) < 0 ) {
00090       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAssociatedGroupCr");
00091       goto ERROR;
00092     }
00093 
00094    /*Réinitialisation du lien MED_TRSF_NOM/MED_COORDINATE_TRSF s'il existe */
00095   /*Si un dataset de transformation existe une erreur est générée par
00096     _MEDsoftlinkDel */
00097   if ( !_isasupportmesh)
00098     if ((_datagroup_trsf = _MEDdatagroupOuvrir(_datagroup1,_datagroup_trsfname)) > 0) {
00099 
00100       if ( _MEDisasoftlink(_datagroup_trsf, MED_NOM_TRF,MED_FALSE, &_isasoftlink ) < 0 ) {
00101         MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_LINK,MED_NOM_COO);
00102         goto ERROR;
00103       }
00104       if (_isasoftlink ) {
00105         if (  _MEDsoftlinkDel(_datagroup_trsf,
00106                               MED_NOM_TRF,
00107                               MED_TRUE) < 0 ) {
00108           MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDsoftlinkDel");
00109           goto ERROR;
00110         }
00111       } else {
00112         if ( (_dataset_trsf = _MEDdatasetOuvrir(_datagroup_trsf,MED_NOM_TRF)) >= 0 ) {
00113           _MEDdatasetFermer(_dataset_trsf);
00114           MED_ERR_(_ret,MED_ERR_NULL,MED_ERR_DATASET,MED_NOM_TRF);
00115           goto ERROR;
00116         }
00117 
00118       }
00119     }
00120 
00121   if ( ( (med_mesh_type) _intmeshtype ) == MED_UNSTRUCTURED_MESH ) {
00122 
00123     if ( _MEDmeshAdvancedWr(fid,
00124                             meshname,
00125                             MED_COORDINATE,
00126                             MED_NO_NAME,
00127                             MED_INTERNAL_UNDEF,
00128                             numdt,
00129                             numit,
00130                             dt,
00131                             MED_NODE,
00132                             MED_NONE,
00133                             MED_NO_CMODE,
00134                             storagemode,
00135                             profilename,
00136                             switchmode,
00137                             dimselect,
00138                             NULL,
00139                             nentity,
00140                             coordinate) < 0 ) {
00141       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAdvancedWr");
00142       goto ERROR;
00143     }
00144 
00145   } else {
00146     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_MESHTYPE,MED_ERR_MESH_MSG);
00147     SSCRUTE(meshname);SSCRUTE(MED_NOM_GTY);goto ERROR;
00148   }
00149 
00150 
00151   _ret = 0;
00152  ERROR:
00153 
00154   if (_datagroup_trsf>0)     if (_MEDdatagroupFermer(_datagroup_trsf) < 0) {
00155     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_datagroup_trsfname);
00156     ISCRUTE_id(_datagroup_trsf);
00157   }
00158 
00159   if (_datagroup1>0)     if (_MEDdatagroupFermer(_datagroup1) < 0) {
00160     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_meshpath);
00161     ISCRUTE_id(_datagroup1);ISCRUTE(numdt);ISCRUTE(numit);
00162   }
00163 
00164   if (_meshid>0)            if (_MEDdatagroupFermer(_meshid) < 0) {
00165     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,meshname);
00166     ISCRUTE_id(_meshid);
00167   }
00168 
00169   return _ret;
00170 }

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