Changeset 13368
- Timestamp:
- 09/13/12 15:22:52 (13 years ago)
- Location:
- issm/trunk-jpl/src/c/python/io
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/python/io/FetchPythonData.cpp
r13353 r13368 16 16 #include "../../shared/shared.h" 17 17 #include "../../io/io.h" 18 void FetchData(char** pstring,PyObject* py_string); 18 19 19 20 /*Primitive data types*/ … … 235 236 } 236 237 /*}}}*/ 237 /*FUNCTION FetchData(DataSet** pcontours,PyObject* py_dict){{{*/ 238 void FetchData(DataSet** pcontours,PyObject* py_dict){ 239 240 _error_("not supported yet"); 238 /*FUNCTION FetchData(DataSet** pcontours,PyObject* py_list){{{*/ 239 void FetchData(DataSet** pcontours,PyObject* py_list){ 240 241 int numcontours,test1,test2; 242 char *contourname = NULL; 243 DataSet *contours = NULL; 244 Contour<double> *contouri = NULL; 245 PyObject *py_dicti = NULL; 246 PyObject *py_item = NULL; 247 248 if (PyString_Check(py_list)){ 249 FetchData(&contourname,py_list); 250 contours=DomainOutlineRead<double>(contourname); 251 } 252 else if(PyList_Check(py_list)){ 253 254 contours=new DataSet(0); 255 numcontours=(int)PyList_Size(py_list); 256 257 for(int i=0;i<numcontours;i++){ 258 259 contouri=xNew<Contour<double> >(1); 260 py_dicti=PyList_GetItem(py_list,(Py_ssize_t)i); 261 262 py_item = PyDict_GetItemString(py_dicti,"nods"); 263 if(!py_item) _error_("input structure does not have a 'nods' field"); 264 FetchData(&contouri->nods,py_item); 265 266 py_item = PyDict_GetItemString(py_dicti,"x"); 267 if(!py_item) _error_("input structure does not have a 'x' field"); 268 FetchData(&contouri->x,&test1,&test2,py_item); 269 if(test1!=contouri->nods || test2!=1) _error_("field x should be of size ["<<contouri->nods<<" 1]"); 270 271 py_item = PyDict_GetItemString(py_dicti,"y"); 272 if(!py_item) _error_("input structure does not have a 'y' field"); 273 FetchData(&contouri->y,&test1,&test2,py_item); 274 if(test1!=contouri->nods || test2!=1) _error_("field y should be of size ["<<contouri->nods<<" 1]"); 275 276 contours->AddObject(contouri); 277 } 278 } 279 else{ 280 _error_("Contour is neither a string nor a structure and cannot be loaded"); 281 } 282 283 /*clean-up and assign output pointer*/ 284 *pcontours=contours; 241 285 } 242 286 /*}}}*/ -
issm/trunk-jpl/src/c/python/io/pythonio.h
r13353 r13368 35 35 void FetchData(BamgOpts** bamgopts,PyObject* py_dict); 36 36 void FetchData(Options** poptions,int istart, int nrhs,PyObject* arguments); 37 void FetchData(DataSet** pcontours,PyObject* py_ dict);37 void FetchData(DataSet** pcontours,PyObject* py_list); 38 38 39 39 int CheckNumPythonArguments(PyObject* inputs,int NRHS, void (*function)( void ));
Note:
See TracChangeset
for help on using the changeset viewer.