diff options
author | don bright <hugh.m.bright@gmail.com> | 2013-02-25 03:07:37 (GMT) |
---|---|---|
committer | don bright <hugh.m.bright@gmail.com> | 2013-02-25 03:07:37 (GMT) |
commit | 9896b6f15eced6d05a131ece44d60745e200b8f5 (patch) | |
tree | 7d8a362003174ed6b150c439f2827d6a7252674d /tests | |
parent | 8738cdc03451803014ca84f8614bdff1ff393ca9 (diff) |
first working version of opencsg png export from gui binary
also guiopencsgtest introduced. passes 100% of 'normal' tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 11 | ||||
-rw-r--r-- | tests/csgtestcore.cc | 48 | ||||
-rw-r--r-- | tests/guiopencsgtest.cc | 27 | ||||
-rwxr-xr-x | tests/test_cmdline_tool.py | 1 |
4 files changed, 38 insertions, 49 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 733a87a..b3d5a54 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -603,6 +603,8 @@ endif() if(EXISTS "${GUI_BINPATH}") add_executable(guicgalpngtest guicgalpngtest.cc) set_target_properties(guicgalpngtest PROPERTIES COMPILE_FLAGS "-DBINPATH=${GUI_BINPATH}") + add_executable(guiopencsgtest guiopencsgtest.cc) + set_target_properties(guiopencsgtest PROPERTIES COMPILE_FLAGS "-DBINPATH=${GUI_BINPATH}") message(STATUS "Found OpenSCAD GUI binary: ${GUI_BINPATH}") else() message(STATUS "Couldn't find the OpenSCAD GUI binary: ${GUI_BINPATH}") @@ -762,6 +764,7 @@ list(APPEND THROWNTOGETHERTEST_FILES ${OPENCSGTEST_FILES}) list(APPEND CGALSTLSANITYTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/normal-nan.scad) list(APPEND GUICGALPNGTEST_FILES ${CGALPNGTEST_FILES}) +list(APPEND GUIOPENCSGTEST_FILES ${OPENCSGTEST_FILES}) # Disable tests which are known to cause floating point comparison issues # Once we're capable of comparing these across platforms, we can put these back in @@ -787,10 +790,11 @@ disable_tests(dumptest_transform-tests # FIXME: This test illustrates a weakness in child() combined with modifiers. # Reenable it when this is improved disable_tests(opencsgtest_child-background) +disable_tests(guiopencsgtest_child-background) # FIXME: This single test takes over an hour to run on a 2.7 GHz P4 disable_tests(opencsgtest_example006 cgalpngtest_example006) -disable_tests(opencsgtest_example006 guicgalpngtest_example006) +disable_tests(guiopencsgtest_example006 guicgalpngtest_example006) # These tests only makes sense in OpenCSG mode disable_tests(cgalpngtest_child-background @@ -807,6 +811,8 @@ disable_tests(cgalpngtest_child-background set_test_config(Heavy opencsgtest_minkowski3-tests opencsgtest_projection-tests + guiopencsgtest_minkowski3-tests + guiopencsgtest_projection-tests throwntogethertest_minkowski3-tests throwntogethertest_projection-tests cgalpngtest_projection-tests @@ -835,6 +841,8 @@ foreach(FILE ${EXAMPLE_FILES}) set_test_config(Examples ${TEST_FULLNAME}) get_test_fullname(guicgalpngtest ${FILE} TEST_FULLNAME) set_test_config(Examples ${TEST_FULLNAME}) + get_test_fullname(guiopencsgtest ${FILE} TEST_FULLNAME) + set_test_config(Examples ${TEST_FULLNAME}) endforeach() # Workaround Gallium bugs @@ -888,6 +896,7 @@ add_cmdline_test(cgalpngtest png ${CGALPNGTEST_FILES}) add_cmdline_test(opencsgtest png ${OPENCSGTEST_FILES}) add_cmdline_test(throwntogethertest png ${THROWNTOGETHERTEST_FILES}) add_cmdline_test(guicgalpngtest png ${GUICGALPNGTEST_FILES}) +add_cmdline_test(guiopencsgtest png ${GUIOPENCSGTEST_FILES}) # FIXME: We don't actually need to compare the output of cgalstlsanitytest # with anything. It's self-contained and returns != 0 on error diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index a4a036d..a3a0b4d 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -105,54 +105,6 @@ po::variables_map parse_options(int argc, char *argv[]) return vm; } -int opencsg_prep( Tree &tree, AbstractNode *root_node, CsgInfo_OpenCSG &csgInfo ) -{ - CGALEvaluator cgalevaluator(tree); - CSGTermEvaluator evaluator(tree, &cgalevaluator.psevaluator); - shared_ptr<CSGTerm> root_raw_term = evaluator.evaluateCSGTerm(*root_node, - csgInfo.highlight_terms, - csgInfo.background_terms); - - if (!root_raw_term) { - cerr << "Error: CSG generation failed! (no top level object found)\n"; - return 1; - } - - // CSG normalization - CSGTermNormalizer normalizer(5000); - csgInfo.root_norm_term = normalizer.normalize(root_raw_term); - if (csgInfo.root_norm_term) { - csgInfo.root_chain = new CSGChain(); - csgInfo.root_chain->import(csgInfo.root_norm_term); - fprintf(stderr, "Normalized CSG tree has %d elements\n", int(csgInfo.root_chain->polysets.size())); - } - else { - csgInfo.root_chain = NULL; - fprintf(stderr, "WARNING: CSG normalization resulted in an empty tree\n"); - } - - if (csgInfo.highlight_terms.size() > 0) { - cerr << "Compiling highlights (" << csgInfo.highlight_terms.size() << " CSG Trees)...\n"; - - csgInfo.highlights_chain = new CSGChain(); - for (unsigned int i = 0; i < csgInfo.highlight_terms.size(); i++) { - csgInfo.highlight_terms[i] = normalizer.normalize(csgInfo.highlight_terms[i]); - csgInfo.highlights_chain->import(csgInfo.highlight_terms[i]); - } - } - - if (csgInfo.background_terms.size() > 0) { - cerr << "Compiling background (" << csgInfo.background_terms.size() << " CSG Trees)...\n"; - - csgInfo.background_chain = new CSGChain(); - for (unsigned int i = 0; i < csgInfo.background_terms.size(); i++) { - csgInfo.background_terms[i] = normalizer.normalize(csgInfo.background_terms[i]); - csgInfo.background_chain->import(csgInfo.background_terms[i]); - } - } - return 0; -} - int csgtestcore(int argc, char *argv[], test_type_e test_type) { bool sysinfo_dump = false; diff --git a/tests/guiopencsgtest.cc b/tests/guiopencsgtest.cc new file mode 100644 index 0000000..75e6abd --- /dev/null +++ b/tests/guiopencsgtest.cc @@ -0,0 +1,27 @@ +// Wrapper around openscad gui binary, so it can act like a 'test' + +#include <unistd.h> +#include <stdio.h> +#ifndef BINPATH +#error please define BINPATH=/some/path/openscad when compiling +#endif +#define PREQUOTE(x) #x +#define QUOTE(x) PREQUOTE(x) +int main( int argc, char * argv[] ) +{ + fprintf(stderr,"%s: wrapper for OpenSCAD at %s\n", argv[0], QUOTE( BINPATH ) ); + if ( argc != 3 ) { + fprintf(stderr,"%s: bad number of arguments: %i\n", argv[0], argc); + return 1; + } + char *newargs[6]; + char *scadfilename = argv[1]; + char *pngfilename = argv[2]; + newargs[0] = const_cast<char *>(QUOTE( BINPATH )); + newargs[1] = scadfilename; + newargs[2] = const_cast<char *>("-o"); + newargs[3] = pngfilename; + newargs[4] = NULL; + return execv( newargs[0], newargs ); +} + diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index ebe60df..5314921 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -30,6 +30,7 @@ import string share_expected_imgs = {} share_expected_imgs["guicgalpngtest"] = "cgalpngtest" +share_expected_imgs["guiopencsgtest"] = "opencsgtest" def initialize_environment(): if not options.generate: options.generate = bool(os.getenv("TEST_GENERATE")) |