Index: /inundation/ga/storm_surge/pmesh/mesh.py
===================================================================
--- /inundation/ga/storm_surge/pmesh/mesh.py	(revision 1176)
+++ /inundation/ga/storm_surge/pmesh/mesh.py	(revision 1177)
@@ -2119,6 +2119,5 @@
 
 
-    def weed(self):
-        #FIXME - for backwards compatibility.
+    def weed(self,Vertices,Segments):
         #weed out existing duplicates
         print 'len(self.getUserSegments())'
@@ -2128,9 +2127,42 @@
 
         point_keys = {}
+        for vertex in Vertices:
+            point = (vertex.x,vertex.y)
+            point_keys[point]=vertex
+
+        line_keys = {}
+        for segment in Segments:
+            vertex1 = segment.vertices[0]
+            vertex2 = segment.vertices[1]
+            point1 = (vertex1.x,vertex1.y)
+            point2 = (vertex2.x,vertex2.y)
+            segment.vertices[0]=point_keys[point1]
+            segment.vertices[1]=point_keys[point2]
+            vertex1 = segment.vertices[0]
+            vertex2 = segment.vertices[1]
+            point1 = (vertex1.x,vertex1.y)
+            point2 = (vertex2.x,vertex2.y)
+            line1 = (point1,point2)
+            line2 = (point2,point1)
+            if not (line_keys.has_key(line1) \
+                 or line_keys.has_key(line2)):
+                 line_keys[line1]=segment
+        Vertices=point_keys.values()
+        Segments=line_keys.values()
+        return Vertices,Segments
+
+    def triangles_to_polySet(self,setName):
+        #turn the triangles into a set
+        Triangles = self.sets[self.setID[setName]]
+        Triangles_dict = {}
+        for triangle in Triangles:
+            Triangles_dict[triangle]=None
+
+        userVertices = {}
+        userSegments = []
+        point_keys = {}
         for vertex in self.getUserVertices():
             point = (vertex.x,vertex.y)
-            if point_keys.has_key(point):
-                self.userVertices.remove(vertex)
-            else: point_keys[point]=vertex
+            point_keys[point]=vertex
 
         line_keys = {}
@@ -2140,42 +2172,16 @@
             point1 = (vertex1.x,vertex1.y)
             point2 = (vertex2.x,vertex2.y)
-            segment.vertices[0]=point_keys[point1]
-            segment.vertices[1]=point_keys[point2]
+            #segment.vertices[0]=point_keys[point1]
+            #segment.vertices[1]=point_keys[point2]
+            #vertex1 = segment.vertices[0]
+            #vertex2 = segment.vertices[1]
+            #point1 = (vertex1.x,vertex1.y)
+            #point2 = (vertex2.x,vertex2.y)
             line1 = (point1,point2)
             line2 = (point2,point1)
-            if line_keys.has_key(line1) or line_keys.has_key(line2):
-                self.userSegments.remove(segment)
-            else: line_keys[line1]=None
-        #end backward-compatibility stuff
-
-    def triangles_to_polySet(self,setName):
-        ##
-        #self.weed()#FIXME for back-compatibilty - delete sometime
-        ##
-
-
-        #build a set of existing segments
-        line_keys = {}
-        for segment in self.getUserSegments():
-            vertex1 = segment.vertices[0]
-            vertex2 = segment.vertices[1]
-            line = ((vertex1.x,vertex1.y),(vertex2.x,vertex2.y))
-            line_keys[line]=None
-
-        #build a set of existing vertexes
-        point_keys = {}
-        for vertex in self.getUserVertices():
-            point = (vertex.x,vertex.y)
-            point_keys[point]=vertex
-
-        #turn the triangles into a set
-        Triangles = self.sets[self.setID[setName]]
-        Triangles_dict = {}
-        for triangle in Triangles:
-            Triangles_dict[triangle]=None
-
-        userVertices = {}
-        userSegments = []
-        index = 0
+            if not (line_keys.has_key(line1) \
+                 or line_keys.has_key(line2)):
+                 line_keys[line1]=segment
+
         for triangle in Triangles:
             for i in (0,1,2):
@@ -2191,5 +2197,7 @@
                         userVertices[a]=True
                         point_keys[(a.x,a.y)]=a
-                    else: userVertices[a]=point_keys[(a.x,a.y)]
+                    else: 
+                        a=point_keys[(a.x,a.y)]
+                        userVertices[a]=point_keys[(a.x,a.y)]
                     assert userVertices.has_key(a)
 
@@ -2199,5 +2207,7 @@
                         userVertices[b]=True
                         point_keys[(b.x,b.y)]=b
-                    else: userVertices[b]=point_keys[(b.x,b.y)]
+                    else: 
+                        b=point_keys[(b.x,b.y)]
+                        userVertices[b]=point_keys[(b.x,b.y)]
                     assert userVertices.has_key(b)  
 
@@ -2208,8 +2218,12 @@
                         assert ((a.x,a.y)!=(b.x,b.y))
                         assert a!=b
-                        userSegments.append((a,b))
+                        userSegments.append(Segment(a,b))
                         line_keys[((a.x,a.y),(b.x,b.y))]=None
 
-        return userVertices, userSegments
+        userVertices,userSegments = self.weed(userVertices.keys(),userSegments)
+        self.userVertices.extend(userVertices)
+        self.userSegments.extend(userSegments)
+        self.userVertices,self.userSegments = \
+           self.weed(self.userVertices,self.userSegments)
 
     def threshold(self,setName,min=None,max=None,attribute_name = 'elevation'):
Index: /inundation/ga/storm_surge/pmesh/pmesh.py
===================================================================
--- /inundation/ga/storm_surge/pmesh/pmesh.py	(revision 1176)
+++ /inundation/ga/storm_surge/pmesh/pmesh.py	(revision 1177)
@@ -339,19 +339,21 @@
 
     def triangles_to_polySet(self,parent):
-        vertices, segments = self.mesh.triangles_to_polySet(self.selSet)
-        event = None
-        for v in vertices.keys():
-            if vertices[v] is True:
-                x = v.x*self.SCALE
-                y = v.y*self.SCALE
-                vertices[v]=self.drawVertex(x,y,event)
-        print 'segments'
-        print segments
-        print 'vertices.keys()'
-        print vertices.keys()
-        for s in segments:
-            v0 = vertices[s[0]]
-            v1 = vertices[s[1]]
-            self.drawSegment(v0,v1)
+        self.mesh.triangles_to_polySet(self.selSet)
+        #event = None
+        #for v in vertices.keys():
+        #    if vertices[v] is True:
+        #        x = v.x*self.SCALE
+        #        y = v.y*self.SCALE
+        #        vertices[v]=self.drawVertex(x,y,event)
+        #print 'segments'
+        #print segments
+        #print 'vertices.keys()'
+        #print vertices.keys()
+        #for s in segments:
+        #    v0 = vertices[s[0]]
+        #    v1 = vertices[s[1]]
+        #    self.drawSegment(v0,v1)
+        self.canvas.delete(ALL)
+        self.visualiseMesh(self.mesh)
 
     def selectTriangles(self,setName):
