diff options
Diffstat (limited to 'src/CGALEvaluator.cc')
-rw-r--r-- | src/CGALEvaluator.cc | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index a63d271..0d46cd9 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -63,12 +63,6 @@ void CGALEvaluator::process(CGAL_Nef_polyhedron &target, const CGAL_Nef_polyhedr case CGE_MINKOWSKI: target.minkowski(src); break; - case CGE_HULL: - //FIXME: Port convex hull to a binary operator or process it all in the end somehow - // target.p2 = convexhull2(target.p2, src.p2); - // target.p2 = convexhull2(polys); - // FIXME: Print warning: hull() not supported in 3D - break; } } @@ -100,6 +94,40 @@ void CGALEvaluator::applyToChildren(const AbstractNode &node, CGALEvaluator::Csg this->cache.insert(cacheid, N); } +extern CGAL_Nef_polyhedron2 *convexhull2(std::list<CGAL_Nef_polyhedron2*> a); + +void CGALEvaluator::applyHull(const CgaladvNode &node) +{ + if (this->visitedchildren[node.index()].size() > 0) { + std::list<CGAL_Nef_polyhedron2*> polys; + bool all2d = true; + for (ChildList::const_iterator iter = this->visitedchildren[node.index()].begin(); + iter != this->visitedchildren[node.index()].end(); + iter++) { + const AbstractNode *chnode = iter->first; + const string &chcacheid = iter->second; + // FIXME: Don't use deep access to modinst members + if (chnode->modinst->tag_background) continue; + assert(isCached(*chnode)); + const CGAL_Nef_polyhedron &ch = this->cache[chcacheid]; + if (ch.dim == 2) { + polys.push_back(ch.p2); + } + else if (ch.dim == 3) { + PRINT("WARNING: hull() is not implemented yet for 3D objects!"); + all2d = false; + } + chnode->progress_report(); + } + + if (all2d) { + CGAL_Nef_polyhedron N(convexhull2(polys)); + const std::string &cacheid = this->tree.getString(node); + this->cache.insert(cacheid, N); + } + } +} + /* Typical visitor behavior: o In prefix: Check if we're cached -> prune @@ -246,17 +274,20 @@ Response CGALEvaluator::visit(State &state, const CgaladvNode &node) switch (node.type) { case MINKOWSKI: op = CGE_MINKOWSKI; + applyToChildren(node, op); break; case GLIDE: + PRINT("WARNING: glide() is not implemented yet!"); + return PruneTraversal; + break; case SUBDIV: - // FIXME: Not implemented + PRINT("WARNING: subdiv() is not implemented yet!"); return PruneTraversal; break; case HULL: - op = CGE_HULL; + applyHull(node); break; } - applyToChildren(node, op); } addToParent(state, node); } |