diff options
Diffstat (limited to 'src/cgaladv.cc')
-rw-r--r-- | src/cgaladv.cc | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/cgaladv.cc b/src/cgaladv.cc index bf2e85a..6301cd3 100644 --- a/src/cgaladv.cc +++ b/src/cgaladv.cc @@ -34,12 +34,14 @@ #ifdef ENABLE_CGAL extern CGAL_Nef_polyhedron3 minkowski3(CGAL_Nef_polyhedron3 a, CGAL_Nef_polyhedron3 b); extern CGAL_Nef_polyhedron2 minkowski2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b); +extern CGAL_Nef_polyhedron2 convexhull2(std::list<CGAL_Nef_polyhedron2> a); #endif enum cgaladv_type_e { MINKOWSKI, GLIDE, - SUBDIV + SUBDIV, + HULL }; class CgaladvModule : public AbstractModule @@ -103,6 +105,10 @@ AbstractNode *CgaladvModule::evaluate(const Context *ctx, const ModuleInstantiat level = c.lookup_variable("level", true); } + if (type == HULL) { + convexity = c.lookup_variable("convexity", true); + } + node->convexity = (int)convexity.num; node->path = path; node->subdiv_type = subdiv_type.text; @@ -125,6 +131,7 @@ void register_builtin_cgaladv() builtin_modules["minkowski"] = new CgaladvModule(MINKOWSKI); builtin_modules["glide"] = new CgaladvModule(GLIDE); builtin_modules["subdiv"] = new CgaladvModule(SUBDIV); + builtin_modules["hull"] = new CgaladvModule(HULL); } #ifdef ENABLE_CGAL @@ -174,6 +181,29 @@ CGAL_Nef_polyhedron CgaladvNode::render_cgal_nef_polyhedron() const PRINT("WARNING: subdiv() is not implemented yet!"); } + if (type == HULL) + { + + std::list<CGAL_Nef_polyhedron2> polys; + bool all2d = true; + foreach(AbstractNode * v, children) { + if (v->modinst->tag_background) + continue; + N = v->render_cgal_nef_polyhedron(); + if (N.dim == 3) { + //polys.push_back(tmp.p3); + all2d=false; + } + if (N.dim == 2) { + polys.push_back(N.p2); + } + v->progress_report(); + } + + if(all2d) + N.p2 = convexhull2(polys); + } + cgal_nef_cache.insert(cache_id, new cgal_nef_cache_entry(N), N.weight()); print_messages_pop(); progress_report(); |