Changeset 4900
- Timestamp:
- Dec 31, 2007, 9:37:12 AM (17 years ago)
- Location:
- anuga_core/source/anuga/mesh_engine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/mesh_engine/mesh_engine.py
r4899 r4900 130 130 #XSprint "mode", mode 131 131 #print "yeah" 132 mesh_dict,trianglelist, pointlist, pointmarkerlist, pointattributelist, triangleattributelist, segmentlist, segmentmarkerlist, neighborlist = triang.genMesh(points,segments,holes,regions,132 trianglelist, pointlist, pointmarkerlist, pointattributelist, triangleattributelist, segmentlist, segmentmarkerlist, neighborlist = triang.genMesh(points,segments,holes,regions, 133 133 pointatts,segatts, mode, segments.flat) 134 mesh_dict = {} 134 135 # the values as arrays 135 136 mesh_dict['generatedtrianglelist'] = trianglelist -
anuga_core/source/anuga/mesh_engine/mesh_engine_c_layer.c
r4898 r4900 115 115 116 116 char *mod; 117 PyObject *holder, *holderlist, *attributelist; 118 int listsize,attsize ; 119 PyObject *ii; 120 121 /* used for testing numeric arrays*/ 122 int n_test; 117 123 118 if(!PyArg_ParseTuple(args,(char *)"OOOOOOOO",&pointlist,&seglist,&holelist,®ionlist,&pointattributelist,&segmarkerlist,&mode,&test)){ 124 119 return NULL; … … 234 229 we send back a dictionary: 235 230 { index : [ coordinates, [connections], Attribute ] } 236 */ 237 holder = PyDict_New(); 231 */ 238 232 239 233 /* … … 260 254 gentrianglelist -> data = out.trianglelist; 261 255 262 /* Add triangle list */263 listsize = out.numberoftriangles;264 /* printf(" out.numberoftriangles %i\n", out.numberoftriangles ); */265 holderlist = PyList_New(listsize);266 for(i=0; i<listsize;i++){267 PyObject *mlist = Py_BuildValue((char *)"(i,i,i)",268 out.trianglelist[i*3 ], out.trianglelist [i*3+1], out.trianglelist [i*3+2]);269 PyList_SetItem(holderlist,i, mlist);270 }271 ii=PyString_FromString("generatedtrianglelist");272 PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);273 274 275 256 /* Add pointlist */ 276 257 dimensions[0] = out.numberofpoints; … … 285 266 286 267 */ 287 genpointlist -> data = out.pointlist; 288 289 /* Add pointlist */ 290 listsize = out.numberofpoints; 291 holderlist = PyList_New(listsize); 292 293 for(i=0; i<out.numberofpoints;i++){ 294 PyObject *mlist = Py_BuildValue((char *)"(d,d)", 295 out.pointlist[i*2 ], out.pointlist[i*2+1]); 296 PyList_SetItem(holderlist,i, mlist); 297 } 298 ii=PyString_FromString("generatedpointlist"); 299 PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist); 268 genpointlist -> data = out.pointlist; 300 269 301 270 /* Add point marker list */ … … 306 275 genpointmarkerlist -> data = out.pointmarkerlist; 307 276 308 /* Add point marker list */309 listsize = out.numberofpoints;310 holderlist = PyList_New(listsize);311 312 for(i=0; i<listsize;i++){313 PyObject *mlist = Py_BuildValue((char *)"i",314 out.pointmarkerlist[i]);315 PyList_SetItem(holderlist,i, mlist);316 }317 ii=PyString_FromString("generatedpointmarkerlist");318 PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);319 320 277 /* Add point attribute list */ 321 278 dimensions[0] = out.numberofpoints; … … 327 284 328 285 329 /* Add point attribute list */330 listsize = out.numberofpoints;331 holderlist = PyList_New(listsize);332 333 for(i=0; i<listsize;i++){334 attsize = out.numberofpointattributes;335 attributelist = PyList_New(attsize);336 for(iatt=0; iatt<attsize;iatt++){337 PyObject *mlist = Py_BuildValue((char *)"d",338 out.pointattributelist[i*attsize + iatt]);339 PyList_SetItem(attributelist,iatt, mlist);340 }341 PyList_SetItem(holderlist,i, attributelist);342 }343 ii=PyString_FromString("generatedpointattributelist");344 PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);345 286 346 287 /* Add triangle attribute list */ … … 352 293 gentriangleattributelist -> data = out.triangleattributelist; 353 294 354 /* Add triangle attribute list */355 listsize = out.numberoftriangles;356 holderlist = PyList_New(listsize);357 358 for(i=0; i<listsize; i++){359 attsize = out.numberoftriangleattributes;360 attributelist = PyList_New(attsize);361 for(iatt=0; iatt<attsize;iatt++){362 PyObject *mlist = Py_BuildValue((char *)"d",out.triangleattributelist[i*attsize + iatt]);363 PyList_SetItem(attributelist,iatt, mlist);364 }365 PyList_SetItem(holderlist,i, attributelist);366 }367 ii=PyString_FromString("generatedtriangleattributelist");368 PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);369 370 295 /* Add segment list */ 371 296 dimensions[0] = out.numberofsegments; … … 377 302 378 303 379 /* Add segment list */380 listsize = out.numberofsegments;381 holderlist = PyList_New(listsize);382 for(i=0; i<listsize;i++){383 PyObject *mlist = Py_BuildValue((char *)"(i,i)",384 out.segmentlist[i*2 ],385 out.segmentlist [i*2+1]);386 PyList_SetItem(holderlist,i, mlist);387 }388 ii=PyString_FromString("generatedsegmentlist");389 PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);390 391 304 /* Add segment marker list */ 392 305 dimensions[0] = out.numberofsegments; … … 395 308 PyArray_INT); 396 309 gensegmentmarkerlist -> data = out.segmentmarkerlist; 397 398 399 /* Add segment marker list */400 listsize = out.numberofsegments;401 holderlist = PyList_New(listsize);402 for(i=0; i<listsize;i++){403 PyObject *mlist = Py_BuildValue((char *)"i",404 out.segmentmarkerlist[i]);405 PyList_SetItem(holderlist,i, mlist);406 }407 ii=PyString_FromString("generatedsegmentmarkerlist");408 PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii);409 Py_DECREF(holderlist);410 310 411 311 /* Add triangle neighbor list */ … … 419 319 420 320 /* Add triangle neighbor list */ 421 if (out.neighborlist != NULL) {321 /*if (out.neighborlist != NULL) { 422 322 listsize = out.numberoftriangles; 423 323 holderlist = PyList_New(listsize); … … 433 333 Py_DECREF(ii); Py_DECREF(holderlist); 434 334 } 435 335 */ 436 336 437 337 … … 481 381 482 382 /* R = Py_BuildValue((char *)"O", holder); */ 483 R = Py_BuildValue((char *)"OOOOOOOO O", holder383 R = Py_BuildValue((char *)"OOOOOOOO" 484 384 ,PyArray_Return(gentrianglelist) 485 385 ,PyArray_Return(genpointlist) … … 491 391 ,PyArray_Return(genneighborlist) 492 392 ); 493 Py_DECREF(holder); /** This fixed a memory problem ticket#189 */393 /*Py_DECREF(holder);* This fixed a memory problem ticket#189 */ 494 394 Py_DECREF(gentrianglelist); 495 395 Py_DECREF(genpointlist);
Note: See TracChangeset
for help on using the changeset viewer.