#1215 Added support for optional --render parameter as well as optional manifoldness requirement to export_import_pngtest, slightly reorganized tests to use the new parameters

master
Marius Kintel 2015-02-14 12:26:54 -05:00
parent a3337c7af8
commit d5d22158dd
3 changed files with 55 additions and 28 deletions

View File

@ -1124,8 +1124,8 @@ set_test_config(Bugs dxfpngtest_text-font-direction-tests
csgpngtest_text-font-direction-tests
throwntogethertest_text-font-direction-tests)
list(APPEND EXPORTCGAL_TEST_FILES ${EXAMPLE_3D_FILES})
list(APPEND EXPORTCGAL_TEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/3D/features/polyhedron-nonplanar-tests.scad
list(APPEND EXPORT3D_CGALCGAL_TEST_FILES ${EXAMPLE_3D_FILES})
list(APPEND EXPORT3D_CGALCGAL_TEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/3D/features/polyhedron-nonplanar-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/3D/features/rotate_extrude-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/3D/features/union-coincident-test.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/3D/features/mirror-tests.scad
@ -1134,22 +1134,24 @@ list(APPEND EXPORTCGAL_TEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/3D/featur
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/internal-cavity-polyhedron.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/bad-stl-pcbvicebar.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/bad-stl-tardis.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/bad-stl-wing.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/rotate_extrude-hole.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/nonmanifold-polyhedron.scad)
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/rotate_extrude-hole.scad)
# Issue #910
set_test_config(Bugs offpngtest_polyhedron-tests
set_test_config(Bugs
offcgalpngtest_polyhedron-tests
offpngtest_nonmanifold-polyhedron
offcgalpngtest_bad-stl-pcbvicebar
offcgalpngtest_bad-stl-tardis
offcgalpngtest_bad-stl-wing)
# No issue - this was introduced when fixing #1033
set_test_config(Bugs stlcgalpngtest_bad-stl-wing)
offpngtest_bad-stl-wing)
list(APPEND EXPORT3D_CGAL_TEST_FILES
${CMAKE_SOURCE_DIR}/../testdata/scad/3D/features/polyhedron-tests.scad)
list(APPEND EXPORT3D_TEST_FILES
${CMAKE_SOURCE_DIR}/../testdata/scad/3D/features/polyhedron-tests.scad)
# Issue #337
set_test_config(Bugs stlpngtest_polyhedron-tests)
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/nonmanifold-polyhedron.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/bad-stl-wing.scad)
# No issue - this was introduced when fixing #1033
set_test_config(Bugs stlpngtest_bad-stl-wing)
disable_tests(
# These don't output anything
@ -1255,10 +1257,11 @@ list(APPEND BUGS_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue13.scad
# We know that we cannot import weakly manifold files into CGAL, so to make tests easier
# to manage, don't try. Once we improve import, we can reenable this
# Known good manifold files -> EXPORTCGAL_TEST_FILES
# Known weak manifold files -> EXPORT3D_TEST_FILES
list(APPEND EXPORTCGAL_TEST_FILES ${BUGS_FILES})
list(REMOVE_ITEM EXPORTCGAL_TEST_FILES
# Known good manifold files -> EXPORT3D_CGALCGAL_TEST_FILES
# Known weak manifold files -> EXPORT3D_CGAL_TEST_FILES
# Known non-manifold files -> EXPORT3D_TEST_FILES
list(APPEND EXPORT3D_CGALCGAL_TEST_FILES ${BUGS_FILES})
list(REMOVE_ITEM EXPORT3D_CGALCGAL_TEST_FILES
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue13.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue13b.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue945.scad
@ -1269,7 +1272,7 @@ list(REMOVE_ITEM EXPORTCGAL_TEST_FILES
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue1105c.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue1215.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue1215b.scad)
list(APPEND EXPORT3D_TEST_FILES
list(APPEND EXPORT3D_CGAL_TEST_FILES
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue13.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue13b.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue945.scad
@ -1281,7 +1284,13 @@ list(APPEND EXPORT3D_TEST_FILES
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue1215.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue1215b.scad)
list(REMOVE_ITEM EXPORTCGAL_TEST_FILES
disable_tests(
# This triggers a Value to string difference when compiled as testing
csgpngtest_issue1215
)
# 2D files
list(REMOVE_ITEM EXPORT3D_CGALCGAL_TEST_FILES
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue899.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue1089.scad)
list(APPEND ALL_2D_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/issue899.scad)
@ -1303,6 +1312,10 @@ foreach(FILE ${BUGS_FILES})
set_test_config(Bugs ${TEST_FULLNAME})
get_test_fullname(stlcgalpngtest ${FILE} TEST_FULLNAME)
set_test_config(Bugs ${TEST_FULLNAME})
get_test_fullname(cgalstlcgalpngtest ${FILE} TEST_FULLNAME)
set_test_config(Bugs ${TEST_FULLNAME})
get_test_fullname(offpngtest ${FILE} TEST_FULLNAME)
set_test_config(Bugs ${TEST_FULLNAME})
get_test_fullname(offcgalpngtest ${FILE} TEST_FULLNAME)
set_test_config(Bugs ${TEST_FULLNAME})
endforeach()
@ -1322,8 +1335,14 @@ foreach(FILE ${EXAMPLE_FILES})
set_test_config(Examples ${TEST_FULLNAME})
get_test_fullname(stlpngtest ${FILE} TEST_FULLNAME)
set_test_config(Examples ${TEST_FULLNAME})
get_test_fullname(stlcgalpngtest ${FILE} TEST_FULLNAME)
set_test_config(Examples ${TEST_FULLNAME})
get_test_fullname(cgalstlcgalpngtest ${FILE} TEST_FULLNAME)
set_test_config(Examples ${TEST_FULLNAME})
get_test_fullname(offpngtest ${FILE} TEST_FULLNAME)
set_test_config(Examples ${TEST_FULLNAME})
get_test_fullname(offcgalpngtest ${FILE} TEST_FULLNAME)
set_test_config(Examples ${TEST_FULLNAME})
endforeach()
# Workaround Gallium bugs
@ -1382,7 +1401,7 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake ${TMP})
# o monotonepngtest: Same as cgalpngtest but with the "Monotone" color scheme
# o stlpngtest: Export to STL, Re-import and render to PNG (--render)
# o stlcgalpngtest: Export to STL, Re-import and render to PNG (--render=cgal)
# o offpngtest: Export to OFF, Re-import and render to PNG (--render=cgal)
# o offpngtest: Export to OFF, Re-import and render to PNG (--render)
# o offcgalpngtest: Export to STL, Re-import and render to PNG (--render=cgal)
# o dxfpngtest: Export to DXF, Re-import and render to PNG (--render=cgal)
#
@ -1414,13 +1433,17 @@ add_cmdline_test(cgalstlsanitytest EXE ${CMAKE_SOURCE_DIR}/cgalstlsanitytest SUF
# Export/Import tests
#
add_cmdline_test(monotonepngtest EXE ${OPENSCAD_BINPATH} ARGS --colorscheme=Monotone --render -o SUFFIX png FILES ${EXPORT3D_TEST_FILES} ${EXPORTCGAL_TEST_FILES})
add_cmdline_test(monotonepngtest EXE ${OPENSCAD_BINPATH} ARGS --colorscheme=Monotone --render -o SUFFIX png FILES ${EXPORT3D_CGAL_TEST_FILES} ${EXPORT3D_CGALCGAL_TEST_FILES})
add_cmdline_test(stlpngtest EXE ${PYTHON_EXECUTABLE} SCRIPT ${CMAKE_SOURCE_DIR}/export_import_pngtest.py ARGS --openscad=${OPENSCAD_BINPATH} --format=STL --render EXPECTEDDIR monotonepngtest SUFFIX png FILES ${EXPORT3D_TEST_FILES})
add_cmdline_test(stlcgalpngtest EXE ${PYTHON_EXECUTABLE} SCRIPT ${CMAKE_SOURCE_DIR}/export_import_pngtest.py ARGS --openscad=${OPENSCAD_BINPATH} --format=STL --render=cgal EXPECTEDDIR monotonepngtest SUFFIX png FILES ${EXPORTCGAL_TEST_FILES})
# stlpngtest: direct STL output, preview rendering
add_cmdline_test(stlpngtest EXE ${PYTHON_EXECUTABLE} SCRIPT ${CMAKE_SOURCE_DIR}/export_import_pngtest.py ARGS --openscad=${OPENSCAD_BINPATH} --format=STL EXPECTEDDIR monotonepngtest SUFFIX png FILES ${EXPORT3D_TEST_FILES})
# cgalstlpngtest: CGAL STL output, normal rendering
add_cmdline_test(stlcgalpngtest EXE ${PYTHON_EXECUTABLE} SCRIPT ${CMAKE_SOURCE_DIR}/export_import_pngtest.py ARGS --openscad=${OPENSCAD_BINPATH} --format=STL --require-manifold --render EXPECTEDDIR monotonepngtest SUFFIX png FILES ${EXPORT3D_CGAL_TEST_FILES})
# cgalstlcgalpngtest: CGAL STL output, CGAL rendering
add_cmdline_test(cgalstlcgalpngtest EXE ${PYTHON_EXECUTABLE} SCRIPT ${CMAKE_SOURCE_DIR}/export_import_pngtest.py ARGS --openscad=${OPENSCAD_BINPATH} --format=STL --require-manifold --render=cgal EXPECTEDDIR monotonepngtest SUFFIX png FILES ${EXPORT3D_CGALCGAL_TEST_FILES})
add_cmdline_test(offpngtest EXE ${PYTHON_EXECUTABLE} SCRIPT ${CMAKE_SOURCE_DIR}/export_import_pngtest.py ARGS --openscad=${OPENSCAD_BINPATH} --format=OFF --render EXPECTEDDIR monotonepngtest SUFFIX png FILES ${EXPORT3D_TEST_FILES})
add_cmdline_test(offcgalpngtest EXE ${PYTHON_EXECUTABLE} SCRIPT ${CMAKE_SOURCE_DIR}/export_import_pngtest.py ARGS --openscad=${OPENSCAD_BINPATH} --format=OFF --render=cgal EXPECTEDDIR monotonepngtest SUFFIX png FILES ${EXPORTCGAL_TEST_FILES})
add_cmdline_test(offcgalpngtest EXE ${PYTHON_EXECUTABLE} SCRIPT ${CMAKE_SOURCE_DIR}/export_import_pngtest.py ARGS --openscad=${OPENSCAD_BINPATH} --format=OFF --render=cgal EXPECTEDDIR monotonepngtest SUFFIX png FILES ${EXPORT3D_CGAL_TEST_FILES})
add_cmdline_test(dxfpngtest EXE ${PYTHON_EXECUTABLE} SCRIPT ${CMAKE_SOURCE_DIR}/export_import_pngtest.py ARGS --openscad=${OPENSCAD_BINPATH} --format=DXF --render=cgal EXPECTEDDIR cgalpngtest SUFFIX png FILES ${FILES_2D})

View File

@ -3,7 +3,7 @@
# Export-import test
#
#
# Usage: <script> <inputfile> --openscad=<executable-path> --format=<format> [<openscad args>] file.png
# Usage: <script> <inputfile> --openscad=<executable-path> --format=<format> --require-manifold [<openscad args>] file.png
#
#
# step 1. If the input file is _not_ an .scad file, create a temporary .scad file importing the input file.
@ -14,7 +14,9 @@
# of the original .scad file. they should be the same!
#
# All the optional openscad args are passed on to OpenSCAD both in step 2 and 4.
# Exception: Any --render argument will be replaced with --render=cgal for step 2
# Exception: In any --render arguments are passed, the first pass (step 2) will always
# be run with --render=cgal while the second pass (step 4) will use the passed --render
# argument.
#
# This script should return 0 on success, not-0 on error.
#
@ -52,6 +54,8 @@ formats = ['csg', 'stl','off', 'amf', 'dxf', 'svg']
parser = argparse.ArgumentParser()
parser.add_argument('--openscad', required=True, help='Specify OpenSCAD executable')
parser.add_argument('--format', required=True, choices=[item for sublist in [(f,f.upper()) for f in formats] for item in sublist], help='Specify 3d export format')
parser.add_argument('--require-manifold', dest='requiremanifold', action='store_true', help='Require STL output to be manifold')
parser.set_defaults(requiremanifold=False)
args,remaining_args = parser.parse_known_args()
args.format = args.format.lower()
@ -84,9 +88,9 @@ if inputsuffix != '.scad' and inputsuffix != '.csg':
#
# First run: Just export the given filetype
# For any --render arguments to --render=cgal
#
tmpargs = [arg for arg in remaining_args if not arg.startswith('--render')]
tmpargs.append('--render=cgal')
tmpargs = ['--render=cgal' if arg.startswith('--render') else arg for arg in remaining_args]
export_cmd = [args.openscad, inputfile, '-o', exportfile] + tmpargs
print >> sys.stderr, 'Running OpenSCAD #1:'
@ -95,7 +99,7 @@ result = subprocess.call(export_cmd)
if result != 0:
failquit('OpenSCAD #1 failed with return code ' + str(result))
if args.format == 'stl':
if args.format == 'stl' and args.requiremanifold:
if not validateSTL(exportfile):
failquit("Error: Non-manifold STL file exported from OpenSCAD")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB