Index: /inundation/ga/storm_surge/pmesh/mesh.py
===================================================================
--- /inundation/ga/storm_surge/pmesh/mesh.py	(revision 403)
+++ /inundation/ga/storm_surge/pmesh/mesh.py	(revision 404)
@@ -3,4 +3,10 @@
 """General 2D triangular classes for triangular mesh generation.
 
+   Note: A .index attribute is added to objects such as vertices and
+   segments, often when reading and writing to files.  This information
+   should not be used as percistant information.  It is not the 'index' of
+   an element in a list.
+
+   
    Copyright 2003/2004
    Ole Nielsen, Stephen Roberts, Duncan Gray, Christopher Zoppou
@@ -346,4 +352,5 @@
 
 Segment.set_default_tag("")       
+
 class Mesh:
     """
@@ -548,5 +555,4 @@
         self.userSegments.append(s)
         return s
-
     
     def clearTriangulation(self):
@@ -690,6 +696,6 @@
         pointlist=[]
         pointattributelist=[]
+        
         index = 0
-
         for vertex in self.userVertices:
             vertex.index = index 
@@ -904,17 +910,17 @@
         #print "@#@#@#"
         
-        index = 0
+        #index = 0
         for point in genDict['pointlist']:
             v=Vertex(point[0], point[1])
-            v.index = index
-            index +=1
+            #v.index = index
+            #index +=1
             self.userVertices.append(v)
 
-        index = 0
+        #index = 0
         for seg,marker in map(None,genDict['segmentlist'],genDict['segmentmarkerlist']):
             segObject = Segment( self.userVertices[seg[0]],
                            self.userVertices[seg[1]], marker = marker )
-            segObject.index = index
-            index +=1
+            #segObject.index = index
+            #index +=1
             self.userSegments.append(segObject)
 
@@ -929,12 +935,12 @@
 #            index += 1
         
-        index = 0
+        #index = 0
         for point in genDict['holelist']:
             h=Hole(point[0], point[1])
-            h.index = index
-            index +=1
+            #h.index = index
+            #index +=1
             self.holes.append(h)
 
-        index = 0
+        #index = 0
         for reg,att,maxArea in map(None,
                                    genDict['regionlist'],
@@ -945,8 +951,36 @@
                              tag = att,
                              maxArea = maxArea)
-            Object.index = index
-            index +=1
+            #Object.index = index
+            #index +=1
             self.regions.append(Object)
-
+        
+    def addVertsSegs(self, outlineDict):
+        """
+        Add out-line (user Mesh) attributes given a dictionary of the lists
+        point list: [(x1,y1),(x2,y2),...] (Tuples of doubles)  
+        segment list: [(point1,point2),(p3,p4),...] (Tuples of integers)
+        #segment marker list: [S1Marker, S2Marker, ...] (list of ints)
+        """
+
+        print "@#@#@#"
+        print outlineDict
+        print "@#@#@#"
+
+        localUserVertices = []
+        #index = 0
+        for point in outlineDict['pointlist']:
+            v=Vertex(point[0], point[1])
+            #v.index = index
+            #index +=1
+            self.userVertices.append(v)
+            localUserVertices.append(v)
+            
+        #index = 0
+        for seg in map(None,outlineDict['segmentlist']):
+            segObject = Segment( localUserVertices[seg[0]],
+                           localUserVertices[seg[1]] )
+            #segObject.index = index
+            #index +=1
+            self.userSegments.append(segObject)
         
     def TestautoSegment(self):
@@ -1485,5 +1519,73 @@
 
         load_mesh.loadASCII.export_xya_file(ofile, xya_dict, title, delimiter = " ")
-
+        
+def importUngenerateFile(ofile):
+    """
+    import a file, ofile, with the format
+    [poly]
+    poly format:
+    First line:  <# of vertices> <x centroid> <y centroid>
+    Following lines: <x> <y> 
+    last line:  "END"
+    """
+    fd = open(ofile,'r')
+    Dict = readUngenerateFile(fd)
+    fd.close()
+    return Dict
+
+def readUngenerateFile(fd):
+    """
+    import a file, ofile, with the format
+    [poly]
+    poly format:
+    First line:  <# of polynomial> <x centroid> <y centroid>
+    Following lines: <x> <y> 
+    last line:  "END"
+    """
+    END_DELIMITER = 'END\n'
+    
+    points = []
+    segments = []
+    
+    isEnd = False
+    line = fd.readline() #not used <# of polynomial> <x> <y>
+    while not isEnd:
+        line = fd.readline()
+        fragments = line.split()
+        vert = [float(fragments.pop(0)),float(fragments.pop(0))]
+        points.append(vert)
+        PreviousVertIndex = len(points)-1
+        firstVertIndex = PreviousVertIndex
+        
+        line = fd.readline() #Read the next line
+        while line <> END_DELIMITER: 
+            #print "line >" + line + "<"
+            fragments = line.split()
+            vert = [float(fragments.pop(0)),float(fragments.pop(0))]
+            points.append(vert)
+            ThisVertIndex = len(points)-1
+            segment = [PreviousVertIndex,ThisVertIndex]
+            segments.append(segment)
+            PreviousVertIndex = ThisVertIndex
+            line = fd.readline() #Read the next line
+            i =+ 1
+        # Remove the last segment and the last vertex
+        # then add a segment from the second last vert to the 1st vert
+        points.pop()
+        segments.pop()
+        ThisVertIndex = len(points)-1
+        segments.append([ThisVertIndex, firstVertIndex])
+        
+        line = fd.readline() # read <# of polynomial> <x> <y> OR END
+        #print "line >>" + line + "<<"
+        if line == END_DELIMITER:
+            isEnd = True
+    
+    #print "points", points       
+    #print "segments", segments
+    ungenerated_dict = {}
+    ungenerated_dict['pointlist'] = points
+    ungenerated_dict['segmentlist'] = segments
+    return ungenerated_dict
 
 def importMeshFromFile(ofile):
