MEDmeshNodeCoordinateTrsfRd.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 
00040 med_err MEDmeshNodeCoordinateTrsfRd(const med_idt               fid,
00041                                     const char*  const          meshname,
00042                                     const med_int               numdt,
00043                                     const med_int               numit,
00044                                     const med_float* const      coordinatetrsf)
00045 {
00046   med_err         _ret         = -1;
00047   med_idt         _meshid      = 0,_datagroup1=0,_dataset_coo=0;
00048   med_int         _intmeshtype = 0;
00049   char            _meshpath   [MED_TAILLE_SUP_MAA+MED_NAME_SIZE+1]="";
00050   char            _dataset_cooname[MED_TAILLE_NOM_ENTITE+1+3+1]=MED_NOM_NOE"/"MED_NOM_COO;
00051   med_bool        _isasupportmesh=MED_FALSE,_isasoftlink=MED_FALSE;
00052 
00053   /* Il ne peut pas y  avoir de transformation géométrique à MED_NO_DT, MED_NO_IT */
00054   if ( (numdt == MED_NO_DT) && (numit == MED_NO_IT) ) {
00055     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_PARAMETER,MED_ERR_MESH_MSG);
00056     SSCRUTE(_meshpath); ISCRUTE(numdt);ISCRUTE(numit);goto ERROR;
00057   }
00058 
00059   /* Maillage de calcul ou maillage support */
00060   if ((_meshid=_MEDmeshDatagroupOpen(fid,meshname,_meshpath,&_isasupportmesh)) < 0) {
00061     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_MESH_MSG);
00062     SSCRUTE(_meshpath); goto ERROR;
00063   }
00064 
00065   /* Lecture de l'attribut du type de maillage MED_NOM_TYP  */
00066   if (_MEDattrEntierLire(_meshid,MED_NOM_TYP,&_intmeshtype) < 0) {
00067     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
00068     SSCRUTE(meshname);SSCRUTE(MED_NOM_TYP);ISCRUTE(_intmeshtype);goto ERROR;
00069   }
00070 
00071   /* Accès (création éventuelle non attendue) du datagroup numdt,numit */
00072   if ( _isasupportmesh ) {
00073       MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_PARAMETER,"");
00074       SSCRUTE(meshname);goto ERROR;
00075   } else
00076     if ( (_datagroup1 =_MEDmeshAssociatedGroupCr(fid, MED_MAA,
00077                                                  meshname, numdt, numit, MED_UNDEF_DT, MED_TRUE,
00078                                                  "." ) ) < 0 ) {
00079       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAssociatedGroupCr");
00080       goto ERROR;
00081     }
00082 
00083   /* Erreur si un un dataset  MED_NODE/MED_COORDINATE existe */
00084   if ( _MEDisasoftlink(_datagroup1, _dataset_cooname,MED_TRUE, &_isasoftlink ) < 0) {
00085     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_LINK,MED_NOM_COO);
00086     goto ERROR;
00087   }
00088 
00089   if (!_isasoftlink) {
00090     MED_ERR_(_ret,MED_ERR_NULL,MED_ERR_DATASET,MED_NOM_COO);
00091     goto ERROR;
00092   }
00093 
00094   if ( ( (med_mesh_type) _intmeshtype ) == MED_UNSTRUCTURED_MESH ) {
00095 
00096     if (  _MEDmeshAdvancedRd(fid,
00097                              meshname,
00098                              MED_COORDINATE_TRSF,
00099                              MED_NO_NAME,
00100                              MED_INTERNAL_UNDEF,
00101                              numdt,
00102                              numit,
00103                              MED_NODE,
00104                              MED_NONE,
00105                              MED_NO_CMODE,
00106                              MED_UNDEF_PFLMODE,
00107                              MED_NO_PROFILE,
00108                              MED_NO_INTERLACE,
00109                              MED_ALL_CONSTITUENT,
00110                              NULL,
00111                              (unsigned char * ) coordinatetrsf) < 0 ) {
00112       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAdvancedRd");
00113       goto ERROR;
00114 
00115     }
00116 
00117   } else {
00118     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_MESHTYPE,MED_ERR_MESH_MSG);
00119     SSCRUTE(meshname);SSCRUTE(MED_NOM_GTY);goto ERROR;
00120   }
00121 
00122   _ret = 0;
00123 
00124  ERROR:
00125   if (_dataset_coo>0)     if (_MEDdatagroupFermer(_dataset_coo) < 0) {
00126     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_dataset_cooname);
00127     ISCRUTE_id(_dataset_coo);
00128   }
00129 
00130   if (_datagroup1>0)     if (_MEDdatagroupFermer(_datagroup1) < 0) {
00131     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_meshpath);
00132     ISCRUTE_id(_datagroup1);ISCRUTE(numdt);ISCRUTE(numit);
00133   }
00134 
00135   if (_meshid>0)            if (_MEDdatagroupFermer(_meshid) < 0) {
00136     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,meshname);
00137     ISCRUTE_id(_meshid);
00138   }
00139 
00140   return _ret;
00141 }

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