Index: inundation/triangle/compile.py
===================================================================
--- inundation/triangle/compile.py	(revision 2141)
+++ inundation/triangle/compile.py	(revision 2142)
@@ -14,15 +14,219 @@
 def compile(FNs=None, CC=None, LD = None, SFLAG = None, verbose = 1):
   """compile(FNs=None, CC=None, LD = None, SFLAG = None):
-  The input parrameters aren't used.
-  I'm keeping the same interface as the standard compile
+  
+     Compile FN(s) using compiler CC (e.g. mpicc), 
+     Loader LD and shared flag SFLAG.
+     If CC is absent use default compiler dependent on platform
+     if LD is absent CC is used.
+     if SFLAG is absent platform default is used
+     FNs can be either one filename or a list of filenames
+     In the latter case, the first will be used to name so file.
   """
   
-  
-  ###########################
-  ####### HIJACKING COMPILE #
-  ###########################
-  print "Compiling using setup.py"
-  import triangle.run_setup
-
+  import os, string, sys, types
+  
+  # Input check
+  #
+  assert not FNs is None, "No filename provided"
+
+  if not type(FNs) == types.ListType:
+    FNs = [FNs]
+
+
+  libext = 'so' #Default extension (Unix)
+  libs = ''
+  version = sys.version[:3]
+  
+  # Determine platform and compiler
+  #
+  if sys.platform == 'sunos5':  #Solaris
+    if CC:
+      compiler = CC
+    else:  
+      compiler = 'gcc'
+    if LD:
+      loader = LD
+    else:  
+      loader = compiler
+    if SFLAG:
+      sharedflag = SFLAG
+    else:  
+      sharedflag = 'G'
+      
+  elif sys.platform == 'osf1V5':  #Compaq AlphaServer
+    if CC:
+      compiler = CC
+    else:  
+      compiler = 'cc'
+    if LD:
+      loader = LD
+    else:  
+      loader = compiler
+    if SFLAG:
+      sharedflag = SFLAG
+    else:  
+      sharedflag = 'shared'    
+      
+  elif sys.platform == 'linux2':  #Linux
+    if CC:
+      compiler = CC
+    else:  
+      compiler = 'gcc'
+    if LD:
+      loader = LD
+    else:  
+      loader = compiler
+    if SFLAG:
+      sharedflag = SFLAG
+    else:  
+      sharedflag = 'shared'    
+      
+  elif sys.platform == 'darwin':  #Mac OS X:
+    if CC:
+      compiler = CC
+    else:  
+      compiler = 'cc'
+    if LD:
+      loader = LD
+    else:  
+      loader = compiler
+    if SFLAG:
+      sharedflag = SFLAG
+    else:  
+      sharedflag = 'bundle -flat_namespace -undefined suppress'
+
+  elif sys.platform == 'cygwin':  #Cygwin (compilation same as linux)
+    if CC:
+      compiler = CC
+    else:  
+      compiler = 'gcc'
+    if LD:
+      loader = LD
+    else:  
+      loader = compiler
+    if SFLAG:
+      sharedflag = SFLAG
+    else:  
+      sharedflag = 'shared'
+    libext = 'dll'
+    libs = '/lib/python%s/config/libpython%s.dll.a' %(version,version)
+      
+  elif sys.platform == 'win32':  #Windows
+    if CC:
+      compiler = CC
+    else:  
+      compiler = 'gcc'
+    if LD:
+      loader = LD
+    else:  
+      loader = compiler
+    if SFLAG:
+      sharedflag = SFLAG
+    else:  
+      sharedflag = 'shared'
+    libext = 'dll'
+
+    v = version.replace('.','')
+    dllfilename = 'python%s.dll' %(v)
+    libs = os.path.join(sys.exec_prefix,dllfilename)
+      
+      
+  else:
+    if verbose: print "Unrecognised platform %s - revert to default"\
+                %sys.platform
+    
+    if CC:
+      compiler = CC
+    else:  
+      compiler = 'cc'
+    if LD:
+      loader = LD
+    else:  
+      loader = 'ld'
+    if SFLAG:
+      sharedflag = SFLAG
+    else:  
+      sharedflag = 'G'
+
+            
+  # Find location of include files
+  #
+  if sys.platform == 'win32':  #Windows
+    include = os.path.join(sys.exec_prefix, 'include')    
+  else:  
+    include = os.path.join(os.path.join(sys.exec_prefix, 'include'),
+                           'python'+version)
+
+  # Check existence of Python.h
+  #
+  headerfile = include + os.sep +'Python.h'
+  try:
+    open(headerfile, 'r')
+  except:
+    raise """Did not find Python header file %s.
+    Make sure files for Python C-extensions are installed. 
+    In debian linux, for example, you need to install a
+    package called something like python2.3-dev""" %headerfile
+  
+  
+  # Check filename(s)
+  #
+  object_files = ''
+  for FN in FNs:        
+    root, ext = os.path.splitext(FN)
+    if ext == '':
+      FN = FN + '.c'
+    elif ext.lower() != '.c':
+      raise Exception, "Unrecognised extension: " + FN
+    
+    try:
+      open(FN,'r')
+    except:    
+      raise Exception, "Could not open: " + FN
+
+    if not object_files: root1 = root  #Remember first filename        
+    object_files += root + '.o '  
+  
+  
+    # Compile
+    #
+    s = "%s -c %s -I%s -o %s.o -Wall -O3  -DTRILIBRARY=1 -DNO_TIMER=1" %(compiler, FN, include, root)
+
+    if os.name == 'posix' and os.uname()[4] == 'x86_64':
+      #Extra flags for 64 bit architectures
+
+      #FIXME: Which one?
+      #s += ' -fPIC'
+      s += ' -fPIC -m64' 
+      
+      
+    if verbose:
+      print s
+    else:
+      s = s + ' 2> /dev/null' #Suppress errors
+  
+    try:
+      err = os.system(s)
+      if err != 0:
+          raise 'Attempting to compile %s failed - please try manually' %FN 
+    except:
+      raise 'Could not compile %s - please try manually' %FN  
+
+  
+  # Make shared library (*.so or *.dll)
+  
+  s = "%s -%s %s -o %s.%s %s -lm" %(loader, sharedflag, object_files, root1, libext, libs)
+  if verbose:
+    print s
+  else:
+    s = s + ' 2> /dev/null' #Suppress warnings
+  
+  try:  
+    err=os.system(s)
+    if err != 0:	
+	raise 'Atempting to link %s failed - please try manually' %root1     
+  except:
+    raise 'Could not link %s - please try manually' %root1
+    
 
 def can_use_C_extension(filename):
