Changeset 4900


Ignore:
Timestamp:
Dec 31, 2007, 9:37:12 AM (17 years ago)
Author:
duncan
Message:

removing list output from mesh_engine/mesh_engine_c_layer.c

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  
    130130    #XSprint "mode", mode
    131131    #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,
    133133                          pointatts,segatts, mode, segments.flat)
     134    mesh_dict = {}
    134135    # the values as arrays
    135136    mesh_dict['generatedtrianglelist'] = trianglelist
  • anuga_core/source/anuga/mesh_engine/mesh_engine_c_layer.c

    r4898 r4900  
    115115     
    116116  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   
    123118  if(!PyArg_ParseTuple(args,(char *)"OOOOOOOO",&pointlist,&seglist,&holelist,&regionlist,&pointattributelist,&segmarkerlist,&mode,&test)){
    124119    return NULL;
     
    234229    we send back a dictionary:                                               
    235230    { index : [ coordinates, [connections], Attribute ] }
    236   */
    237   holder = PyDict_New();   
     231  */ 
    238232 
    239233  /*
     
    260254  gentrianglelist -> data = out.trianglelist;
    261255   
    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  
    275256  /* Add pointlist */
    276257  dimensions[0] = out.numberofpoints;
     
    285266 
    286267  */
    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;
    300269 
    301270  /* Add point marker list */
     
    306275  genpointmarkerlist -> data = out.pointmarkerlist;
    307276 
    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    
    320277  /* Add point attribute list */
    321278  dimensions[0] = out.numberofpoints;
     
    327284 
    328285 
    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); 
    345286 
    346287  /* Add triangle attribute list */
     
    352293  gentriangleattributelist -> data = out.triangleattributelist;
    353294 
    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  
    370295  /* Add segment list */
    371296  dimensions[0] = out.numberofsegments;
     
    377302 
    378303 
    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  
    391304  /* Add segment marker list */
    392305  dimensions[0] = out.numberofsegments;
     
    395308                                                    PyArray_INT);
    396309  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); 
    410310 
    411311  /* Add triangle neighbor list */
     
    419319 
    420320  /* Add triangle neighbor list */
    421   if (out.neighborlist != NULL) {
     321  /*if (out.neighborlist != NULL) {
    422322    listsize = out.numberoftriangles;
    423323    holderlist = PyList_New(listsize);
     
    433333    Py_DECREF(ii); Py_DECREF(holderlist);
    434334  }   
    435  
     335   */
    436336 
    437337 
     
    481381 
    482382  /* R = Py_BuildValue((char *)"O", holder); */
    483   R = Py_BuildValue((char *)"OOOOOOOOO", holder
     383  R = Py_BuildValue((char *)"OOOOOOOO"
    484384                    ,PyArray_Return(gentrianglelist)
    485385                    ,PyArray_Return(genpointlist)
     
    491391                    ,PyArray_Return(genneighborlist)
    492392                    );
    493   Py_DECREF(holder); /** This fixed a  memory problem ticket#189 */
     393   /*Py_DECREF(holder);* This fixed a  memory problem ticket#189 */
    494394  Py_DECREF(gentrianglelist);
    495395  Py_DECREF(genpointlist);
Note: See TracChangeset for help on using the changeset viewer.