Index: /inundation/ga/storm_surge/pmesh/mesh.py
===================================================================
--- /inundation/ga/storm_surge/pmesh/mesh.py	(revision 987)
+++ /inundation/ga/storm_surge/pmesh/mesh.py	(revision 988)
@@ -1205,6 +1205,12 @@
         self.userSegments.extend(newsegs)
         return newsegs
-     
-    def autoSegment(self, alpha = None, boundary_type=REMOVE_PINCH_OFF): 
+    def autoSegmentFilter(self,):
+        pass
+    
+    def autoSegment(self, alpha = None,
+                                 raw_boundary=True,
+                                 remove_holes=False,
+                                 smooth_indents=False,
+                                 expand_pinch=False): 
         """
         Precon: There must be 3 or more vertices in the userVertices structure
@@ -1214,23 +1220,12 @@
         for vertex in self.getUserVertices():
             points.append((vertex.x,vertex.y))
-        shape = alpha_shape.alpha_shape.Alpha_Shape(points, alpha = alpha)
-        shape.set_boundary_type(flag = boundary_type)
-        boundary_segs = shape.get_boundary()
+        self.shape = alpha_shape.alpha_shape.Alpha_Shape(points, alpha = alpha)
+        self.shape.set_boundary_type(raw_boundary=raw_boundary,
+                                 remove_holes=remove_holes,
+                                 smooth_indents=smooth_indents,
+                                 expand_pinch=expand_pinch)
+        boundary_segs = self.shape.get_boundary()
 
         segs2delete = self.alphaUserSegments
-        #for neededseg in boundary_segs:
-        #    try:
-         #     segs2delete.remove(neededseg)
-         #     print "list delete",neededseg
-         #   except:
-         #       print "list don't delete",neededseg
-        #addback = []
-        #for delseg in segs2delete:
-        #    print "boundary_segs.count(delseg)",boundary_segs.count(delseg)
-        #    if boundary_segs.count(delseg) > 0:
-        #        #Don't delete this seg.  We need it for the new boundary
-        #        addback.append(delseg)
-        #for seg in addback:
-        #    segs2delete.remove(seg)
                 
         new_segs = []
@@ -1262,5 +1257,5 @@
         self.alphaUserSegments.extend(alpha_segs)
 
-        optimum_alpha = shape.get_alpha()
+        optimum_alpha = self.shape.get_alpha()
         # need to draw newsegs
         return new_segs, segs2delete, optimum_alpha
Index: /inundation/ga/storm_surge/pmesh/pmesh.py
===================================================================
--- /inundation/ga/storm_surge/pmesh/pmesh.py	(revision 987)
+++ /inundation/ga/storm_surge/pmesh/pmesh.py	(revision 988)
@@ -5,5 +5,5 @@
 from   tkSimpleDialog import Dialog
 import mesh
-from Tkinter import  FALSE,TRUE, Frame,X, LEFT,YES,BOTH,ALL,Widget,CURRENT, Label,W, Entry, E, StringVar, END, Checkbutton, Radiobutton, IntVar
+from Tkinter import  FALSE,TRUE, Frame,X, LEFT,YES,BOTH,ALL,Widget,CURRENT, Label,W, Entry, E, StringVar, END, Checkbutton, Radiobutton, IntVar, DISABLED, NORMAL
 #from cursornames import TLC,TRC, BLC, BRC, TS, RS, LS, BS
 from tkMessageBox import showerror, _show, QUESTION,YESNOCANCEL
@@ -130,4 +130,8 @@
                                  label='Auto segment',
                                  command=self.autoSegment)
+        self.menuBar.addmenuitem('File', 'command',
+                           'modify the alpha boundary by applying filters',
+                                 label='filter alpha boundary',
+                                 command=self.autoSegmentFilter)
         self.menuBar.addmenuitem('File', 'command', 'Normalise mesh',
                                  label='Normalise mesh', command=self.normaliseMesh)
@@ -628,13 +632,23 @@
             if dialog.alphaValueOk:
                 self.autoSegment(alpha = dialog.alpha,
-                                 boundary_type=dialog.boundary_type.get())
+                                 raw_boundary=dialog.raw_boundary.get(),
+                                 remove_holes=dialog.remove_holes.get(),
+                                 smooth_indents=dialog.smooth_indents.get(),
+                                 expand_pinch=dialog.expand_pinch.get())
             else:
                  showerror('pMesh',
                       'Bad alpha value.')
         else:
-            self.autoSegment(boundary_type=dialog.boundary_type.get())
+            self.autoSegment(raw_boundary=dialog.raw_boundary.get(),
+                             remove_holes=dialog.remove_holes.get(),
+                             smooth_indents=dialog.smooth_indents.get(),
+                             expand_pinch=dialog.expand_pinch.get())
            
         
-    def autoSegment (self, alpha = None, boundary_type=mesh.REMOVE_PINCH_OFF):
+    def autoSegment (self, alpha = None,
+                                 raw_boundary=True,
+                                 remove_holes=False,
+                                 smooth_indents=False,
+                                 expand_pinch=False ):
         """
         add Segments to bound all vertices