@@ -30,6 +234,93 @@
     can and should be used.
     """
-    pass
+
+    from config import use_extensions
+
+    from os.path import splitext
+
+    root, ext = splitext(filename)
+    
+    C=False
+    if use_extensions:
+        try:
+            s = 'import %s' %root
+            #print s
+            exec(s)
+        except:
+            try:
+                open(filename)
+            except:
+                msg = 'C extension %s cannot be opened' %filename
+                print msg                
+            else:    
+                print '------- Trying to compile c-extension %s' %filename
+	    
+                try:
+                    compile(filename)
+                except:
+                    print 'WARNING: Could not compile C-extension %s'\
+                          %filename
+                else:
+                    try:
+                        exec('import %s' %root)
+                    except:
+                        msg = 'C extension %s seems to compile OK, '
+                        msg += 'but it can still not be imported.'
+                        raise msg
+                    else:
+                        C=True
+        else:
+            C=True
+            
+    if not C:
+        pass
+        print 'NOTICE: C-extension %s not used' %filename
+
+    return C
+
 
 if __name__ == '__main__':
-  compile()
+
+
+  import sys, os
+  from os.path import splitext
+  
+  if len(sys.argv) > 1:
+      files = sys.argv[1:]
+      for filename in files:
+          root, ext = splitext(filename)
+
+          if ext <> '.c':
+	      print 'WARNING (compile.py): Skipping %s. I only compile C-files.' %filename
+      
+  else:  
+      #path = os.path.split(sys.argv[0])[0] or os.getcwd()
+      path = '.'
+      files = os.listdir(path)
+      
+      
+
+  for filename in files:
+      root, ext = splitext(filename)
+
+      if ext == '.c':
+          for x in ['.dll', '.so']:
+              try:
+                  os.remove(root + x)
+              except:
+                  pass
+
+          print '--------------- Trying to compile c-extension %s' %filename
+          try:
+            if filename == 'triang.c':
+              print "********** Manually doing dependancies **************"
+              compile(['triang.c','triangle.c'])
+            else:
+              compile(filename)
+          except:
+              print 'Could not compile C extension %s' %filename            
+          else:
+              print 'C extension %s OK' %filename
+          print    
+        
+
Index: inundation/triangle/run_setup.py
===================================================================
--- inundation/triangle/run_setup.py	(revision 2141)
+++ 	(revision )
@@ -1,42 +1,0 @@
-import os
-import string
-import sys
-import shutil
-
-
-# Work out the directory the pyd will go.
-_s = string.split( sys.version )[0]
-#print "_s",_s
-version_info = tuple( map(int, string.split(_s, '.') ) )
-del _s
-#print "version_info", version_info
-#print "sys.executable",sys.executable 
-pyd_in_dir = 'build/lib.%s-%s.%s/'  %(sys.platform,version_info[0],version_info[1])
-
-# See if the pyd has already been compiled.
-try:
-    _ = os.listdir(pyd_in_dir)
-except WindowsError:
-    # The build hasn't got the files we want
-    print "Removing the current build directory"
-    try:
-        shutil.rmtree('build')
-    except:
-        pass
-    
-
-if sys.platform == 'win32':  #Windows
-    win32_extra = '-cmingw32'
-
-command = '%s setup.py build %s' %(sys.executable,win32_extra) 
-os.system(command)
-    
-
-# 
-
-#print "file_in_dir", file_in_dir 
-for file in os.listdir(pyd_in_dir):
-    if os.path.splitext(file)[1] == ".pyd":
-        shutil.copy(os.path.join(pyd_in_dir,file), '.')
-
-
Index: inundation/triangle/setup.py
===================================================================
--- inundation/triangle/setup.py	(revision 2141)
+++ 	(revision )
@@ -1,17 +1,0 @@
-#!/usr/bin/env python
-
-from distutils.core import setup, Extension
-
-setup (name = "pMesh",
-       version = "1.XX",
-       author="Duncan Gray",
-       author_email="duncan.gray@ga.gov.au",
-       ext_modules = [
-                      Extension("triang",["triangle.c",
-                                          "triangmodule.c"],
-                                define_macros=[("TRILIBRARY",1),
-                                               ("NO_TIMER",1)]
-                                )           
-                      
-                      ]
-       )
Index: inundation/triangle/triang.c
===================================================================
--- inundation/triangle/triang.c	(revision 2142)
+++ inundation/triangle/triang.c	(revision 2142)
@@ -0,0 +1,573 @@
+/* this appears to be necessary to run on Linux */
+
+#undef _STDLIB_H_
+#define _STDLIB_H_
+
+
+/*
+    This code is based on code by A. Pletzer
+
+    This code interfaces pmesh directly with "triangle", a general        
+    purpose triangulation code. In doing so, Python data structures          
+    are passed to C for  use by "triangle" and the results are then          
+    converted back. This was accomplished using the Python/C API.            
+                                                                           
+    I. Lists of points,edges,holes, and regions must normally be 
+     created for proper triangulation. However, if there are no holes,
+     the  hole list need not be specified (however, a 
+     measure of control over the shape of the convex hull is lost; 
+     triangle decides). 
+     
+     points list: [(x1,y1),(x2,y2),...] (Tuples of doubles)                  
+     edge list: [(Ea,Eb),(Ef,Eg),...] (Tuples of integers)                   
+     hole list: [(x1,y1),...](Tuples of doubles, one inside each hole region)
+     regionlist: [ (x1,y1,index,area),...] (Tuple of doubles)                
+     pointattributelist:[ (a1,a2..),...] (Tuple of lists) 
+     mode: String - the commands sent to triangle
+          
+     This is all that is needed to accomplish an intial triangulation.       
+     A dictionary of the Triangle output is returned.                                   
+     Precondition
+     End list in the pointattributelist has to have the same length
+     
+    Compilation can be done as follows                                       
+                    
+    c++ -I/usr/local/include/python1.5 -shared -o triangmodule.so            
+    triangmodule.c triangle.o                                                */
+
+
+#ifdef SINGLE  
+#define REAL float 
+#else  
+#define REAL double 
+#endif  
+
+#include "triangle.h" 
+
+#ifndef _STDLIB_H_ 
+#ifndef _WIN32
+extern "C" void *malloc(); 
+extern "C" void free(); 
+#endif
+#endif  
+
+#include "Python.h" 
+
+
+ static PyObject *triang_genMesh(PyObject *self, PyObject *args){
+     
+  /* Mesh generation routine
+     pre-conditions:
+     mode must have a 'z' switch, to avoid segmentation faults
+  */
+    
+  struct triangulateio in,out;
+
+  PyObject *hull;
+  PyObject *seglist;
+  PyObject *holelist;
+  PyObject *regionlist;
+  PyObject *trianglelist;
+  PyObject *mode;
+  PyObject *firstPointAttr;
+  PyObject *pointattributelist;
+  PyObject *segmarkerlist;
+  PyObject *Attrlist;
+  REAL Attr;
+  int i, j, iatt, n;
+  int a,b,c;
+  int marker;
+  int tuplesize;
+    
+  int index = 0;
+  double x,y;
+  PyObject *elems;
+  PyObject *pair;
+     
+  char *mod;
+  PyObject *holder, *holderlist, *attributelist;
+  int listsize,attsize ;
+  PyObject  *ii;
+     
+  if(!PyArg_ParseTuple(args,(char *)"OOOOOOOO",&hull,&seglist,&holelist,&regionlist,&pointattributelist,&segmarkerlist,&trianglelist,&mode)){
+    return NULL;
+  }
+  if(!PyList_Check(hull)){
+    PyErr_SetString(PyExc_TypeError, 
+		    "incorrect first argument for 'genMesh': list required.");
+    return NULL;
+  }
+  if(!PyList_Check(hull)){
+    PyErr_SetString(PyExc_TypeError,
+		    "incorrect second argument for 'genMesh': list required.");
+    return NULL;
+  }
+  if(!PyList_Check(hull)){
+    PyErr_SetString(PyExc_TypeError,
+		    "incorrect third argument for 'genMesh': list required.");
+    return NULL;
+  }
+  if(!PyList_Check(hull)){
+    PyErr_SetString(PyExc_TypeError,
+		    "incorrect fourth argument for 'genMesh': list required.");
+    return NULL;
+  }
+  if(!PyList_Check(hull)){
+    PyErr_SetString(PyExc_TypeError,
+		    "incorrect fifth argument for 'genMesh': list required.");
+    return NULL;
+  }
+  if(!PyList_Check(hull)){
+    PyErr_SetString(PyExc_TypeError,
+		    "incorrect sixth argument for 'genMesh': list required.");
+    return NULL;
+  }
+  if(!PyList_Check(hull)){
+    PyErr_SetString(PyExc_TypeError,
+		    "incorrect seventh argument for 'genMesh': list required.");
+    return NULL;
+  }
+  if(!PyList_Check(hull)){
+    PyErr_SetString(PyExc_TypeError,
+		    "incorrect eighth argument for 'genMesh': list required.");
+    return NULL;
+  }
+     
+     
+  /* Initialize  points */
+  in.numberofpoints =  PyList_Size(hull); 
+  in.pointlist = (REAL *)malloc(in.numberofpoints*2*sizeof(REAL));
+  in.pointmarkerlist = (int *)NULL; /* malloc(in.numberofpoints*sizeof(int)); */
+     
+  /* Initialize and fill up region list */
+  in.numberofregions = PyList_Size(regionlist);
+  
+  /*printf(" numberofregions %i\n",in.numberofregions );*/
+  in.regionlist = (REAL *)malloc(in.numberofregions*4*sizeof(REAL));
+  for(i=0; i<in.numberofregions;i++){
+    elems = PyList_GetItem(regionlist,i);
+    tuplesize = PySequence_Length(elems);
+    /*printf("tuplesize %i\n",tuplesize);*/
+    if (tuplesize>0){
+      in.regionlist[4*i] = PyFloat_AsDouble(PyTuple_GetItem(elems,0));
+    } else {
+      PyErr_SetString(PyExc_TypeError,
+		      "data sent to trianglemodule error: A region has no x value.");
+      return NULL;
+    }
+    if (tuplesize>1){
+      in.regionlist[4*i+1] = PyFloat_AsDouble(PyTuple_GetItem(elems,1));
+    } else {
+      PyErr_SetString(PyExc_TypeError,
+		    "data sent to trianglemodule error: A region has no y value.");
+      return NULL;
+    }
+    if (tuplesize>2){
+      /* 2 is attribute*/
+      in.regionlist[4*i+2] = PyFloat_AsDouble(PyTuple_GetItem(elems,2));
+    } else {
+      PyErr_SetString(PyExc_TypeError,
+		    "data sent to trianglemodule error: A region has no attribute value.");
+      return NULL;
+    }
+    if (tuplesize>3){
+      in.regionlist[4*i+3] = PyFloat_AsDouble(PyTuple_GetItem(elems,3));
+    } else {
+      /* 0.0 is interpreted as no local max area by triangle  */
+      in.regionlist[4*i+3] = (REAL)0.0;
+    } 
+  }
+  
+  /*Initialize segments */
+  in.numberofsegments = PyList_Size(seglist);
+  in.segmentlist = (int *)malloc(in.numberofsegments*2*sizeof(int));
+  in.segmentmarkerlist = (int *)malloc(in.numberofsegments*sizeof(int));
+
+    
+  /*Initialize triangles */
+  in.numberofcorners = 3;
+  in.numberoftriangles = PyList_Size(trianglelist);
+  if (in.numberoftriangles  != 0) {
+    in.trianglelist = (int *)malloc(in.numberofsegments*3*sizeof(int));
+  } else {
+    in.trianglelist = (int *)NULL;
+  }
+  in.numberoftriangleattributes = 0;  
+  in.triangleattributelist  = (REAL *)NULL; 
+     
+     
+     
+  /*Initialize holes */
+  in.numberofholes = PyList_Size(holelist);
+  if (in.numberofholes != 0) {
+    in.holelist = (REAL *)malloc(in.numberofholes*2*sizeof(REAL));
+  } else {
+    in.holelist = (REAL *)NULL;
+  }     
+     
+  /* Fill up triangle list */
+  index = 0;
+  for(i = 0; i < in.numberoftriangles; i++) {
+    pair =  PyList_GetItem(trianglelist,i);
+    if (3 != PySequence_Length(pair)) {
+      PyErr_SetString(PyExc_TypeError,
+		      "data sent to trianglemodule error:Found a triangle without 3 vertices.");
+      return NULL;
+    }
+    a = (int)PyInt_AsLong(PyTuple_GetItem(pair,0));
+    in.trianglelist[index] = a;
+    index++;
+    b = (int)PyInt_AsLong(PyTuple_GetItem(pair,1));
+    in.trianglelist[index] = b;
+    index++;
+    c = (int)PyInt_AsLong(PyTuple_GetItem(pair,2));
+    in.trianglelist[index] = c;
+    index++;
+  }
+     
+     
+  /*  print the triangle list DEBUGGING
+      printf ("numberoftriangles %i\n", in.numberoftriangles);
+      for(i = 0; i < in.numberoftriangles; i++) {
+      printf("(%i,%i,%i)",in.trianglelist[i* 3+ 0],in.trianglelist[i* 3+ 1], in.trianglelist[i* 3+ 2]);
+      }*/
+     
+  /* Fill up segment list */
+  index = 0;
+  if (in.numberofsegments != PyList_Size(segmarkerlist)) {
+    PyErr_SetString(PyExc_TypeError,
+		    "data sent to trianglemodule error:number of segments doesn't = number of segment attributes.");
+    return NULL;
+  }
+    
+  for(i = 0; i < in.numberofsegments; i++) {
+    pair =  PyList_GetItem(seglist,i);
+    if (2 != PySequence_Length(pair)) {
+      PyErr_SetString(PyExc_TypeError,
+		      "data sent to trianglemodule error:Found a segment without 2 vertices.");
+      return NULL;
+    }
+    a = (int)PyInt_AsLong(PyTuple_GetItem(pair,0));
+    in.segmentlist[index] = a;
+    index++;
+    b = (int)PyInt_AsLong(PyTuple_GetItem(pair,1));
+    in.segmentlist[index] = b;
+    index++;
+    /* Fill up segment marker list */
+    marker =  (int)PyInt_AsLong(PyList_GetItem(segmarkerlist,i));
+    in.segmentmarkerlist[i] = marker;
+  }
+  /* Fill up hole list */
+  index = 0;
+  for(i = 0; i < in.numberofholes; i++) {
+    pair =  PyList_GetItem(holelist,i);
+    if (2 != PySequence_Length(pair)) {
+      PyErr_SetString(PyExc_TypeError,
+		      "data sent to trianglemodule error:Found a pair without 2 vertices.");
+      return NULL;
+    }
+    x = PyFloat_AsDouble(PyTuple_GetItem(pair,0));
+    in.holelist[index] = x;
+    index++;
+    y = PyFloat_AsDouble(PyTuple_GetItem(pair,1));
+    in.holelist[index] = y;
+    index++;
+  }
+     
+  /* Fill up point list */
+  index = 0;
+  for(i = 0; i < in.numberofpoints; i++) {
+    pair =  PyList_GetItem(hull,i);
+    if (2 != PySequence_Length(pair)) {
+      PyErr_SetString(PyExc_TypeError,
+		      "data sent to trianglemodule error:Found a vertex without an x,y values.");
+      return NULL;
+    }
+    x = PyFloat_AsDouble(PyTuple_GetItem(pair,0));
+    in.pointlist[index] = x;
+    index++;
+    y = PyFloat_AsDouble(PyTuple_GetItem(pair,1));
+    in.pointlist[index] = y;
+    index++;
+  }
+
+  /* Initialize  point attributes */
+/*      firstPointAttr = PyList_GetItem(pointattributelist,0); */
+/*      if (firstPointAttr != NULL) { */
+/*        //in.numberofpointattributes = PyList_Size(firstPointAttr); */
+/*        printf("in.numberofpointattributes =%i",PyList_Size(firstPointAttr)); */
+/*        //printf("in.numberofpointattributes =%i",in.numberofpointattributes); */
+/*      } else { */
+/*        printf("(firstPointAttr is NULL\n"); */
+/*        in.pointattributelist = NULL; */
+/*        in.numberofpointattributes = 0; */
+/*      } */
+  n = PyList_Size(pointattributelist);
+  if (n < 0) {
+    in.numberofpointattributes = 0; 
+    in.pointattributelist = (REAL *)NULL;
+  } else {
+    /* Get the # of attributes based on the size of the first point*/
+    firstPointAttr = PyList_GetItem(pointattributelist,0);
+    if (firstPointAttr == NULL) {
+      in.numberofpointattributes = 0; 
+      in.pointattributelist = (REAL *)NULL;
+    } else {
+      in.numberofpointattributes = PyList_Size(firstPointAttr);
+      in.pointattributelist = (REAL *)malloc(in.numberofpoints
+					     *in.numberofpointattributes
+					     *sizeof(REAL)); 
+     
+     
+      /* fill the point attribute list */
+      if (in.numberofpointattributes != 0) {
+	for(j = 0; j < in.numberofpoints; j++){
+	  Attrlist = PyList_GetItem(pointattributelist,j);
+	  if (in.numberofpointattributes != PySequence_Length(Attrlist)) {
+	    PyErr_SetString(PyExc_TypeError,
+			    "data sent to trianglemodule error:List size of attributes is different from vertex to vertex.");
+	    return NULL;
+	  }
+	  for(i = 0; i < in.numberofpointattributes; i++){
+	    Attr = PyFloat_AsDouble(PyList_GetItem(Attrlist,i));
+	    in.pointattributelist[in.numberofpointattributes*j+i]= (REAL)Attr;
+	    /* 	 printf("i =%i\n",i);  */
+	    /* 	 printf("j =%i\n",j);  */
+	    /* 	 printf("in.pointattributelist[4*j+i]
+		 =%f\n",in.pointattributelist[4*j+i]); */
+	  }
+	}
+      } 
+    }
+  }
+    
+     
+  /* this half from triangulate*/
+  /* set up the switch arguments to the triangulation routine */
+
+  mod = PyString_AS_STRING(mode);
+     
+         
+  out.pointlist = (REAL *)NULL;
+  out.pointmarkerlist = (int *)NULL;
+  out.numberofpointattributes = in.numberofpointattributes;
+  out.pointattributelist = (REAL *)NULL;
+  
+  out.trianglelist = (int *)NULL;
+  out.triangleattributelist = (REAL *)NULL;                   
+  out.trianglearealist = (REAL *)NULL;                        
+  out.neighborlist = (int *)NULL;
+     
+  out.segmentlist = (int *)NULL;
+  out.segmentmarkerlist = (int *)NULL;
+     
+  out.edgelist = (int *)NULL;
+  out.edgemarkerlist = (int *)NULL;
+     
+  out.holelist = (REAL *)NULL;
+  out.regionlist = (REAL *)NULL;
+    
+  /*printf("\n\nTriangulate input args: %s \n\n", mod); */
+  triangulate(mod, &in, &out, (struct triangulateio *)NULL );
+
+  /*
+    ------- Pass point numbers,coordinates and neighbors back to Python ------
+    we send back a dictionary:                                               
+    { index : [ coordinates, [connections], Attribute ] } 
+  */
+  holder = PyDict_New();
+     
+  /* Add pointlist */
+  listsize = out.numberofpoints;
+  holderlist = PyList_New(listsize);
+     
+  for(i=0; i<listsize;i++){
+    PyObject *mlist = Py_BuildValue((char *)"(d,d)", 
+				    out.pointlist[i*2  ], out.pointlist[i*2+1]);  
+    PyList_SetItem(holderlist,i, mlist);
+  }  
+  ii=PyString_FromString("generatedpointlist");
+  PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);
+    
+  /* Add point marker list */
+  listsize = out.numberofpoints;
+  holderlist = PyList_New(listsize);
+  
+  for(i=0; i<listsize;i++){
+    PyObject *mlist = Py_BuildValue((char *)"d", 
+				    out.pointmarkerlist[i]);     
+    PyList_SetItem(holderlist,i, mlist); 
+  }  
+  ii=PyString_FromString("generatedpointmarkerlist");
+  PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);
+    
+  /* Add point attribute list */
+  listsize = out.numberofpoints;
+  holderlist = PyList_New(listsize);
+  
+  for(i=0; i<listsize;i++){
+    attsize = out.numberofpointattributes;
+    attributelist = PyList_New(attsize);
+    for(iatt=0; iatt<attsize;iatt++){
+      PyObject *mlist = Py_BuildValue((char *)"d", 
+				      out.pointattributelist[i*attsize + iatt]);     
+      PyList_SetItem(attributelist,iatt, mlist);
+    }      
+    PyList_SetItem(holderlist,i, attributelist);
+  }  
+  ii=PyString_FromString("generatedpointattributelist");
+  PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);  
+  
+  /* Add triangle list */
+  listsize = out.numberoftriangles;
+  holderlist = PyList_New(listsize);
+  for(i=0; i<listsize;i++){
+    PyObject *mlist = Py_BuildValue((char *)"(i,i,i)", 
+				    out.trianglelist[i*3  ], out.trianglelist [i*3+1], out.trianglelist [i*3+2]);    
+    PyList_SetItem(holderlist,i, mlist);
+  }    
+  ii=PyString_FromString("generatedtrianglelist");
+  PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);
+     
+     
+  /* Add triangle attribute list */
+  listsize = out.numberoftriangles;
+  holderlist = PyList_New(listsize);
+     
+  for(i=0; i<listsize; i++){
+    attsize = out.numberoftriangleattributes;
+    attributelist = PyList_New(attsize);       
+    for(iatt=0; iatt<attsize;iatt++){
+      PyObject *mlist = Py_BuildValue((char *)"d",out.triangleattributelist[i*attsize + iatt]);     
+      PyList_SetItem(attributelist,iatt, mlist);
+    }      
+    PyList_SetItem(holderlist,i, attributelist);
+  }  
+  ii=PyString_FromString("generatedtriangleattributelist");
+  PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);
+  
+  /* Add segment list */
+  listsize = out.numberofsegments;
+  holderlist = PyList_New(listsize);
+  for(i=0; i<listsize;i++){
+    PyObject *mlist = Py_BuildValue((char *)"(i,i)", 
+				    out.segmentlist[i*2  ],
+				    out.segmentlist [i*2+1]);
+    PyList_SetItem(holderlist,i, mlist);
+  }    
+  ii=PyString_FromString("generatedsegmentlist");
+  PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);  
+  
+  /* Add segment marker list */
+  listsize = out.numberofsegments;
+  holderlist = PyList_New(listsize);
+  for(i=0; i<listsize;i++){
+    PyObject *mlist = Py_BuildValue((char *)"i", 
+				    out.segmentmarkerlist[i]);
+    PyList_SetItem(holderlist,i, mlist);
+  }    
+  ii=PyString_FromString("generatedsegmentmarkerlist");
+  PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);  
+  /* Add triangle neighbor list */
+  if (out.neighborlist != NULL) {
+    listsize = out.numberoftriangles;
+    holderlist = PyList_New(listsize);
+    for(i=0; i<listsize;i++){
+      PyObject *mlist = Py_BuildValue((char *)"(i,i,i)", 
+				      out.neighborlist[i*3  ],
+				      out.neighborlist [i*3+1],
+				      out.neighborlist [i*3+2]);    
+      PyList_SetItem(holderlist,i, mlist);
+    }    
+    ii=PyString_FromString("generatedtriangleneighborlist");
+    PyDict_SetItem(holder, ii, holderlist);
+    Py_DECREF(ii); Py_DECREF(holderlist);
+  }   
+     
+  /* Free in/out structure memory */
+  
+  /* OUT */
+
+  if(!out.pointlist){
+    free(out.pointlist);  out.pointlist=NULL;
+  }
+  if(!out.pointmarkerlist){    
+    free(out.pointmarkerlist); out.pointmarkerlist=NULL;
+  }
+  if(!out.pointattributelist){    
+    free(out.pointattributelist); out.pointattributelist=NULL;
+  }
+    
+ 
+  if(!out.trianglelist){    
+    free(out.trianglelist); out.trianglelist=NULL;
+  }
+  if(!out.triangleattributelist){    
+    free(out.triangleattributelist); out.triangleattributelist=NULL;
+  }
+  if(!out.trianglearealist){    
+    free(out.trianglearealist); out.trianglearealist=NULL;
+  }
+  if(!out.neighborlist){    
+    free(out.neighborlist); out.neighborlist=NULL;
+  }
+  if(!out.segmentlist){
+    free(out.segmentlist); out.segmentlist =NULL;
+  }
+  if(!out.segmentmarkerlist){
+    free(out.segmentmarkerlist); out.segmentmarkerlist  =NULL;
+  }
+  if(!out.edgelist){
+    free(out.edgelist);  out.edgelist=NULL;
+  }
+  if(!out.edgemarkerlist){
+    free(out.edgemarkerlist);  out.edgemarkerlist=NULL;
+  }
+  if(!out.holelist){
+    free(out.holelist); out.holelist=NULL;
+  }
+  if(!out.regionlist){
+    free(out.regionlist); out.regionlist=NULL;
+  }
+    
+  /*  IN */
+  
+  if(!in.pointlist){
+    free(in.pointlist);  in.pointlist   =NULL;             
+  }
+  if(!in.pointattributelist){
+    free(in.pointattributelist); in.pointattributelist =NULL;       
+  }
+  if(!in.pointmarkerlist){
+    free(in.pointmarkerlist); in.pointmarkerlist    =NULL;        
+  }
+  if(!in.segmentlist){
+    free(in.segmentlist);  in.segmentlist    =NULL;         
+  }
+  if(!in.segmentmarkerlist){
+    free(in.segmentmarkerlist); in.segmentmarkerlist    =NULL;   
+  }
+  if(!in.regionlist){
+    free(in.regionlist); in.regionlist  =NULL;            
+  }
+  if(!in.holelist){
+    free(in.holelist); in.holelist=NULL;
+  }
+
+  //return Py_BuildValue((char *)"O", holder);
+  return Py_BuildValue((char *)"O", holder);
+}
+
+/* end of my function*/
+
+
+   
+    
+static PyMethodDef triang_methods[] = {
+  {(char *)"genMesh", triang_genMesh, 1, (char *)"Passes hull points to triangle.All arguments are lists.(<hull>,<seglist>,<holelist>,<regionlist>)-><hull>"}, 
+  {NULL,NULL}
+};
+
+void inittriang(){
+  Py_InitModule((char *)"triang",triang_methods);
+}    
Index: inundation/triangle/triangmodule.c
===================================================================
--- inundation/triangle/triangmodule.c	(revision 2141)
+++ 	(revision )
@@ -1,573 +1,0 @@
-/* this appears to be necessary to run on Linux */
-
-#undef _STDLIB_H_
-#define _STDLIB_H_
-
-
-/*
-    This code is based on code by A. Pletzer
-
-    This code interfaces pmesh directly with "triangle", a general        
-    purpose triangulation code. In doing so, Python data structures          
-    are passed to C for  use by "triangle" and the results are then          
-    converted back. This was accomplished using the Python/C API.            
-                                                                           
-    I. Lists of points,edges,holes, and regions must normally be 
-     created for proper triangulation. However, if there are no holes,
-     the  hole list need not be specified (however, a 
-     measure of control over the shape of the convex hull is lost; 
-     triangle decides). 
-     
-     points list: [(x1,y1),(x2,y2),...] (Tuples of doubles)                  
-     edge list: [(Ea,Eb),(Ef,Eg),...] (Tuples of integers)                   
-     hole list: [(x1,y1),...](Tuples of doubles, one inside each hole region)
-     regionlist: [ (x1,y1,index,area),...] (Tuple of doubles)                
-     pointattributelist:[ (a1,a2..),...] (Tuple of lists) 
-     mode: String - the commands sent to triangle
-          
-     This is all that is needed to accomplish an intial triangulation.       
-     A dictionary of the Triangle output is returned.                                   
-     Precondition
-     End list in the pointattributelist has to have the same length
-     
-    Compilation can be done as follows                                       
-                    
-    c++ -I/usr/local/include/python1.5 -shared -o triangmodule.so            
-    triangmodule.c triangle.o                                                */
-
-
-#ifdef SINGLE  
-#define REAL float 
-#else  
-#define REAL double 
-#endif  
-
-#include "triangle.h" 
-
-#ifndef _STDLIB_H_ 
-#ifndef _WIN32
-extern "C" void *malloc(); 
-extern "C" void free(); 
-#endif
-#endif  
-
-#include "Python.h" 
-
-
- static PyObject *triang_genMesh(PyObject *self, PyObject *args){
-     
-  /* Mesh generation routine
-     pre-conditions:
-     mode must have a 'z' switch, to avoid segmentation faults
-  */
-    
-  struct triangulateio in,out;
-
-  PyObject *hull;
-  PyObject *seglist;
-  PyObject *holelist;
-  PyObject *regionlist;
-  PyObject *trianglelist;
-  PyObject *mode;
-  PyObject *firstPointAttr;
-  PyObject *pointattributelist;
-  PyObject *segmarkerlist;
-  PyObject *Attrlist;
-  REAL Attr;
-  int i, j, iatt, n;
-  int a,b,c;
-  int marker;
-  int tuplesize;
-    
-  int index = 0;
-  double x,y;
-  PyObject *elems;
-  PyObject *pair;
-     
-  char *mod;
-  PyObject *holder, *holderlist, *attributelist;
-  int listsize,attsize ;
-  PyObject  *ii;
-     
-  if(!PyArg_ParseTuple(args,(char *)"OOOOOOOO",&hull,&seglist,&holelist,&regionlist,&pointattributelist,&segmarkerlist,&trianglelist,&mode)){
-    return NULL;
-  }
-  if(!PyList_Check(hull)){
-    PyErr_SetString(PyExc_TypeError, 
-		    "incorrect first argument for 'genMesh': list required.");
-    return NULL;
-  }
-  if(!PyList_Check(hull)){
-    PyErr_SetString(PyExc_TypeError,
-		    "incorrect second argument for 'genMesh': list required.");
-    return NULL;
-  }
-  if(!PyList_Check(hull)){
-    PyErr_SetString(PyExc_TypeError,
-		    "incorrect third argument for 'genMesh': list required.");
-    return NULL;
-  }
-  if(!PyList_Check(hull)){
-    PyErr_SetString(PyExc_TypeError,
-		    "incorrect fourth argument for 'genMesh': list required.");
-    return NULL;
-  }
-  if(!PyList_Check(hull)){
-    PyErr_SetString(PyExc_TypeError,
-		    "incorrect fifth argument for 'genMesh': list required.");
-    return NULL;
-  }
-  if(!PyList_Check(hull)){
-    PyErr_SetString(PyExc_TypeError,
-		    "incorrect sixth argument for 'genMesh': list required.");
-    return NULL;
-  }
-  if(!PyList_Check(hull)){
-    PyErr_SetString(PyExc_TypeError,
-		    "incorrect seventh argument for 'genMesh': list required.");
-    return NULL;
-  }
-  if(!PyList_Check(hull)){
-    PyErr_SetString(PyExc_TypeError,
-		    "incorrect eighth argument for 'genMesh': list required.");
-    return NULL;
-  }
-     
-     
-  /* Initialize  points */
-  in.numberofpoints =  PyList_Size(hull); 
-  in.pointlist = (REAL *)malloc(in.numberofpoints*2*sizeof(REAL));
-  in.pointmarkerlist = (int *)NULL; /* malloc(in.numberofpoints*sizeof(int)); */
-     
-  /* Initialize and fill up region list */
-  in.numberofregions = PyList_Size(regionlist);
-  
-  /*printf(" numberofregions %i\n",in.numberofregions );*/
-  in.regionlist = (REAL *)malloc(in.numberofregions*4*sizeof(REAL));
-  for(i=0; i<in.numberofregions;i++){
-    elems = PyList_GetItem(regionlist,i);
-    tuplesize = PySequence_Length(elems);
-    /*printf("tuplesize %i\n",tuplesize);*/
-    if (tuplesize>0){
-      in.regionlist[4*i] = PyFloat_AsDouble(PyTuple_GetItem(elems,0));
-    } else {
-      PyErr_SetString(PyExc_TypeError,
-		      "data sent to trianglemodule error: A region has no x value.");
-      return NULL;
-    }
-    if (tuplesize>1){
-      in.regionlist[4*i+1] = PyFloat_AsDouble(PyTuple_GetItem(elems,1));
-    } else {
-      PyErr_SetString(PyExc_TypeError,
-		    "data sent to trianglemodule error: A region has no y value.");
-      return NULL;
-    }
-    if (tuplesize>2){
-      /* 2 is attribute*/
-      in.regionlist[4*i+2] = PyFloat_AsDouble(PyTuple_GetItem(elems,2));
-    } else {
-      PyErr_SetString(PyExc_TypeError,
-		    "data sent to trianglemodule error: A region has no attribute value.");
-      return NULL;
-    }
-    if (tuplesize>3){
-      in.regionlist[4*i+3] = PyFloat_AsDouble(PyTuple_GetItem(elems,3));
-    } else {
-      /* 0.0 is interpreted as no local max area by triangle  */
-      in.regionlist[4*i+3] = (REAL)0.0;
-    } 
-  }
-  
-  /*Initialize segments */
-  in.numberofsegments = PyList_Size(seglist);
-  in.segmentlist = (int *)malloc(in.numberofsegments*2*sizeof(int));
-  in.segmentmarkerlist = (int *)malloc(in.numberofsegments*sizeof(int));
-
-    
-  /*Initialize triangles */
-  in.numberofcorners = 3;
-  in.numberoftriangles = PyList_Size(trianglelist);
-  if (in.numberoftriangles  != 0) {
-    in.trianglelist = (int *)malloc(in.numberofsegments*3*sizeof(int));
-  } else {
-    in.trianglelist = (int *)NULL;
-  }
-  in.numberoftriangleattributes = 0;  
-  in.triangleattributelist  = (REAL *)NULL; 
-     
-     
-     
-  /*Initialize holes */
-  in.numberofholes = PyList_Size(holelist);
-  if (in.numberofholes != 0) {
-    in.holelist = (REAL *)malloc(in.numberofholes*2*sizeof(REAL));
-  } else {
-    in.holelist = (REAL *)NULL;
-  }     
-     
-  /* Fill up triangle list */
-  index = 0;
-  for(i = 0; i < in.numberoftriangles; i++) {
-    pair =  PyList_GetItem(trianglelist,i);
-    if (3 != PySequence_Length(pair)) {
-      PyErr_SetString(PyExc_TypeError,
-		      "data sent to trianglemodule error:Found a triangle without 3 vertices.");
-      return NULL;
-    }
-    a = (int)PyInt_AsLong(PyTuple_GetItem(pair,0));
-    in.trianglelist[index] = a;
-    index++;
-    b = (int)PyInt_AsLong(PyTuple_GetItem(pair,1));
-    in.trianglelist[index] = b;
-    index++;
-    c = (int)PyInt_AsLong(PyTuple_GetItem(pair,2));
-    in.trianglelist[index] = c;
-    index++;
-  }
-     
-     
-  /*  print the triangle list DEBUGGING
-      printf ("numberoftriangles %i\n", in.numberoftriangles);
-      for(i = 0; i < in.numberoftriangles; i++) {
-      printf("(%i,%i,%i)",in.trianglelist[i* 3+ 0],in.trianglelist[i* 3+ 1], in.trianglelist[i* 3+ 2]);
-      }*/
-     
-  /* Fill up segment list */
-  index = 0;
-  if (in.numberofsegments != PyList_Size(segmarkerlist)) {
-    PyErr_SetString(PyExc_TypeError,
-		    "data sent to trianglemodule error:number of segments doesn't = number of segment attributes.");
-    return NULL;
-  }
-    
-  for(i = 0; i < in.numberofsegments; i++) {
-    pair =  PyList_GetItem(seglist,i);
-    if (2 != PySequence_Length(pair)) {
-      PyErr_SetString(PyExc_TypeError,
-		      "data sent to trianglemodule error:Found a segment without 2 vertices.");
-      return NULL;
-    }
-    a = (int)PyInt_AsLong(PyTuple_GetItem(pair,0));
-    in.segmentlist[index] = a;
-    index++;
-    b = (int)PyInt_AsLong(PyTuple_GetItem(pair,1));
-    in.segmentlist[index] = b;
-    index++;
-    /* Fill up segment marker list */
-    marker =  (int)PyInt_AsLong(PyList_GetItem(segmarkerlist,i));
-    in.segmentmarkerlist[i] = marker;
-  }
-  /* Fill up hole list */
-  index = 0;
-  for(i = 0; i < in.numberofholes; i++) {
-    pair =  PyList_GetItem(holelist,i);
-    if (2 != PySequence_Length(pair)) {
-      PyErr_SetString(PyExc_TypeError,
-		      "data sent to trianglemodule error:Found a pair without 2 vertices.");
-      return NULL;
-    }
-    x = PyFloat_AsDouble(PyTuple_GetItem(pair,0));
-    in.holelist[index] = x;
-    index++;
-    y = PyFloat_AsDouble(PyTuple_GetItem(pair,1));
-    in.holelist[index] = y;
-    index++;
-  }
-     
-  /* Fill up point list */
-  index = 0;
-  for(i = 0; i < in.numberofpoints; i++) {
-    pair =  PyList_GetItem(hull,i);
-    if (2 != PySequence_Length(pair)) {
-      PyErr_SetString(PyExc_TypeError,
-		      "data sent to trianglemodule error:Found a vertex without an x,y values.");
-      return NULL;
-    }
-    x = PyFloat_AsDouble(PyTuple_GetItem(pair,0));
-    in.pointlist[index] = x;
-    index++;
-    y = PyFloat_AsDouble(PyTuple_GetItem(pair,1));
-    in.pointlist[index] = y;
-    index++;
-  }
-
-  /* Initialize  point attributes */
-/*      firstPointAttr = PyList_GetItem(pointattributelist,0); */
-/*      if (firstPointAttr != NULL) { */
-/*        //in.numberofpointattributes = PyList_Size(firstPointAttr); */
-/*        printf("in.numberofpointattributes =%i",PyList_Size(firstPointAttr)); */
-/*        //printf("in.numberofpointattributes =%i",in.numberofpointattributes); */
-/*      } else { */
-/*        printf("(firstPointAttr is NULL\n"); */
-/*        in.pointattributelist = NULL; */
-/*        in.numberofpointattributes = 0; */
-/*      } */
-  n = PyList_Size(pointattributelist);
-  if (n < 0) {
-    in.numberofpointattributes = 0; 
-    in.pointattributelist = (REAL *)NULL;
-  } else {
-    /* Get the # of attributes based on the size of the first point*/
-    firstPointAttr = PyList_GetItem(pointattributelist,0);
-    if (firstPointAttr == NULL) {
-      in.numberofpointattributes = 0; 
-      in.pointattributelist = (REAL *)NULL;
-    } else {
-      in.numberofpointattributes = PyList_Size(firstPointAttr);
-      in.pointattributelist = (REAL *)malloc(in.numberofpoints
-					     *in.numberofpointattributes
-					     *sizeof(REAL)); 
-     
-     
-      /* fill the point attribute list */
-      if (in.numberofpointattributes != 0) {
-	for(j = 0; j < in.numberofpoints; j++){
-	  Attrlist = PyList_GetItem(pointattributelist,j);
-	  if (in.numberofpointattributes != PySequence_Length(Attrlist)) {
-	    PyErr_SetString(PyExc_TypeError,
-			    "data sent to trianglemodule error:List size of attributes is different from vertex to vertex.");
-	    return NULL;
-	  }
-	  for(i = 0; i < in.numberofpointattributes; i++){
-	    Attr = PyFloat_AsDouble(PyList_GetItem(Attrlist,i));
-	    in.pointattributelist[in.numberofpointattributes*j+i]= (REAL)Attr;
-	    /* 	 printf("i =%i\n",i);  */
-	    /* 	 printf("j =%i\n",j);  */
-	    /* 	 printf("in.pointattributelist[4*j+i]
-		 =%f\n",in.pointattributelist[4*j+i]); */
-	  }
-	}
-      } 
-    }
-  }
-    
-     
-  /* this half from triangulate*/
-  /* set up the switch arguments to the triangulation routine */
-
-  mod = PyString_AS_STRING(mode);
-     
-         
-  out.pointlist = (REAL *)NULL;
-  out.pointmarkerlist = (int *)NULL;
-  out.numberofpointattributes = in.numberofpointattributes;
-  out.pointattributelist = (REAL *)NULL;
-  
-  out.trianglelist = (int *)NULL;
-  out.triangleattributelist = (REAL *)NULL;                   
-  out.trianglearealist = (REAL *)NULL;                        
-  out.neighborlist = (int *)NULL;
-     
-  out.segmentlist = (int *)NULL;
-  out.segmentmarkerlist = (int *)NULL;
-     
-  out.edgelist = (int *)NULL;
-  out.edgemarkerlist = (int *)NULL;
-     
-  out.holelist = (REAL *)NULL;
-  out.regionlist = (REAL *)NULL;
-    
-  /*printf("\n\nTriangulate input args: %s \n\n", mod); */
-  triangulate(mod, &in, &out, (struct triangulateio *)NULL );
-
-  /*
-    ------- Pass point numbers,coordinates and neighbors back to Python ------
-    we send back a dictionary:                                               
-    { index : [ coordinates, [connections], Attribute ] } 
-  */
-  holder = PyDict_New();
-     
-  /* Add pointlist */
-  listsize = out.numberofpoints;
-  holderlist = PyList_New(listsize);
-     
-  for(i=0; i<listsize;i++){
-    PyObject *mlist = Py_BuildValue((char *)"(d,d)", 
-				    out.pointlist[i*2  ], out.pointlist[i*2+1]);  
-    PyList_SetItem(holderlist,i, mlist);
-  }  
-  ii=PyString_FromString("generatedpointlist");
-  PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);
-    
-  /* Add point marker list */
-  listsize = out.numberofpoints;
-  holderlist = PyList_New(listsize);
-  
-  for(i=0; i<listsize;i++){
-    PyObject *mlist = Py_BuildValue((char *)"d", 
-				    out.pointmarkerlist[i]);     
-    PyList_SetItem(holderlist,i, mlist); 
-  }  
-  ii=PyString_FromString("generatedpointmarkerlist");
-  PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);
-    
-  /* Add point attribute list */
-  listsize = out.numberofpoints;
-  holderlist = PyList_New(listsize);
-  
-  for(i=0; i<listsize;i++){
-    attsize = out.numberofpointattributes;
-    attributelist = PyList_New(attsize);
-    for(iatt=0; iatt<attsize;iatt++){
-      PyObject *mlist = Py_BuildValue((char *)"d", 
-				      out.pointattributelist[i*attsize + iatt]);     
-      PyList_SetItem(attributelist,iatt, mlist);
-    }      
-    PyList_SetItem(holderlist,i, attributelist);
-  }  
-  ii=PyString_FromString("generatedpointattributelist");
-  PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);  
-  
-  /* Add triangle list */
-  listsize = out.numberoftriangles;
-  holderlist = PyList_New(listsize);
-  for(i=0; i<listsize;i++){
-    PyObject *mlist = Py_BuildValue((char *)"(i,i,i)", 
-				    out.trianglelist[i*3  ], out.trianglelist [i*3+1], out.trianglelist [i*3+2]);    
-    PyList_SetItem(holderlist,i, mlist);
-  }    
-  ii=PyString_FromString("generatedtrianglelist");
-  PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);
-     
-     
-  /* Add triangle attribute list */
-  listsize = out.numberoftriangles;
-  holderlist = PyList_New(listsize);
-     
-  for(i=0; i<listsize; i++){
-    attsize = out.numberoftriangleattributes;
-    attributelist = PyList_New(attsize);       
-    for(iatt=0; iatt<attsize;iatt++){
-      PyObject *mlist = Py_BuildValue((char *)"d",out.triangleattributelist[i*attsize + iatt]);     
-      PyList_SetItem(attributelist,iatt, mlist);
-    }      
-    PyList_SetItem(holderlist,i, attributelist);
-  }  
-  ii=PyString_FromString("generatedtriangleattributelist");
-  PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);
-  
-  /* Add segment list */
-  listsize = out.numberofsegments;
-  holderlist = PyList_New(listsize);
-  for(i=0; i<listsize;i++){
-    PyObject *mlist = Py_BuildValue((char *)"(i,i)", 
-				    out.segmentlist[i*2  ],
-				    out.segmentlist [i*2+1]);
-    PyList_SetItem(holderlist,i, mlist);
-  }    
-  ii=PyString_FromString("generatedsegmentlist");
-  PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);  
-  
-  /* Add segment marker list */
-  listsize = out.numberofsegments;
-  holderlist = PyList_New(listsize);
-  for(i=0; i<listsize;i++){
-    PyObject *mlist = Py_BuildValue((char *)"i", 
-				    out.segmentmarkerlist[i]);
-    PyList_SetItem(holderlist,i, mlist);
-  }    
-  ii=PyString_FromString("generatedsegmentmarkerlist");
-  PyDict_SetItem(holder, ii, holderlist); Py_DECREF(ii); Py_DECREF(holderlist);  
-  /* Add triangle neighbor list */
-  if (out.neighborlist != NULL) {
-    listsize = out.numberoftriangles;
-    holderlist = PyList_New(listsize);
-    for(i=0; i<listsize;i++){
-      PyObject *mlist = Py_BuildValue((char *)"(i,i,i)", 
-				      out.neighborlist[i*3  ],
-				      out.neighborlist [i*3+1],
-				      out.neighborlist [i*3+2]);    
-      PyList_SetItem(holderlist,i, mlist);
-    }    
-    ii=PyString_FromString("generatedtriangleneighborlist");
-    PyDict_SetItem(holder, ii, holderlist);
-    Py_DECREF(ii); Py_DECREF(holderlist);
-  }   
-     
-  /* Free in/out structure memory */
-  
-  /* OUT */
-
-  if(!out.pointlist){
-    free(out.pointlist);  out.pointlist=NULL;
-  }
-  if(!out.pointmarkerlist){    
-    free(out.pointmarkerlist); out.pointmarkerlist=NULL;
-  }
-  if(!out.pointattributelist){    
-    free(out.pointattributelist); out.pointattributelist=NULL;
-  }
-    
- 
-  if(!out.trianglelist){    
-    free(out.trianglelist); out.trianglelist=NULL;
-  }
-  if(!out.triangleattributelist){    
-    free(out.triangleattributelist); out.triangleattributelist=NULL;
-  }
-  if(!out.trianglearealist){    
-    free(out.trianglearealist); out.trianglearealist=NULL;
-  }
-  if(!out.neighborlist){    
-    free(out.neighborlist); out.neighborlist=NULL;
-  }
-  if(!out.segmentlist){
-    free(out.segmentlist); out.segmentlist =NULL;
-  }
-  if(!out.segmentmarkerlist){
-    free(out.segmentmarkerlist); out.segmentmarkerlist  =NULL;
-  }
-  if(!out.edgelist){
-    free(out.edgelist);  out.edgelist=NULL;
-  }
-  if(!out.edgemarkerlist){
-    free(out.edgemarkerlist);  out.edgemarkerlist=NULL;
-  }
-  if(!out.holelist){
-    free(out.holelist); out.holelist=NULL;
-  }
-  if(!out.regionlist){
-    free(out.regionlist); out.regionlist=NULL;
-  }
-    
-  /*  IN */
-  
-  if(!in.pointlist){
-    free(in.pointlist);  in.pointlist   =NULL;             
-  }
-  if(!in.pointattributelist){
-    free(in.pointattributelist); in.pointattributelist =NULL;       
-  }
-  if(!in.pointmarkerlist){
-    free(in.pointmarkerlist); in.pointmarkerlist    =NULL;        
-  }
-  if(!in.segmentlist){
-    free(in.segmentlist);  in.segmentlist    =NULL;         
-  }
-  if(!in.segmentmarkerlist){
-    free(in.segmentmarkerlist); in.segmentmarkerlist    =NULL;   
-  }
-  if(!in.regionlist){
-    free(in.regionlist); in.regionlist  =NULL;            
-  }
-  if(!in.holelist){
-    free(in.holelist); in.holelist=NULL;
-  }
-
-  //return Py_BuildValue((char *)"O", holder);
-  return Py_BuildValue((char *)"O", holder);
-}
-
-/* end of my function*/
-
-
-   
-    
-static PyMethodDef triang_methods[] = {
-  {(char *)"genMesh", triang_genMesh, 1, (char *)"Passes hull points to triangle.All arguments are lists.(<hull>,<seglist>,<holelist>,<regionlist>)-><hull>"}, 
-  {NULL,NULL}
-};
-
-void inittriang(){
-  Py_InitModule((char *)"triang",triang_methods);
-}    
