From 5d5c745fdecd2580b5254cc1fd758bdc31ff88ba Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sat, 9 Apr 2011 17:53:19 +0100 Subject: Slight improvement. You no longer need an arbitary shape in the script for it to work. See changes in testdata/scad/convex_hull.scad The square(2) was never rendered it was just there because the hull is calculated when it itterates onto the second child. I also removed the unneeded parameter. diff --git a/src/cgaladv.cc b/src/cgaladv.cc index 48f14c7..45a3bdd 100644 --- a/src/cgaladv.cc +++ b/src/cgaladv.cc @@ -34,7 +34,7 @@ #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(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b); +extern CGAL_Nef_polyhedron2 convexhull2(CGAL_Nef_polyhedron2 a); #endif enum cgaladv_type_e { @@ -183,24 +183,19 @@ CGAL_Nef_polyhedron CgaladvNode::render_cgal_nef_polyhedron() const if (type == HULL) { - bool first = true; + foreach(AbstractNode * v, children) { - if (v->modinst->tag_background) - continue; - if (first) { - N = v->render_cgal_nef_polyhedron(); - if (N.dim != 0) - first = false; - } else { - CGAL_Nef_polyhedron tmp = v->render_cgal_nef_polyhedron(); - if (N.dim == 3 && tmp.dim == 3) { - - } - if (N.dim == 2 && tmp.dim == 2) { - N.p2 = convexhull2(N.p2, tmp.p2); - } - } - v->progress_report(); + if (v->modinst->tag_background) + continue; + N = v->render_cgal_nef_polyhedron(); + if (N.dim == 3) { + + } + if (N.dim == 2) { + N.p2 = convexhull2(N.p2); + } + v->progress_report(); + break; } } diff --git a/src/cgaladv_convexhull2.cc b/src/cgaladv_convexhull2.cc index 9505e44..1914954 100644 --- a/src/cgaladv_convexhull2.cc +++ b/src/cgaladv_convexhull2.cc @@ -29,7 +29,7 @@ #include "cgal.h" #include -extern CGAL_Nef_polyhedron2 convexhull2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b); +extern CGAL_Nef_polyhedron2 convexhull2(CGAL_Nef_polyhedron2 a); extern CGAL_Poly2 nef2p2(CGAL_Nef_polyhedron2 p); static std::list p2points(CGAL_Poly2 p2) @@ -44,7 +44,7 @@ static std::list p2points(CGAL_Poly2 p2) return points; } -CGAL_Nef_polyhedron2 convexhull2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b) +CGAL_Nef_polyhedron2 convexhull2(CGAL_Nef_polyhedron2 a) { CGAL_Poly2 ap = nef2p2(a); std::list points = p2points(ap), result; diff --git a/testdata/scad/convex_hull.scad b/testdata/scad/convex_hull.scad index 7db6817..0f6c073 100644 --- a/testdata/scad/convex_hull.scad +++ b/testdata/scad/convex_hull.scad @@ -4,5 +4,4 @@ hull() { circle(10); circle(10); } - square(2); } -- cgit v0.10.1