mirror of https://github.com/vitalif/openscad
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.stl_dim
parent
5ef540054c
commit
5d5c745fde
|
@ -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();
|
||||
foreach(AbstractNode * v, children) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "cgal.h"
|
||||
#include <CGAL/convex_hull_2.h>
|
||||
|
||||
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<CGAL_Nef_polyhedron2::Point> p2points(CGAL_Poly2 p2)
|
||||
|
@ -44,7 +44,7 @@ static std::list<CGAL_Nef_polyhedron2::Point> 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<CGAL_Nef_polyhedron2::Point> points = p2points(ap), result;
|
||||
|
|
|
@ -4,5 +4,4 @@ hull() {
|
|||
circle(10);
|
||||
circle(10);
|
||||
}
|
||||
square(2);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue