Index: /inundation/ga/storm_surge/pmesh/load_mesh/loadASCII.py
===================================================================
--- /inundation/ga/storm_surge/pmesh/load_mesh/loadASCII.py	(revision 934)
+++ /inundation/ga/storm_surge/pmesh/load_mesh/loadASCII.py	(revision 935)
@@ -66,4 +66,7 @@
 
 def read_triangulation(fd):
+    """
+    Read the generated triangulation, NOT the outline. 
+    """
     delimiter = " "
     ######### loading the point info
@@ -451,4 +454,7 @@
     Following lines:  <segment #> <vertex #>  <vertex #> [boundary marker]
     """
+    #print "DSG************"
+    #print "gen_dict",gen_dict 
+    #print "DSG************"
     try:
         fd = open(ofile,'w')
@@ -458,4 +464,78 @@
         msg = 'Could not write file %s ' %fileName
         raise IOError, msg 
+
+        
+def write_ASCII_mesh(fd,
+                     dict):
+    points = dict['pointlist']
+    point_attributes = dict['pointattributelist']
+    segments = dict['segmentlist']
+    segment_markers = dict['segmentmarkerlist']
+    holes = dict['holelist']
+    regions = dict['regionlist']
+        
+    num_points = str(len(points))
+    if (num_points == "0"):
+        num_point_atts = "0"
+    else:
+        num_point_atts = str(len(point_attributes[0]))
+    fd.write(num_points + " " + num_point_atts + " # <# of verts> <# of vert attributes>, next lines <vertex #> <x> <y> [attributes] ...Mesh Vertices..." + "\n")
+        
+    # <x> <y> [attributes]
+    for i,point in enumerate(points):
+        attlist = ""
+        for att in point_attributes[i]:
+            attlist = attlist + str(att)+" "
+        attlist.strip()
+        fd.write(str(i) + " "
+                 +str(point[0]) + " "
+                 + str(point[1]) + " "
+                 + attlist + "\n")
+            
+    #One line:  <# of segments> 
+    fd.write(str(len(segments)) + 
+             " # <# of segments>, next lines <segment #> <vertex #>  <vertex #> [boundary marker] ...Mesh Segments..." + "\n")
+        
+    #Following lines:  <vertex #>  <vertex #> [boundary marker]
+    for i,seg in enumerate(segments):
+        fd.write(str(i) + " "
+                 + str(seg[0]) + " " 
+                 + str(seg[1]) + " " 
+                 + str(segment_markers[i]) + "\n")
+
+    #One line:  <# of holes> 
+    fd.write(str(len(holes)) + 
+             " # <# of holes>, next lines <Hole #> <x> <y> ...Mesh Holes..." + "\n")    
+    # <x> <y>
+    for i,h in enumerate(holes):
+        fd.write(str(i) + " "
+                 + str(h[0]) + " "
+                 + str(h[1]) + "\n")
+        
+    #One line:  <# of regions> 
+    fd.write(str(len(regions)) + 
+             " # <# of regions>, next lines <Region #> <x> <y> <tag>...Mesh Regions..." + "\n")    
+    # <index> <x> <y> <tag>
+    #print "regions",regions 
+    for i,r in enumerate(regions):
+        #print "r",r 
+        fd.write(str(i) + " " 
+                 + str(r[0]) + " "
+                 + str(r[1])+ " "
+                 + str(r[2]) + "\n")
+        
+    # <index> [<MaxArea>|""]
+        
+    #One line:  <# of regions> 
+    fd.write(str(len(regions)) + 
+             " # <# of regions>, next lines <Region #> [Max Area] ...Mesh Regions..." + "\n") 
+    for i,r in enumerate(regions):
+        if len(r) < 4:
+            area = ""
+        else:
+            area = str(r[3])
+            
+        fd.write(str(i) + " " + area + "\n")
+
 
 ## used by alpha shapes
Index: /inundation/ga/storm_surge/pmesh/load_mesh/test_loadASCII.py
===================================================================
--- /inundation/ga/storm_surge/pmesh/load_mesh/test_loadASCII.py	(revision 934)
+++ /inundation/ga/storm_surge/pmesh/load_mesh/test_loadASCII.py	(revision 935)
@@ -22,6 +22,4 @@
 from Numeric import array #Float, arrayrange, concatenate
     
-#FIXME (DSG): remove this dependency
-from mesh import *
 from loadASCII import *
 from Numeric import array, allclose
@@ -34,126 +32,55 @@
         pass
 
-
-# FIXME move this to meshharness.  have a test that doesn't depend on mesh
-    def ztest_import_triangulation(self):
-    
-        a_att = [5,2]
-        d_att =[4,2]
-        f_att = [3,2]
-        e_att = [2,2]
-        a_xy = [0.0, 0.0]
-        a = Vertex ( a_xy[0],a_xy[1]) #, attributes =a_att)
-        d = Vertex (0.0, 4.0) #, attributes =d_att)
-        f = Vertex (4.0,0.0) #, attributes =f_att)
-        e = Vertex (1.0,1.0) #, attributes =e_att)
-    
-        s1 = Segment(a,d, marker = "50")
-        s2 = Segment(d,f, marker = "40")
-        s3 = Segment(a,f, marker = "30")
-        s4 = Segment(a,e, marker = "20")
-     
-        r1 = Region(0.3, 0.3,tag = "1.3", maxArea = 45)
-        m = Mesh(userVertices=[a,d,f,e],
-                 userSegments=[s1,s2,s3,s4],
-                 regions=[r1])
-
-        m.generateMesh("QApza2.1")
-
-        seg = m.getMeshSegments()
-        points = m.getMeshVertices()
-        
+    
+    def test_import_mesh(self):
+        dict ={}
+        dict['segmentlist'] = [(0, 1), (1, 2), (0, 2), (0, 3)]
+        dict['segmentmarkerlist'] = ['50', '40', '30', '20']
+        dict['holelist'] = [(0.2, 0.6)]
+        dict['pointattributelist'] = [[5, 2], [4, 2], [3, 2], [2,2]]
+        dict['regionlist'] = [(0.3, 0.3, '1.3',36.0)]
+        dict['pointlist'] = [(0.0, 0.0), (0.0, 4.0), (4.0, 0.0), (1.0, 1.0)]
+
         fileName = tempfile.mktemp(".txt")
-        #print "fileName",fileName
-
-        #print "",
-        #print "",
-        
-        m.exportASCIItriangulationfile(fileName)
-        
-        dict = import_triangulation(fileName)
-        os.remove(fileName)
-        
+        fd = open(fileName,'w')
+        write_ASCII_mesh(fd,dict)
+        fd.close()
+        loaded_dict = import_mesh(fileName)
+        os.remove(fileName)
+        
+        #gen_dict = 
+        #print "*********************"
         #print dict
-        #print "seg",seg
-        for pimport,pactual,pimpatt in map(None,dict['generatedpointlist'],points,dict['generatedpointattributelist']):
-            self.failUnless( pimport == [pactual.x,pactual.y],
-                        'loadASCIITestCase failed. test 1')
-            self.failUnless( pimpatt == pactual.attributes,
-                        'loadASCIITestCase failed. test 1.1')
-        self.failUnless( dict['segmentlist'][0] == [0,1],
-                        'loadASCIITestCase failed. test 3')
-        for segimp,segactual in map(None,dict['generatedsegmentmarkerlist'],seg):
-            self.failUnless( segimp == segactual.marker,
-                        'loadASCIITestCase failed. test 4')
-        self.failUnless( dict['generatedtrianglelist'][0] == [3,2,4],
-                        'loadASCIITestCase failed. test 5')
-        self.failUnless( dict['generatedtriangleneighborlist'][0] == [-1,2,3],
+        #print "**loaded_dict*******************"
+        #print loaded_dict
+        #print "*********************"
+
+        
+        self.failUnless(array(loaded_dict['pointlist'])  ==
+                        array(dict['pointlist']),
+                         'test_import_mesh failed. Test 1')
+        self.failUnless(array(loaded_dict['pointattributelist'])  ==
+                        array(dict['pointattributelist']),
+                         'test_import_mesh failed. Test 2')
+        self.failUnless(array(loaded_dict['segmentlist'])  ==
+                        array(dict['segmentlist']),
+                         'test_import_mesh failed. Test 3')
+        self.failUnless(array(loaded_dict['segmentmarkerlist'])  ==
+                        array(dict['segmentmarkerlist']),
+                         'test_import_mesh failed. Test 4')
+        
+        for regimp,regactual,regattimp, regmaxarea in map(None,loaded_dict['regionlist'],dict['regionlist'], loaded_dict['regionattributelist'], loaded_dict['regionmaxarealist']):
+            self.failUnless( regimp == [regactual[0],regactual[1]],
                         'loadASCIITestCase failed. test 6')
-        self.failUnless( dict['generatedtriangleattributelist'][0] == ["1.3"],
-                         'loadASCIITestCase failed. test 7')
-      
-      
-# FIXME move this to meshharness.  have a test that doesn't depend on mesh
-    def ztest_import_mesh(self):
-    
-        a_att = [5,2]
-        d_att =[4,2]
-        f_att = [3,2]
-        e_att = [2,2]
-        a_xy = [0.0, 0.0]
-        a = Vertex ( a_xy[0],a_xy[1], attributes =a_att)
-        d = Vertex (0.0, 4.0, attributes =d_att)
-        f = Vertex (4.0,0.0, attributes =f_att)
-        e = Vertex (1.0,1.0, attributes =e_att)
-    
-        s1 = Segment(a,d, marker = "50")
-        s2 = Segment(d,f, marker = "40")
-        s3 = Segment(a,f, marker = "30")
-        s4 = Segment(a,e, marker = "20")
-     
-        r1 = Region(0.3, 0.3,tag = "1.3", maxArea = 36)
-
-
-        h1 = Hole(0.2,0.6)
-        
-        m = Mesh(userVertices=[a,d,f,e],
-                 userSegments=[s1,s2,s3,s4],
-                 regions=[r1],
-                 holes=[h1])
-
-        seg = m.getUserSegments()
-        points = m.getUserVertices()
-        holes = m.getHoles()
-        regions = m.getRegions()
-        fileName = tempfile.mktemp(".txt")
-        m.exportASCIImeshfile(fileName)
-        #print "***************************fileName", fileName
-        dict = import_mesh(fileName)
-        os.remove(fileName)
-
-        #print dict
-        
-        for pimport,pactual,pimpatt in map(None,dict['pointlist'],points,dict['pointattributelist']):
-            self.failUnless( pimport == [pactual.x,pactual.y],
-                        'loadASCIITestCase failed. test 1')
-            self.failUnless( pimpatt == pactual.attributes,
-                        'loadASCIITestCase failed. test 1.1')
-        self.failUnless( dict['segmentlist'][0] == [0,1],
-                        'loadASCIITestCase failed. test 3')
-        for segimp,segactual in map(None,dict['segmentmarkerlist'],seg):
-            self.failUnless( segimp == segactual.marker,
-                        'loadASCIITestCase failed. test 4')
-        for holeimp,holeactual in map(None,dict['holelist'],holes):
-            self.failUnless( holeimp == [holeactual.x,holeactual.y],
-                        'loadASCIITestCase failed. test 5')
-        for regimp,regactual,regattimp, regmaxarea in map(None,dict['regionlist'],regions, dict['regionattributelist'], dict['regionmaxarealist']):
-            self.failUnless( regimp == [regactual.x,regactual.y],
-                        'loadASCIITestCase failed. test 6')
-            self.failUnless( regattimp == regactual.getTag(),
+            self.failUnless( regattimp == regactual[2],
                         'loadASCIITestCase failed. test 7')
-            self.failUnless( regmaxarea == regactual.getMaxArea(),
+            self.failUnless( regmaxarea == regactual[3],
                         'loadASCIITestCase failed. test 7')
 
 
+        self.failUnless(array(loaded_dict['holelist'])  ==
+                        array(dict['holelist']),
+                         'test_import_mesh failed. Test 6')
+        
     def test_export_triangulation_file(self):
         import os
Index: /inundation/ga/storm_surge/pmesh/mesh.py
===================================================================
--- /inundation/ga/storm_surge/pmesh/mesh.py	(revision 934)
+++ /inundation/ga/storm_surge/pmesh/mesh.py	(revision 935)
@@ -802,5 +802,8 @@
         return deletedObs
                                                  
-    def Mesh2triangList(self):
+    def Mesh2triangList(self, userVertices=None,
+                        userSegments=None,
+                        holes=None,
+                        regions=None):
         """
         Convert the Mesh to a dictionary of the lists needed for the triang modul;
