#1867 Fixed problem with vertices having an evil, downscaled-to-float, twin, if a polyhedron contains occasional non-planar polygons

This commit is contained in:
Marius Kintel 2016-11-17 13:24:31 -05:00
parent c5821c924e
commit 684d283b1e
5 changed files with 35 additions and 13 deletions

View file

@ -55,15 +55,11 @@ namespace PolysetUtils {
Reindexer<Vector3f> allVertices;
std::vector<std::vector<IndexedFace>> polygons;
for(const auto &pgon : inps.polygons) {
for (const auto &pgon : inps.polygons) {
if (pgon.size() < 3) {
degeneratePolygons++;
continue;
}
if (pgon.size() == 3) { // Short-circuit
outps.append_poly(pgon);
continue;
}
polygons.push_back(std::vector<IndexedFace>());
std::vector<IndexedFace> &faces = polygons.back();
@ -86,18 +82,19 @@ namespace PolysetUtils {
std::vector<IndexedTriangle> allTriangles;
for(const auto &faces : polygons) {
std::vector<IndexedTriangle> triangles;
bool err = false;
if (faces[0].size() == 3) {
triangles.push_back(IndexedTriangle(faces[0][0], faces[0][1], faces[0][2]));
}
else {
bool err = GeometryUtils::tessellatePolygonWithHoles(verts, faces, triangles, NULL);
if (!err) {
for(const auto &t : triangles) {
outps.append_poly();
outps.append_vertex(verts[t[0]]);
outps.append_vertex(verts[t[1]]);
outps.append_vertex(verts[t[2]]);
}
err = GeometryUtils::tessellatePolygonWithHoles(verts, faces, triangles, NULL);
}
if (!err) {
for(const auto &t : triangles) {
outps.append_poly();
outps.append_vertex(verts[t[0]]);
outps.append_vertex(verts[t[1]]);
outps.append_vertex(verts[t[2]]);
}
}
}

25
testdata/scad/3D/issues/issue1867.scad vendored Normal file
View file

@ -0,0 +1,25 @@
polyhedron(points = [
[78.1831, 62.349, 10],
[97.4928, -22.2521, -5],
[-97.4928, -22.2521, 5],
[-78.1831, 62.349, -10],
[78.1831, 62.349, 200],
[97.4928, -22.2521, 200],
[-97.4928, -22.2521, 200],
[-78.1831, 62.349, 200]
],
faces = [
[0, 1, 4],
[1, 2, 5],
[2, 3, 6],
[3, 0, 7],
[5, 4, 1],
[6, 5, 2],
[7, 6, 3],
[4, 7, 0],
[4, 5, 6],
[4, 6, 7],
[3, 2, 1, 0],
]);

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB