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
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
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
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
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
00095
00096
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 }