Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add manifold corner case tests #5013

Merged
merged 9 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 46 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,52 @@ add_cmdline_test(offcgalpngtest SCRIPT ${EX_IM_PNGTEST_PY} ARGS ${OPENSCA
add_cmdline_test(dxfpngtest SCRIPT ${EX_IM_PNGTEST_PY} ARGS ${OPENSCAD_ARG} --format=DXF --render=force EXPECTEDDIR cgalpngtest SUFFIX png FILES ${FILES_2D} ${SCAD_DXF_FILES})
add_cmdline_test(svgpngtest SCRIPT ${EX_IM_PNGTEST_PY} ARGS ${OPENSCAD_ARG} --format=SVG --render=force EXPECTEDDIR cgalpngtest SUFFIX png FILES ${FILES_2D} ${SCAD_SVG_FILES})

# Manifold corner cases
set(FILES_MANIFOLD_CORNER_CASES
${TEST_SCAD_DIR}/3D/misc/tetracyl-slim.scad
${TEST_SCAD_DIR}/3D/misc/tetracyl-touch-edge.scad
${TEST_SCAD_DIR}/3D/misc/tetracyl-touch-edge-nonmanifold.scad
${TEST_SCAD_DIR}/3D/misc/tetracyl-touch-vertex.scad
${TEST_SCAD_DIR}/3D/misc/tetracyl-touch-vertex-nonmanifold.scad
${TEST_SCAD_DIR}/3D/misc/polyhedrons-touch-edge-nonmanifold.scad
${TEST_SCAD_DIR}/3D/misc/polyhedrons-touch-edge.scad
${TEST_SCAD_DIR}/3D/misc/polyhedrons-touch-vertex-nonmanifold.scad
${TEST_SCAD_DIR}/3D/misc/polyhedrons-touch-vertex.scad
${TEST_SCAD_DIR}/3D/misc/polyhedrons-touch-face-nonmanifold.scad
${TEST_SCAD_DIR}/3D/misc/polyhedrons-touch-face.scad
${TEST_SCAD_DIR}/3D/misc/polyhedron-self-touch-edge-nonmanifold.scad
${TEST_SCAD_DIR}/3D/misc/polyhedron-self-touch-edge.scad
${TEST_SCAD_DIR}/3D/misc/polyhedron-self-touch-face-nonmanifold.scad
${TEST_SCAD_DIR}/3D/misc/polyhedron-self-touch-face.scad
${TEST_SCAD_DIR}/3D/misc/polyhedron-self-touch-vertex-nonmanifold.scad
${TEST_SCAD_DIR}/3D/misc/polyhedron-self-touch-vertex.scad
)
add_cmdline_test(3mfpngtest SCRIPT ${EX_IM_PNGTEST_PY} ARGS ${OPENSCAD_ARG} --format=3MF --render=force EXPECTEDDIR 3mfpngtest SUFFIX png FILES ${FILES_MANIFOLD_CORNER_CASES})
add_cmdline_test(objpngtest SCRIPT ${EX_IM_PNGTEST_PY} ARGS ${OPENSCAD_ARG} --format=OBJ --render=force EXPECTEDDIR 3mfpngtest SUFFIX png FILES ${FILES_MANIFOLD_CORNER_CASES})
add_cmdline_test(offpngtest SCRIPT ${EX_IM_PNGTEST_PY} ARGS ${OPENSCAD_ARG} --format=OFF --render=force EXPECTEDDIR 3mfpngtest SUFFIX png FILES ${FILES_MANIFOLD_CORNER_CASES})
add_cmdline_test(stlpngtest SCRIPT ${EX_IM_PNGTEST_PY} ARGS ${OPENSCAD_ARG} --format=STL --render=force EXPECTEDDIR 3mfpngtest SUFFIX png FILES ${FILES_MANIFOLD_CORNER_CASES})

set_tests_properties(
# Manifold construction error. Probably due to polygon soup strategy
3mfpngtest_polyhedron-self-touch-face-nonmanifold
3mfpngtest_polyhedron-self-touch-face
objpngtest_polyhedron-self-touch-face-nonmanifold
objpngtest_polyhedron-self-touch-face
offpngtest_polyhedron-self-touch-face-nonmanifold
offpngtest_polyhedron-self-touch-face
stlpngtest_polyhedron-self-touch-face-nonmanifold
stlpngtest_polyhedron-self-touch-face
3mfpngtest_polyhedrons-touch-face-nonmanifold
3mfpngtest_polyhedrons-touch-face
objpngtest_polyhedrons-touch-face-nonmanifold
objpngtest_polyhedrons-touch-face
offpngtest_polyhedrons-touch-face-nonmanifold
offpngtest_polyhedrons-touch-face
stlpngtest_polyhedrons-touch-face-nonmanifold
stlpngtest_polyhedrons-touch-face
PROPERTIES DISABLED TRUE
)

# Failing tests
add_failing_test(stlfailedtest SUFFIX stl FILES ${TEST_SCAD_DIR}/misc/empty-union.scad ARGS --retval=1)
add_failing_test(offfailedtest SUFFIX off FILES ${TEST_SCAD_DIR}/misc/empty-union.scad ARGS --retval=1)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// A single volume touching itself (two pairs of coincident vertices forming an edge).
// This is a non-manifold object since the collapsed vertices are not distinct.
polyhedron(
points=[
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[1, 1, 0],

[0, 0, 1],
[1, 0, 1],
[0, 1, 1],
[1, 1, 1],

[0.4, 0.5, 0.5],
[0.6, 0.5, 0.5],
],
faces=[
[5,4,8],[5,8,9],
[4,6,8],
[6,7,9],[6,9,8],
[7,5,9],

[0,1,9],[0,9,8],
[1,3,9],
[3,2,8],[3,8,9],
[2,0,8],

[4,5,1],[4,1,0],
[5,7,3],[5,3,1],
[7,6,2],[7,2,3],
[6,4,0],[6,0,2],
]);
36 changes: 36 additions & 0 deletions tests/data/scad/3D/misc/polyhedron-self-touch-edge.scad
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// A single volume touching itself (two pairs of coincident vertices forming an edge),
// but with a manifold topology (the coincident vertices are distinct).
polyhedron(
points=[
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[1, 1, 0],

[0, 0, 1],
[1, 0, 1],
[0, 1, 1],
[1, 1, 1],

[0.4, 0.5, 0.5],
[0.6, 0.5, 0.5],

[0.4, 0.5, 0.5],
[0.6, 0.5, 0.5],
],
faces=[
[5,4,10],[5,10,11],
[4,6,10],
[6,7,11],[6,11,10],
[7,5,11],

[0,1,9],[0,9,8],
[1,3,9],
[3,2,8],[3,8,9],
[2,0,8],

[4,5,1],[4,1,0],
[5,7,3],[5,3,1],
[7,6,2],[7,2,3],
[6,4,0],[6,0,2],
]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
polyhedron(
points=[
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[1, 1, 0],

[0, 0, 1],
[1, 0, 1],
[0, 1, 1],
[1, 1, 1],

[0.4, 0.4, 0.5],
[0.6, 0.4, 0.5],
[0.5, 0.6, 0.5],
],
faces=[
[5,4,8],[5,8,9],
[4,6,8],
[6,10,8],
[6,7,10],
[7,9,10],
[7,5,9],
[10,9,8],

[0,1,9],[0,9,8],
[1,3,9],
[3,10,9],
[3,2,10],
[2,8,10],
[2,0,8],
[8,9,10],

[4,5,1],[4,1,0],
[5,7,3],[5,3,1],
[7,6,2],[7,2,3],
[6,4,0],[6,0,2],
]);
43 changes: 43 additions & 0 deletions tests/data/scad/3D/misc/polyhedron-self-touch-face.scad
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// A single volume touching itself (three pairs of coincident vertices forming a triangle).
polyhedron(
points=[
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[1, 1, 0],

[0, 0, 1],
[1, 0, 1],
[0, 1, 1],
[1, 1, 1],

[0.4, 0.4, 0.5],
[0.6, 0.4, 0.5],
[0.5, 0.6, 0.5],

[0.4, 0.4, 0.5],
[0.6, 0.4, 0.5],
[0.5, 0.6, 0.5],
],
faces=[
[5,4,11],[5,11,12]
[4,6,11],
[6,13,11],
[6,7,13],
[7,12,13],
[7,5,12],
[13,12,11],

[0,1,9],[0,9,8],
[1,3,9],
[3,10,9],
[3,2,10],
[2,8,10],
[2,0,8],
[8,9,10],

[4,5,1],[4,1,0],
[5,7,3],[5,3,1],
[7,6,2],[7,2,3],
[6,4,0,2],[6,0,2],
]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
polyhedron(
points=[
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[1, 1, 0],

[0, 0, 1],
[1, 0, 1],
[0, 1, 1],
[1, 1, 1],

[0.5, 0.5, 0.5],
],
faces=[
[5,4,8],
[4,6,8],
[6,7,8],
[7,5,8],

[0,1,8],
[1,3,8],
[3,2,8],
[2,0,8],

[4,5,1],[4,1,0],
[5,7,3],[5,3,1],
[7,6,2],[7,2,3],
[6,4,0],[6,0,2],
]);
31 changes: 31 additions & 0 deletions tests/data/scad/3D/misc/polyhedron-self-touch-vertex.scad
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
polyhedron(
points=[
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[1, 1, 0],

[0, 0, 1],
[1, 0, 1],
[0, 1, 1],
[1, 1, 1],

[0.5, 0.5, 0.5],
[0.5, 0.5, 0.5],
],
faces=[
[5,4,9],
[4,6,9],
[6,7,9],
[7,5,9],

[0,1,8],
[1,3,8],
[3,2,8],
[2,0,8],

[4,5,1],[4,1,0],
[5,7,3],[5,3,1],
[7,6,2],[7,2,3],
[6,4,0],[6,0,2],
]);
34 changes: 34 additions & 0 deletions tests/data/scad/3D/misc/polyhedrons-touch-edge-nonmanifold.scad
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Two cubes sharing an edge.
// This is a non-manifold object since the collapsed vertices are not distinct.
polyhedron(
points=[
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[1, 1, 0],
[0, 0, 1],
[1, 0, 1],
[0, 1, 1],
[1, 1, 1],

[2, 1, 0],
[1, 2, 0],
[2, 2, 0],
[2, 1, 1],
[1, 2, 1],
[2, 2, 1],
],
faces=[
[6,7,5,4],
[0,1,3,2],
[4,5,1,0],
[5,7,3,1],
[7,6,2,3],
[6,4,0,2],
[12,13,11,7],
[3,8,10,9],
[7,11,8,3],
[11,13,10,8],
[13,12,9,10],
[12,7,3,9],
]);
34 changes: 34 additions & 0 deletions tests/data/scad/3D/misc/polyhedrons-touch-edge.scad
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
polyhedron(
points=[
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[1, 1, 0],
[0, 0, 1],
[1, 0, 1],
[0, 1, 1],
[1, 1, 1],

[1, 1, 0],
[2, 1, 0],
[1, 2, 0],
[2, 2, 0],
[1, 1, 1],
[2, 1, 1],
[1, 2, 1],
[2, 2, 1],
],
faces=[
[6,7,5],[6,5,4],
[0,1,3],[0,3,2],
[4,5,1],[4,1,0],
[5,7,3],[5,3,1],
[7,6,2],[7,2,3],
[6,4,0],[6,0,2],
[14,15,13],[14,13,7],
[3,9,11],[3,11,10],
[7,13,9],[7,9,3],
[13,15,11],[13,11,9],
[15,14,10],[15,10,11],
[14,7,3],[14,3,10],
]);
30 changes: 30 additions & 0 deletions tests/data/scad/3D/misc/polyhedrons-touch-face-nonmanifold.scad
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
polyhedron(
points=[
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[1, 1, 0],
[0, 0, 1],
[1, 0, 1],
[0, 1, 1],
[1, 1, 1],

[2, 0, 0],
[2, 1, 0],
[2, 0, 1],
[2, 1, 1],
],
faces=[
[6,7,5],[6,5,4],
[0,1,3],[0,3,2],
[4,5,1],[4,1,0],
[5,7,3],[5,3,1],
[7,6,2],[7,2,3],
[4,0,2],[4,2,6],
[7,11,10],[7,10,5],
[1,8,9],[1,9,3],
[5,10,8],[5,8,1],
[10,11,9],[10,9,8],
[11,7,3],[11,3,9],
[5,1,3],[5,3,7],
]);