Skip to content

Commit

Permalink
Fix T44567: inset polygon added crash
Browse files Browse the repository at this point in the history
Crash caused by some vertices in the input model being doubled.
The code to test for the maximum inset deduped the vertices
but the faces were not remapped. Fixed by having that test code
not dedup the vertices.
  • Loading branch information
howardt committed May 1, 2015
1 parent 922272e commit 44153e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions mesh_inset/geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ def Quantize(p):

return tuple([int(round(v * INVDISTTOL)) for v in p])

def AddPoint(self, p):
def AddPoint(self, p, allowdups = False):
"""Add point p to the Points set and return vertex number.
If there is an existing point which quantizes the same,,
don't add a new one but instead return existing index.
Except if allowdups is True, don't do that deduping.
Args:
p: tuple of float - coordinates (2-tuple or 3-tuple)
Expand All @@ -80,14 +81,14 @@ def AddPoint(self, p):
"""

qp = Points.Quantize(p)
if qp in self.invmap:
if qp in self.invmap and not allowdups:
return self.invmap[qp]
else:
self.invmap[qp] = len(self.pos)
self.pos.append(p)
return len(self.pos) - 1

def AddPoints(self, points):
def AddPoints(self, points, allowdups = False):
"""Add another set of points to this set.
We need to return a mapping from indices
Expand All @@ -102,7 +103,7 @@ def AddPoints(self, points):

vmap = [0] * len(points.pos)
for i in range(len(points.pos)):
vmap[i] = self.AddPoint(points.pos[i])
vmap[i] = self.AddPoint(points.pos[i], allowdups)
return vmap

def AddZCoord(self, z):
Expand Down
2 changes: 1 addition & 1 deletion mesh_inset/offset.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def MaxAmount(self):
# so don't add points that won't be used when
# really do a Build with a smaller amount
test_points = geom.Points()
test_points.AddPoints(self.polyarea.points)
test_points.AddPoints(self.polyarea.points, True)
save_points = self.polyarea.points
self.polyarea.points = test_points
self.Build()
Expand Down

0 comments on commit 44153e0

Please sign in to comment.