Commit 69af98d6 authored by sumpfralle's avatar sumpfralle

ContourModel now uses line_groups internally


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@377 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 9d34e641
...@@ -174,14 +174,29 @@ class ContourModel(BaseModel): ...@@ -174,14 +174,29 @@ class ContourModel(BaseModel):
def __init__(self): def __init__(self):
super(ContourModel, self).__init__() super(ContourModel, self).__init__()
self.name = "contourmodel%d" % self.id self.name = "contourmodel%d" % self.id
self._lines = [] self._line_groups = []
self._item_groups.append(self._lines) self._item_groups.append(self._lines)
_lines = property(lambda self: sum(self._line_groups, []))
def append(self, item): def append(self, item):
super(ContourModel, self).append(item) super(ContourModel, self).append(item)
if isinstance(item, Line): if isinstance(item, Line):
self._lines.append(item) for line_group in self._line_groups:
if item.p2 == line_group[0].p1:
# the line fits to the start of this group
line_group.insert(0, item)
break
elif item.p1 == line_group[-1].p2:
# the line fits to the end of this group
line_group.append(item)
break
else:
# add a new group with this single item
self._line_groups.append([item])
def get_lines(self): def get_lines(self):
return self._lines[:] return self._lines
def get_line_groups(self):
return self._line_groups
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment