diff options
author | Howard Trickey <howard.trickey@gmail.com> | 2015-05-01 14:53:07 +0300 |
---|---|---|
committer | Howard Trickey <howard.trickey@gmail.com> | 2015-05-01 14:53:07 +0300 |
commit | 44153e0c67f7ccbe3091215875c7f127ec847f1f (patch) | |
tree | 4b91a1fe3d4aa41dd36727ac856b27b87f74d385 /mesh_inset | |
parent | 922272e6bed1829df4b71fa731aa40ddb3e39655 (diff) |
Fix T44567: inset polygon added crash
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.
Diffstat (limited to 'mesh_inset')
-rw-r--r-- | mesh_inset/geom.py | 9 | ||||
-rw-r--r-- | mesh_inset/offset.py | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/mesh_inset/geom.py b/mesh_inset/geom.py index a7eb4fed..dce2a818 100644 --- a/mesh_inset/geom.py +++ b/mesh_inset/geom.py @@ -67,11 +67,12 @@ class Points(object): 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) @@ -80,14 +81,14 @@ class Points(object): """ 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 @@ -102,7 +103,7 @@ class Points(object): 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): diff --git a/mesh_inset/offset.py b/mesh_inset/offset.py index 4e860b67..3c6a7c76 100644 --- a/mesh_inset/offset.py +++ b/mesh_inset/offset.py @@ -706,7 +706,7 @@ class Offset(object): # 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() |