00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
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   
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   
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   
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   
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   
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 }