@@ -1695,27 +1797,8 @@
 
 if __name__ == "__main__":
-# THIS CAN BE DELETED
-    list = ["internal boundary","sea","river inlet",
-            "","sea","","moat","internal boundary"]
-    #list = ["sea","river inlet","","sea","","moat"]
-    list = []
-    print list
-    preset = [""]
-    print preset
-    [intlist, converter] = segment_strings2ints(list, preset)
-    print "intlist",intlist
-    print "converter",converter
-    newlist = segment_ints2strings(intlist, converter)
-    print newlist 
-    print "***************************"
-    list = [(4,5,"lo"),(3,2,"mo"),(3,2,"ro")]
-    #list = []
-    print "list",list
-    [newlist, converter] = region_strings2ints(list)
-    print "newlist",newlist
-    trilist = []
-    for x in newlist:
-        trilist.append([x[2]])
-        print "trilist",trilist
-    oldlist = region_ints2strings(trilist, converter)  
-    print "oldlist",oldlist   
+    #from mesh import *
+    # THIS CAN BE DELETED
+    m = Mesh()
+    dict = importUngenerateFile("ungen_test.txt")
+    m.addVertsSegs(dict)
+    print m
Index: /inundation/ga/storm_surge/pmesh/pmesh.py
===================================================================
--- /inundation/ga/storm_surge/pmesh/pmesh.py	(revision 403)
+++ /inundation/ga/storm_surge/pmesh/pmesh.py	(revision 404)
@@ -100,6 +100,11 @@
         self.menuBar.addmenuitem('File', 'separator')
         self.menuBar.addmenuitem('File', 'command',
+                                 'Add ungenerated file from arcGIS',
+                                 label='Add ungenerated file...',
+                                 command=self.ImportUngenerate)
+        
+        self.menuBar.addmenuitem('File', 'command',
                                  'Export ASCII obj',
-                                 label='Export ASCII obj...',
+                                 label='Export ASCII obj',
                                  command=self.exportObj)
         
@@ -123,7 +128,7 @@
                                  command=self.autoSegment)
         self.menuBar.addmenuitem('File', 'command', 'Normalise mesh',
-                                 label='Normalise mesh...', command=self.normaliseMesh)
+                                 label='Normalise mesh', command=self.normaliseMesh)
         self.menuBar.addmenuitem('File', 'command', 'Normalise mesh for glutobj',
-                                 label='Normalise mesh for glutobj...', command=self.normalise4ObjMesh)
+                                 label='Normalise mesh for glutobj', command=self.normalise4ObjMesh)
         self.menuBar.addmenuitem('File', 'separator')
         self.menuBar.addmenuitem('File', 'command', 'Exit program',
@@ -150,9 +155,9 @@
             t.cycle("DrawMode")
             if key == 'pointer': #FIXME - this is specified in line 925 as well
-                self.curFunc     = self.drawVertex
+                self.curFunc  = self.drawVertex
                 t.setInitialSunkenButton("DrawMode")
-            self.modeClass[key]  = Mode
+            self.modeClass[key] = Mode
             # for actions that occur when the mouse goes down
-            self.mouseDownFunc[key] =mouseDownFunc
+            self.mouseDownFunc[key] = mouseDownFunc
          
     def createZooms(self):
@@ -752,6 +757,35 @@
                                    'No triangulation to export.')
 
-                
-    
+    
+
+    def ImportUngenerate(self):
+        ofile = tkFileDialog.askopenfilename(initialdir=self.currentPath,
+                                             filetypes=[ ("ungenerated polygon information", "txt"),
+                                           ("All Files", "*")])
+        if ofile == "":
+            # The user cancelled the loading action
+            return
+        
+        try:
+            self.clearSelections()
+            self.canvas.delete(ALL)
+            dict = mesh.importUngenerateFile(ofile)
+            self.mesh.addVertsSegs(dict)
+            
+        except SyntaxError: 
+            #this is assuming that the SyntaxError is thrown in
+            #loadxyafile
+            showerror('File error',
+                      ofile + ' is not in the correct format.')
+        except IOError: 
+            #!!! this error type can not be thrown?
+            showerror('File error',
+                      'file ' + ofile + ' could not be found.')
+        except RuntimeError: 
+            showerror('File error',
+                  'file ' + ofile + ' has an unknown file type.')
+    
+        self.visualiseMesh(self.mesh)
+        
     def exportASCIIsegmentoutlinefile(self):
         fileType = "tsh"
