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
00042 med_err MEDmeshNodeCoordinateAdvancedWr(const med_idt fid,
00043 const char* const meshname,
00044 const med_int numdt,
00045 const med_int numit,
00046 const med_float dt,
00047 const med_filter * const filter,
00048 const med_float* const coordinate)
00049 {
00050 med_err _ret = -1;
00051 med_idt _meshid = 0,_datagroup1=0,_datagroup_trsf=0;
00052 med_idt _dataset_trsf = 0;
00053 med_int _intmeshtype = 0;
00054 char _meshpath [MED_TAILLE_SUP_MAA+MED_NAME_SIZE+1]="";
00055 char _datagroup_trsfname[MED_TAILLE_NOM_ENTITE+MED_TAILLE_COOTRF+1]=MED_NOM_NOE MED_COOTRF;
00056 med_bool _isasupportmesh=MED_FALSE,_isasoftlink=MED_FALSE;
00057
00058 if (_MEDcheckVersion30(fid) < 0) goto ERROR;
00059
00060
00061 if ((_meshid=_MEDmeshDatagroupOpen(fid,meshname,_meshpath,&_isasupportmesh)) < 0) {
00062 MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_MESH_MSG);
00063 SSCRUTE(_meshpath); goto ERROR;
00064 }
00065
00066
00067 if (_MEDattrEntierLire(_meshid,MED_NOM_TYP,&_intmeshtype) < 0) {
00068 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
00069 SSCRUTE(meshname);SSCRUTE(MED_NOM_TYP);ISCRUTE(_intmeshtype);goto ERROR;
00070 }
00071
00072 if ( _isasupportmesh ) {
00073 if (( numdt != MED_NO_DT) && (numit != MED_NO_IT) ) {
00074 MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_PARAMETER,MED_ERR_MESH_MSG);
00075 SSCRUTE(meshname);ISCRUTE(numdt);ISCRUTE(numit);goto ERROR;
00076 }
00077 } else
00078 if ( (_datagroup1 =_MEDmeshAssociatedGroupCr(fid, MED_MAA,
00079 meshname, numdt, numit, dt, MED_FALSE,
00080 "." ) ) < 0 ) {
00081 MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAssociatedGroupCr");
00082 goto ERROR;
00083 }
00084
00085
00086
00087
00088
00089
00090
00091
00092 if ( !_isasupportmesh)
00093 if ((_datagroup_trsf = _MEDdatagroupOuvrir(_datagroup1,_datagroup_trsfname)) > 0) {
00094
00095 if ( _MEDisasoftlink(_datagroup_trsf, MED_NOM_TRF,MED_FALSE, &_isasoftlink ) < 0 ) {
00096 MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_LINK,MED_NOM_COO);
00097 goto ERROR;
00098 }
00099 if (_isasoftlink ) {
00100 if ( _MEDsoftlinkDel(_datagroup_trsf,
00101 MED_NOM_TRF,
00102 MED_TRUE) < 0 ) {
00103 MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDsoftlinkDel");
00104 goto ERROR;
00105 }
00106 } else {
00107 if ( (_dataset_trsf = _MEDdatasetOuvrir(_datagroup_trsf,MED_NOM_TRF)) >= 0 ) {
00108 _MEDdatasetFermer(_dataset_trsf);
00109 MED_ERR_(_ret,MED_ERR_NULL,MED_ERR_DATASET,MED_NOM_TRF);
00110 goto ERROR;
00111 }
00112
00113 }
00114 }
00115
00116
00117 if ( ( (med_mesh_type) _intmeshtype ) == MED_UNSTRUCTURED_MESH ) {
00118
00119
00120 if ( _MEDmeshAdvancedWr(fid,
00121 meshname,
00122 MED_COORDINATE,
00123 MED_NO_NAME,
00124 MED_INTERNAL_UNDEF,
00125 numdt,
00126 numit,
00127 dt,
00128 MED_NODE,
00129 MED_NONE,
00130 MED_NO_CMODE,
00131 MED_UNDEF_PFLMODE,
00132 MED_NO_PROFILE,
00133 MED_UNDEF_INTERLACE,
00134 MED_ALL_CONSTITUENT,
00135 filter,
00136 MED_UNDEF_SIZE,
00137 coordinate) <0 ) {
00138 MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAdvancedWr");
00139 goto ERROR;
00140 }
00141
00142 } else {
00143 MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_MESHTYPE,MED_ERR_MESH_MSG);
00144 SSCRUTE(meshname);SSCRUTE(MED_NOM_GTY);goto ERROR;
00145 }
00146
00147 _ret = 0;
00148 ERROR:
00149
00150 if (_datagroup_trsf>0) if (_MEDdatagroupFermer(_datagroup_trsf) < 0) {
00151 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_datagroup_trsfname);
00152 ISCRUTE_id(_datagroup_trsf);
00153 }
00154
00155 if (_datagroup1>0) if (_MEDdatagroupFermer(_datagroup1) < 0) {
00156 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_meshpath);
00157 ISCRUTE_id(_datagroup1);ISCRUTE(numdt);ISCRUTE(numit);
00158 }
00159
00160 if (_meshid>0) if (_MEDdatagroupFermer(_meshid) < 0) {
00161 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,meshname);
00162 ISCRUTE_id(_meshid);
00163 }
00164
00165 return _ret;
00166
00167 }