Index: /inundation/ga/storm_surge/pmesh/mesh.py
===================================================================
--- /inundation/ga/storm_surge/pmesh/mesh.py	(revision 678)
+++ /inundation/ga/storm_surge/pmesh/mesh.py	(revision 679)
@@ -15,4 +15,5 @@
 
 import load_mesh.loadASCII
+import alpha_shape.alpha_shape
 
 import sys
@@ -28,5 +29,5 @@
 # 1st and third values must be the same
 #initialconversions = ['internal', 'external','internal']
-# FIXME: maybe make this a switch that the user can change?
+# FIXME: maybe make this a switch that the user can change? - DSG
 initialconversions = ['', 'external','']
 
@@ -137,4 +138,6 @@
                                        outline=colour,
                                        fill = 'white')
+    
+        #return tags
      
     def __repr__(self):
@@ -1012,5 +1015,5 @@
         fd.close()
 
-    def autoSegment(self):
+    def autoSegmentHull(self):
         """
         initially work by running an executable
@@ -1030,11 +1033,4 @@
             fd.write('\n')
         fd.close()
-
-        # os.system('SET PATH=..\pmesh;%PATH%') # this doesn't work
-        #print "os.getcwd()",os.getcwd()    # this could be usefull
-        #command = "k:\\EQRMsens\\" + s
-        #os.chdir(command)
-        #command = 'env'
-        #os.system(command)
         
         #run hull executable
@@ -1063,4 +1059,28 @@
                 newseg = Segment(v1, v2)
                 newsegs.append(newseg)
+        self.userSegments.extend(newsegs)
+        return newsegs
+     
+    def autoSegment(self):
+        """
+
+        Precon: There must be 3 or more vertices in the userVertices structure
+        """
+
+        
+        points=[]
+        for vertex in self.getUserVertices():
+            points.append((vertex.x,vertex.y))
+            
+        shape = alpha_shape.alpha_shape.Alpha_Shape(points)
+        boundary_segs = shape.get_boundary()
+
+        newsegs = []
+        for seg in boundary_segs:
+            v1 = self.userVertices[int(seg[0])]
+            v2 = self.userVertices[int(seg[1])]
+            if self.isUserSegmentNew(v1, v2):
+                unique_seg = Segment(v1, v2)
+                newsegs.append(unique_seg)
         self.userSegments.extend(newsegs)
         return newsegs
@@ -1479,5 +1499,10 @@
             index += 1
         index = 0
+        
         # <index> [<MaxArea>|""]
+        
+        #One line:  <# of regions> 
+        fd.write(str(len(regions)) + 
+                 " # <Region #> [Max Area] ...Mesh Regions..." + "\n") 
         for r in regions:
             area = r.getMaxArea()
@@ -1635,5 +1660,5 @@
     
 def square_outline(side_length = 1,up = "top", left = "left", right = "right",
-                   down = "bottom"):
+                   down = "bottom", regions = False):
     
         a = Vertex (0,0)
@@ -1646,7 +1671,25 @@
         s4 = Segment(d,c, marker = right)
         s5 = Segment(a,c, marker = down)
+
+        if regions:
+            e =  Vertex (side_length/2,side_length/2)
+            s6 = Segment(a,e, marker = down + left)
+            s7 = Segment(b,e, marker = up + left)
+            s8 = Segment(c,e, marker = down + right)
+            s9 = Segment(d,e, marker = up + right)
+            r1 = Region(side_length/2,3.*side_length/4, tag = up)
+            r2 = Region(1.*side_length/4,side_length/2, tag = left)
+            r3 = Region(3.*side_length/4,side_length/2, tag = right)
+            r4 = Region(side_length/2,1.*side_length/4, tag = down)
+            mesh = Mesh(userVertices=[a,b,c,d,e],
+                        userSegments=[s2,s3,s4,s5,s6,s7,s8,s9],
+                        regions = [r1,r2,r3,r4])
+        else:
+            mesh = Mesh(userVertices=[a,b,c,d],
+                 userSegments=[s2,s3,s4,s5])
      
-        return Mesh(userVertices=[a,b,c,d],
-                 userSegments=[s2,s3,s4,s5]) 
+        return mesh
+
+    
 
 def region_strings2ints(region_list):
Index: /inundation/ga/storm_surge/pmesh/pmesh.py
===================================================================
--- /inundation/ga/storm_surge/pmesh/pmesh.py	(revision 678)
+++ /inundation/ga/storm_surge/pmesh/pmesh.py	(revision 679)
@@ -187,4 +187,5 @@
                 ('default', self.windowDefault, 'set default value for selected mode'),
                 ('joinVer', self.joinVerticesButton, 'add Segments to connect all vertices'),      
+                ('autoSegHull', self.autoSegmentHullButton, 'add Segments to form alpha shape, using Hull'),  
                 ('autoSeg', self.autoSegmentButton, 'add Segments to form alpha shape'),
                 ('meshGen', self.windowMeshGen, 'Generate Mesh')]:
@@ -339,4 +340,28 @@
     
     
+    def autoSegmentHullButton (self, parent):
+        self.autoSegment()
+  
+    def autoSegmentHull (self):
+        """
+        add Segments to bound all vertices
+        
+        the parent attribute isn't used by this function.
+        need to userstand toolbarbutton.py to know how to
+        get rid of it.
+        """
+        if len(self.mesh.getUserVertices()) >= 3:
+            newsegs = self.mesh.autoSegment()
+            for segment in newsegs:
+                self.serial +=1
+                self.uniqueID = 'M*%d' % self.serial
+                self.Segments.visualise(segment,
+                                        self.uniqueID,
+                                        self.canvas,
+                                        self.SCALE)
+        else:
+            showerror('pMesh',
+                      'Three or more vetices are needed to be able to autosegment.')
+  
     def autoSegmentButton (self, parent):
         self.autoSegment()
