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