@@ -813,4 +816,13 @@
         """
         
+        if userVertices is None:
+            userVertices = self.getUserVertices()
+        if userSegments is None:
+            userSegments = self.getUserSegments()
+        if holes is None:
+            holes = self.getHoles()
+        if regions is None:
+            regions = self.getRegions()
+            
         meshDict = {}
         
@@ -818,5 +830,5 @@
         pointattributelist=[]
         index = 0
-        for vertex in self.userVertices:
+        for vertex in userVertices:
             vertex.index = index 
             pointlist.append((vertex.x,vertex.y))
@@ -829,16 +841,17 @@
         segmentlist=[]
         segmentmarkerlist=[]
-        for seg in self.getUserSegments():
+        for seg in userSegments:
             segmentlist.append((seg.vertices[0].index,seg.vertices[1].index))
             segmentmarkerlist.append(seg.marker)
         meshDict['segmentlist'] =segmentlist 
         meshDict['segmentmarkerlist'] =segmentmarkerlist
+        
         holelist=[]
-        for hole in self.holes:
+        for hole in holes:
             holelist.append((hole.x,hole.y)) 
         meshDict['holelist'] = holelist
         
         regionlist=[]
-        for region in self.regions:
+        for region in regions:
             if (region.getMaxArea() != None): 
                 regionlist.append((region.x,region.y,region.getTag(),
@@ -1511,5 +1524,6 @@
             #Most probably, the Tkinter module is not available.
             #"""
