Bug with wire not well designed generating unlimited loop fixed
authorlaurent
Thu, 27 Aug 2009 16:29:23 +0200
changeset 398 c215899298c7
parent 397 ea47ebbe23b7
child 399 3b9e0b092298
Bug with wire not well designed generating unlimited loop fixed
graphics/GraphicCommons.py
--- a/graphics/GraphicCommons.py	Wed Aug 26 20:24:45 2009 +0200
+++ b/graphics/GraphicCommons.py	Thu Aug 27 16:29:23 2009 +0200
@@ -1930,15 +1930,21 @@
             self.Segments = []
             i = 0
             while i < len(self.Points) - 1:
-                segment = vector(self.Points[i], self.Points[i + 1])
-                if is_null_vector(segment) and i > 0:
-                    segment = (self.Segments[-1][1], self.Segments[-1][0])
-                if i < len(self.Points) - 2:
-                    next = vector(self.Points[i + 1], self.Points[i + 2])
-                    if next == segment or is_null_vector(add_vectors(segment, next)):
-                        self.Points.insert(i + 1, wx.Point(self.Points[i + 1].x, self.Points[i + 1].y))
-                self.Segments.append(segment)
-                i += 1
+                if 0 < i < len(self.Points) - 2 and \
+                   self.Points[i] == self.Points[i + 1] and \
+                   self.Segments[-1] == vector(self.Points[i + 1], self.Points[i + 2]):
+                    for j in xrange(2):
+                        self.Points.pop(i)
+                else:
+                    segment = vector(self.Points[i], self.Points[i + 1])
+                    if is_null_vector(segment) and i > 0:
+                        segment = (self.Segments[-1][1], self.Segments[-1][0])
+                    if i < len(self.Points) - 2:
+                        next = vector(self.Points[i + 1], self.Points[i + 2])
+                        if next == segment or is_null_vector(add_vectors(segment, next)):
+                            self.Points.insert(i + 1, wx.Point(self.Points[i + 1].x, self.Points[i + 1].y))
+                    self.Segments.append(segment)
+                    i += 1
             self.RefreshBoundingBox()
             self.RefreshRealPoints()