diff options
author | Marius Kintel <marius@kintel.net> | 2011-09-06 13:47:21 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2011-09-06 13:47:21 (GMT) |
commit | f0bd1eed9746e0349700c969292c9eeca58c5635 (patch) | |
tree | 4fb5e2c627f6b2ed01bd9505c05985d87d91dee6 /src | |
parent | aa3ac2d3000b0fbf5ec5e8d0ecaaaedf44678dc2 (diff) |
Fixes crash bug reported by Brad Pitcher
Diffstat (limited to 'src')
-rw-r--r-- | src/polyset.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/polyset.cc b/src/polyset.cc index e34aeb3..9601fef 100644 --- a/src/polyset.cc +++ b/src/polyset.cc @@ -518,7 +518,13 @@ CGAL_Nef_polyhedron PolySet::render_cgal_nef_polyhedron() const double x = ps->polygons[i][j].x; double y = ps->polygons[i][j].y; if (this->grid.has(x, y)) { - this->polygons[this->poly_n].append(this->grid.data(x, y)); + int idx = this->grid.data(x, y); + // Filter away two vertices with the same index (due to grid) + // This could be done in a more general way, but we'd rather redo the entire + // grid concept instead. + if (this->polygons[this->poly_n].indexOf(idx) == -1) { + this->polygons[this->poly_n].append(this->grid.data(x, y)); + } } else { this->grid.align(x, y) = point_n; this->polygons[this->poly_n].append(point_n); @@ -526,8 +532,13 @@ CGAL_Nef_polyhedron PolySet::render_cgal_nef_polyhedron() const point_n++; } } - add_edges(this->poly_n); - this->poly_n++; + if (this->polygons[this->poly_n].size() >= 3) { + add_edges(this->poly_n); + this->poly_n++; + } + else { + this->polygons.remove(this->poly_n); + } } } |