-      
+            
+    # Is this used by anything?  
     def exportASCIItriangulationfile(self,ofile):
         """
@@ -1545,5 +1559,4 @@
         meshDict['generatedsegmentlist'] = []
         meshDict['generatedsegmentmarkerlist'] = []
-
         meshDict['generatedtrianglelist'] = [] 
         meshDict['generatedtriangleattributelist'] = []
@@ -1636,76 +1649,13 @@
                        holes,
                        regions):
-        numVert = str(len(userVertices))
-        if (numVert == "0"):
-            numVertAttrib = "0"
-        else:
-            numVertAttrib = str(len(userVertices[0].attributes))
-        fd.write(numVert + " " + numVertAttrib + " # <# of verts> <# of vert attributes>, next lines <vertex #> <x> <y> [attributes] ...Mesh Vertices..." + "\n")
-        
-        # <x> <y> [attributes]
-        index = 0 
-        for vert in userVertices:
-            vert.index = index
-            index += 1
-            attlist = ""
-            for att in vert.attributes:
-                attlist = attlist + str(att)+" "
-            attlist.strip()
-            fd.write(str(vert.index) + " "
-                     +str(vert.x) + " "
-                     + str(vert.y) + " "
-                     + attlist + "\n")
-            
-        #One line:  <# of segments> 
-        fd.write(str(len(userSegments)) + 
-                 " # <# of segments>, next lines <segment #> <vertex #>  <vertex #> [boundary marker] ...Mesh Segments..." + "\n")
-        
-        #Following lines:  <vertex #>  <vertex #> [boundary marker]
-        index = 0
-        for seg in userSegments:
-            fd.write(str(index) + " "
-                     + str(seg.vertices[0].index) + " " 
-                     + str(seg.vertices[1].index) + " " 
-                     + str(seg.marker) + "\n")
-            index += 1
-
-        #One line:  <# of holes> 
-        fd.write(str(len(holes)) + 
-                 " # <# of holes>, next lines <Hole #> <x> <y> ...Mesh Holes..." + "\n")    
-        # <x> <y>
-        index = 0
-        for h in holes:
-            fd.write(str(index) + " "
-                     + str(h.x) + " "
-                     + str(h.y) + "\n")
-            index += 1
-        
-        #One line:  <# of regions> 
-        fd.write(str(len(regions)) + 
-                 " # <# of regions>, next lines <Region #> <x> <y> <tag>...Mesh Regions..." + "\n")    
-        # <index> <x> <y> <tag>
-        index = 0
-        for r in regions:
-            fd.write(str(index) + " " 
-                     + str(r.x) + " "
-                     + str(r.y)+ " "
-                     + str(r.getTag()) + "\n")
-            index += 1
-        index = 0
-        
-        # <index> [<MaxArea>|""]
-        
-        #One line:  <# of regions> 
-        fd.write(str(len(regions)) + 
-                 " # <# of regions>, next lines <Region #> [Max Area] ...Mesh Regions..." + "\n") 
-        for r in regions:
-            area = r.getMaxArea()
-            if area == None:
-                area = ""
-            else:
-                area = str(area)
-            
-            fd.write(str(index) + " " + area + "\n")
-            index += 1
+        
+        dict = self.Mesh2triangList(userVertices,
+                       userSegments,
+                       holes,
+                       regions)
+        #print "mesh*********"
+        #print "dict",dict 
+        #print "mesh*********"
+        load_mesh.loadASCII.write_ASCII_mesh(fd, dict)
                 
     def exportxyafile(self,ofile):
Index: /inundation/ga/storm_surge/pmesh/meshHarness.py
===================================================================
--- /inundation/ga/storm_surge/pmesh/meshHarness.py	(revision 934)
+++ /inundation/ga/storm_surge/pmesh/meshHarness.py	(revision 935)
@@ -759,5 +759,5 @@
         m_returned = importMeshFromFile(fileName)
 
-        #print "m_returned ****",m_returned
+        print "m_returned ****",m_returned
         #print "****************** fileName", fileName
         os.remove(fileName)
@@ -768,4 +768,5 @@
         m.meshSegments = []
         m.userVertices=[a,b,c]
+        print "mesh ***************dsg*", m
         #print "(m.__cmp__(m_returned)", m.__cmp__(m_returned) 
         self.failUnless(0 == m.__cmp__(m),
@@ -1050,9 +1051,67 @@
         self.failUnless(len(m.userVertices) == 11,
                         'Wrong vertex list length.')
+
+    def test_exportASCIImeshfile(self):
+    
+        a_att = [5,2]
+        d_att =[4,2]
+        f_att = [3,2]
+        e_att = [2,2]
+        a_xy = [0.0, 0.0]
+        a = Vertex ( a_xy[0],a_xy[1], attributes =a_att)
+        d = Vertex (0.0, 4.0, attributes =d_att)
+        f = Vertex (4.0,0.0, attributes =f_att)
+        e = Vertex (1.0,1.0, attributes =e_att)
+    
+        s1 = Segment(a,d, marker = "50")
+        s2 = Segment(d,f, marker = "40")
+        s3 = Segment(a,f, marker = "30")
+        s4 = Segment(a,e, marker = "20")
+     
+        r1 = Region(0.3, 0.3,tag = "1.3", maxArea = 36)
+
+
+        h1 = Hole(0.2,0.6)
+        
+        m = Mesh(userVertices=[a,d,f,e],
+                 userSegments=[s1,s2,s3,s4],
+                 regions=[r1],
+                 holes=[h1])
+
+        seg = m.getUserSegments()
+        points = m.getUserVertices()
+        holes = m.getHoles()
+        regions = m.getRegions()
+        fileName = tempfile.mktemp(".txt")
+        m.exportASCIImeshfile(fileName)
+        #print "***************************fileName", fileName
+        dict = import_mesh(fileName)
+        os.remove(fileName)
+
+        for pimport,pactual,pimpatt in map(None,dict['pointlist'],points,dict['pointattributelist']):
+            self.failUnless( pimport == [pactual.x,pactual.y],
+                        'loadASCIITestCase failed. test 1')
+            self.failUnless( pimpatt == pactual.attributes,
+                        'loadASCIITestCase failed. test 1.1')
+        self.failUnless( dict['segmentlist'][0] == [0,1],
+                        'loadASCIITestCase failed. test 3')
+        for segimp,segactual in map(None,dict['segmentmarkerlist'],seg):
+            self.failUnless( segimp == segactual.marker,
+                        'loadASCIITestCase failed. test 4')
+        for holeimp,holeactual in map(None,dict['holelist'],holes):
+            self.failUnless( holeimp == [holeactual.x,holeactual.y],
+                        'loadASCIITestCase failed. test 5')
+        for regimp,regactual,regattimp, regmaxarea in map(None,dict['regionlist'],regions, dict['regionattributelist'], dict['regionmaxarealist']):
+            self.failUnless( regimp == [regactual.x,regactual.y],
+                        'loadASCIITestCase failed. test 6')
+            self.failUnless( regattimp == regactual.getTag(),
+                        'loadASCIITestCase failed. test 7')
+            self.failUnless( regmaxarea == regactual.getMaxArea(),
+                        'loadASCIITestCase failed. test 7')
+
         
 #-------------------------------------------------------------
 if __name__ == "__main__":
     suite = unittest.makeSuite(meshTestCase,'test')
-    #suite = unittest.makeSuite(meshTestCase,'test_load') 
     #suite = unittest.makeSuite(meshTestCase,'test_import_mesh')
     runner = unittest.TextTestRunner() #verbosity=2)
