summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2014-01-14 01:57:49 (GMT)
committerMarius Kintel <marius@kintel.net>2014-01-14 01:57:49 (GMT)
commit34ae2b8f68b73b91f5c4c522620aeed8e5a9e7b7 (patch)
treea6f44723e944da89ec34823cc5fddeeb41ad04a5
parent23b04c3a9f1aba164d7429fee4669de18a32d9a8 (diff)
Testcase and fix for a problem transforming an empty bbox with very small numbers in a transformation matrix
-rw-r--r--src/linalg.cc1
-rw-r--r--testdata/scad/misc/rotate-empty-bbox.scad11
-rw-r--r--tests/CMakeLists.txt3
-rw-r--r--tests/regression/cgalpngtest/rotate-empty-bbox-expected.pngbin0 -> 7776 bytes
-rw-r--r--tests/regression/opencsgtest/rotate-empty-bbox-expected.pngbin0 -> 8239 bytes
-rw-r--r--tests/regression/throwntogethertest/rotate-empty-bbox-expected.pngbin0 -> 7837 bytes
6 files changed, 14 insertions, 1 deletions
diff --git a/src/linalg.cc b/src/linalg.cc
index 6799055..274a70a 100644
--- a/src/linalg.cc
+++ b/src/linalg.cc
@@ -14,6 +14,7 @@
*/
BoundingBox operator*(const Transform3d &m, const BoundingBox &box)
{
+ if (box.isEmpty()) return box;
BoundingBox newbox;
Vector3d boxvec[2] = { box.min(), box.max() };
for (int k=0;k<2;k++) {
diff --git a/testdata/scad/misc/rotate-empty-bbox.scad b/testdata/scad/misc/rotate-empty-bbox.scad
new file mode 100644
index 0000000..f39a923
--- /dev/null
+++ b/testdata/scad/misc/rotate-empty-bbox.scad
@@ -0,0 +1,11 @@
+// rotate([90,0,0]) results in a matrix with some close-to-zero values
+// Transforming an empty boundingbox by this matrix has caused a problem resulting
+// in the union being evaluated to nothing.
+rotate([90,0,0])
+difference() {
+ cube(60, center=true);
+ union() {
+ translate([0,0,40]) cube(50, center=true);
+ cube(0);
+ }
+}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index daf7c1e..6e1f905 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -840,7 +840,8 @@ list(APPEND CGALPNGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/include-
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/use-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/transform-nan-inf-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/localfiles-test.scad
- ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/localfiles_dir/localfiles-compatibility-test.scad)
+ ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/localfiles_dir/localfiles-compatibility-test.scad
+ ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/rotate-empty-bbox.scad)
list(APPEND OPENCSGTEST_FILES ${CGALPNGTEST_FILES})
list(APPEND OPENCSGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/intersection-prune-test.scad)
diff --git a/tests/regression/cgalpngtest/rotate-empty-bbox-expected.png b/tests/regression/cgalpngtest/rotate-empty-bbox-expected.png
new file mode 100644
index 0000000..f3fa75f
--- /dev/null
+++ b/tests/regression/cgalpngtest/rotate-empty-bbox-expected.png
Binary files differ
diff --git a/tests/regression/opencsgtest/rotate-empty-bbox-expected.png b/tests/regression/opencsgtest/rotate-empty-bbox-expected.png
new file mode 100644
index 0000000..182a879
--- /dev/null
+++ b/tests/regression/opencsgtest/rotate-empty-bbox-expected.png
Binary files differ
diff --git a/tests/regression/throwntogethertest/rotate-empty-bbox-expected.png b/tests/regression/throwntogethertest/rotate-empty-bbox-expected.png
new file mode 100644
index 0000000..4408dc1
--- /dev/null
+++ b/tests/regression/throwntogethertest/rotate-empty-bbox-expected.png
Binary files differ
contact: Jan Huwald // Impressum