summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/TODO.txt2
-rw-r--r--testdata/scad/bugs/intersection-prune-test.scad9
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/csgtestcore.cc27
-rw-r--r--tests/regression/opencsgtest/intersection-prune-test-expected.pngbin0 -> 4408 bytes
-rw-r--r--tests/regression/throwntogethertest/intersection-prune-test-expected.pngbin0 -> 4408 bytes
6 files changed, 26 insertions, 13 deletions
diff --git a/doc/TODO.txt b/doc/TODO.txt
index 2b19a12..e7e0105 100644
--- a/doc/TODO.txt
+++ b/doc/TODO.txt
@@ -254,8 +254,6 @@ o Caching
- Test that caching is actually performed (speedup + same results)
- Test the modifier characters correctly influence the cache (also when
added/removed)
-o CSG normalization
- - Empty top-level intersection
o other tests
- export
- cmd-line tests
diff --git a/testdata/scad/bugs/intersection-prune-test.scad b/testdata/scad/bugs/intersection-prune-test.scad
new file mode 100644
index 0000000..3c6df7a
--- /dev/null
+++ b/testdata/scad/bugs/intersection-prune-test.scad
@@ -0,0 +1,9 @@
+// This tree cannot be pruned inline, but will still result in an empty CSG tree
+// Crashes OpenSCAD-2011.12. Bug fixed in 14e4f3bb
+intersection() {
+ union() {
+ cube();
+ translate([4,0,0]) cube();
+ }
+ translate([2,0,0]) cube();
+}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 931fb12..665bd92 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -619,6 +619,7 @@ list(APPEND CGALPNGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/include-
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/use-tests.scad)
list(APPEND OPENCSGTEST_FILES ${CGALPNGTEST_FILES})
list(APPEND OPENCSGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/bbox-transform-bug.scad)
+list(APPEND OPENCSGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/intersection-prune-test.scad)
list(APPEND THROWNTOGETHERTEST_FILES ${OPENCSGTEST_FILES})
list(APPEND CGALSTLSANITYTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/normal-nan.scad)
diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc
index 06b9d7b..e89f4a6 100644
--- a/tests/csgtestcore.cc
+++ b/tests/csgtestcore.cc
@@ -301,13 +301,16 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type)
// CSG normalization
CSGTermNormalizer normalizer;
csgInfo.root_norm_term = normalizer.normalize(root_raw_term, 5000);
-
- assert(csgInfo.root_norm_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");
+ }
- 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()));
-
if (csgInfo.highlight_terms.size() > 0) {
cerr << "Compiling highlights (" << csgInfo.highlight_terms.size() << " CSG Trees)...\n";
@@ -339,12 +342,14 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type)
enable_opencsg_shaders(csgInfo.glview);
if (sysinfo_dump) cout << info_dump(csgInfo.glview);
- BoundingBox bbox = csgInfo.root_chain->getBoundingBox();
-
- Vector3d center = (bbox.min() + bbox.max()) / 2;
- double radius = (bbox.max() - bbox.min()).norm() / 2;
-
+ Vector3d center(0,0,0);
+ double radius = 1.0;
+ if (csgInfo.root_chain) {
+ BoundingBox bbox = csgInfo.root_chain->getBoundingBox();
+ center = (bbox.min() + bbox.max()) / 2;
+ radius = (bbox.max() - bbox.min()).norm() / 2;
+ }
Vector3d cameradir(1, 1, -0.5);
Vector3d camerapos = center - radius*1.8*cameradir;
csgInfo.glview->setCamera(camerapos, center);
diff --git a/tests/regression/opencsgtest/intersection-prune-test-expected.png b/tests/regression/opencsgtest/intersection-prune-test-expected.png
new file mode 100644
index 0000000..50d838c
--- /dev/null
+++ b/tests/regression/opencsgtest/intersection-prune-test-expected.png
Binary files differ
diff --git a/tests/regression/throwntogethertest/intersection-prune-test-expected.png b/tests/regression/throwntogethertest/intersection-prune-test-expected.png
new file mode 100644
index 0000000..50d838c
--- /dev/null
+++ b/tests/regression/throwntogethertest/intersection-prune-test-expected.png
Binary files differ
contact: Jan Huwald // Impressum