Skip to content

Commit

Permalink
Filter empty children before performing minkowski sum. Fixes #1196
Browse files Browse the repository at this point in the history
  • Loading branch information
kintel committed Jan 29, 2015
1 parent e4d7de1 commit 1d66d21
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/GeometryEvaluator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,15 @@ GeometryEvaluator::ResultObject GeometryEvaluator::applyToChildren3D(const Abstr
// Only one child -> this is a noop
if (children.size() == 1) return ResultObject(children.front().second);

if (op == OPENSCAD_MINKOWSKI) return ResultObject(CGALUtils::applyMinkowski(children));
if (op == OPENSCAD_MINKOWSKI) {
Geometry::ChildList actualchildren;
BOOST_FOREACH(const Geometry::ChildItem &item, children) {
if (!item.second->isEmpty()) actualchildren.push_back(item);
}
if (actualchildren.empty()) return ResultObject();
if (actualchildren.size() == 1) return ResultObject(actualchildren.front().second);
return ResultObject(CGALUtils::applyMinkowski(actualchildren));
}

CGAL_Nef_polyhedron *N = CGALUtils::applyOperator(children, op);
// FIXME: Clarify when we can return NULL and what that means
Expand Down
3 changes: 3 additions & 0 deletions src/cgalutils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ namespace CGALUtils {
return visited.size() == p.size_of_facets();
}

/*!
children cannot contain NULL objects
*/
Geometry const * applyMinkowski(const Geometry::ChildList &children)
{
CGAL::Timer t,t_tot;
Expand Down
11 changes: 11 additions & 0 deletions testdata/scad/bugs/issue1196.scad
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@ minkowski() {
import("notfound.dxf");
}
}

minkowski() {
linear_extrude() {
import("notfound.dxf");
}
linear_extrude() {
import("notfound.dxf");
}
cube();
cube();
}

0 comments on commit 1d66d21

Please sign in to comment.