From c4cae2a29a7df82f4f1b43543e6b22b642a275b0 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 2 May 2013 22:11:23 -0400 Subject: Fixes crash if hull's children are empty objects. Fixes #345 diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index 6ad9e4d..d0140fa 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -141,6 +141,9 @@ CGAL_Nef_polyhedron CGALEvaluator::applyHull(const CgaladvNode &node) PRINT("WARNING: hull() does not support mixing 2D and 3D objects."); continue; } + if (chN.isNull()) { // If one of the children evaluated to a null object + continue; + } if (dim == 2) { CGAL_Nef_polyhedron2::Explorer explorer = chN.p2->explorer(); BOOST_FOREACH(const CGAL_Nef_polyhedron2::Explorer::Vertex &vh, diff --git a/testdata/scad/features/hull2-tests.scad b/testdata/scad/features/hull2-tests.scad index e656e6a..82b56e4 100644 --- a/testdata/scad/features/hull2-tests.scad +++ b/testdata/scad/features/hull2-tests.scad @@ -31,7 +31,15 @@ module hull2dForLoop() { } } +module hull2null() { + hull() { + square(0); + circle(0); + } +} + convex2dHole(); translate([40,0,0]) convex2dSimple(); translate([0,-20,0]) concave2dSimple(); translate([30,-25,0]) hull2dForLoop(); +hull2null(); \ No newline at end of file diff --git a/testdata/scad/features/hull3-tests.scad b/testdata/scad/features/hull3-tests.scad index e3fc8e7..0f48b8f 100644 --- a/testdata/scad/features/hull3-tests.scad +++ b/testdata/scad/features/hull3-tests.scad @@ -26,3 +26,12 @@ translate([-5,-5,-5]) { } } } + +module hull3null() { + hull() { + cube(0); + sphere(0); + } +} +hull3null(); + diff --git a/tests/regression/dumptest/hull2-tests-expected.txt b/tests/regression/dumptest/hull2-tests-expected.txt index e4c5a5b..c14282f 100644 --- a/tests/regression/dumptest/hull2-tests-expected.txt +++ b/tests/regression/dumptest/hull2-tests-expected.txt @@ -56,4 +56,10 @@ } } } + group() { + hull() { + square(size = [0, 0], center = false); + circle($fn = 0, $fa = 12, $fs = 2, r = 0); + } + } diff --git a/tests/regression/dumptest/hull3-tests-expected.txt b/tests/regression/dumptest/hull3-tests-expected.txt index 4c05e2c..f8def3b 100644 --- a/tests/regression/dumptest/hull3-tests-expected.txt +++ b/tests/regression/dumptest/hull3-tests-expected.txt @@ -27,4 +27,10 @@ } } } + group() { + hull() { + cube(size = [0, 0, 0], center = false); + sphere($fn = 0, $fa = 12, $fs = 2, r = 0); + } + } -- cgit v0.10.1