@@ -646,7 +660,11 @@
         if len(self.mesh.getUserVertices()) >= 3:
             if alpha == None:
-                newsegs, ObjectsToVisuallyDelete, self.meshLastAlpha = self.mesh.autoSegment(boundary_type=boundary_type)
+                newsegs, ObjectsToVisuallyDelete, self.meshLastAlpha = self.mesh.autoSegment(remove_holes=remove_holes,
+                                 smooth_indents=smooth_indents,
+                                 expand_pinch=expand_pinch)
             else:
-                newsegs, ObjectsToVisuallyDelete, self.meshLastAlpha = self.mesh.autoSegment(alpha=alpha,boundary_type=boundary_type)
+                newsegs, ObjectsToVisuallyDelete, self.meshLastAlpha = self.mesh.autoSegment(alpha=alpha, remove_holes=remove_holes,
+                                 smooth_indents=smooth_indents,
+                                 expand_pinch=expand_pinch)
                 
             #print "newsegs",newsegs
@@ -669,4 +687,8 @@
 
 
+    def autoSegmentFilter (self):
+        dialog = autoSegmentFilterDialog(self.canvas)
+        dialog.use_optimum.get() == SET_ALPHA
+        
     def joinVerticesButton (self, parent):
         self.joinVertices()
@@ -1439,4 +1461,89 @@
 
 class  AutoSegmentDialog(Dialog):
+    """
+    Dialog box for adding segments
+    """
+    def __init__(self, parent, alpha):
+        self.alpha = alpha
+        Dialog.__init__(self, parent)
+        
+    def body(self, master):
+        """
+        GUI description
+        """
+        self.title("Automatically Add Segments")
+
+        self.use_optimum = IntVar()
+        self.use_optimum.set(AUTO) # should initialise the radio buttons.
+                                   #  It doesn't
+                                   
+        #self.use_optimum.set(NO_SELECTION) 
+        self.ck = Radiobutton(master, value = AUTO, variable=self.use_optimum) 
+        self.ck.grid(row=1, column=0)
+        Label(master, text='Use optimum alpha').grid(row=1, column=1, sticky=W)
+
+        self.ck2 = Radiobutton(master, value = SET_ALPHA,
+                               variable=self.use_optimum) 
+        self.ck2.grid(row=2, column=0)
+        
+        Label(master, text='alpha:').grid(row=2, column=1, sticky=W)
+        if (self.alpha):
+            alphaVar = StringVar()
+            alphaVar.set(self.alpha)
+            self.alpha_str  = Entry(master,
+                                     textvariable = alphaVar,
+                                     width = 16, name ="entry") 
+        else: 
+            self.alpha_str = Entry(master, width = 16, name ="entry")
+        
+        self.alpha_str.grid(row=2, column=3, sticky=W)
+
+        #boundary type buttons
+        self.raw_boundary = IntVar()
+        self.remove_holes = IntVar()
+        self.smooth_indents = IntVar()
+        self.expand_pinch = IntVar()
+        self.ck3 = Checkbutton(master, state=NORMAL,
+                               variable=self.raw_boundary) 
+        self.ck3.grid(row=3, column=0)
+        Label(master, text='Raw boundary').grid(row=3, column=1, sticky=W)
+        #
+        self.ck4 = Checkbutton(master, state=NORMAL,
+                               variable=self.remove_holes) 
+        self.ck4.grid(row=4, column=0)
+        Label(master, text='Remove small holes').grid(row=4,column=1, sticky=W)
+        #
+        self.ck5 = Checkbutton(master,state=NORMAL,
+                               variable=self.smooth_indents) 
+        self.ck5.grid(row=5, column=0)
+        Label(master,
+              text='Remove sharp indents').grid(row=5, column=1, sticky=W)
+        #
+        self.ck6 = Checkbutton(master,state=NORMAL,
+                               variable=self.expand_pinch) 
+        self.ck6.grid(row=6, column=0)
+        Label(master,
+              text='Remove pinch off').grid(row=6, column=1,  sticky=W)
+
+        
+        self.alpha  = 0
+        self.alphaValueOk = False
+        
+
+    def apply(self):
+        """
+        check entered values
+        """
+        try:
+            self.alpha = float(self.alpha_str.get())
+            self.alphaValueOk = True
+            
+        except ValueError:
+            pass
+            #showerror('Bad Alpha value',
+            #                       'Alpha is negative.')
+
+
+class  AutoSegmentFilterDialog(Dialog):
     """
     Dialog box for adding segments
@@ -1525,4 +1632,5 @@
 
 
+
 class  MeshGenDialog(Dialog):
     """
