This one was missing:
function to3d(p) = [for(pi=p) [pi[0], pi[1], 0] ];
2018-02-19 17:50 GMT-03:00 Ronaldo Persiano rcmpersiano@gmail.com:
Nice but I still have caught some other cases with this test code:
b = 20;
seed =floor(rands(0,10000,1)[0]); // some problematic seeds: 2517, 4041,
2033
echo(seed=seed); // to reproduce problematic cases
a = rands(b/5, 2*b, 12,seed);
star = [ for(i=[0:30:360-1]) (i%60 ? a[i/30]:b)*[cos(i), sin(i)] ];
color("red")
translate([0,0,-5])
polygon(star);
star3 = to3d(star);
polyhedron( star3, triangulate_face(star3,[for(i=[0:len(star)-1]) i ]));
On 18/02/18 23:10, Revar Desmera wrote:
Sadly, CGAL will barf frequently even with known good coplanar face points. CGAL is only really reliable with triangles, in my experience.
This is why I have my own version of skin () that triangulates the top
and bottom. Sometimes the render retries and it all works but more often
it barfs out an error with no clue as to which bit of geometry.
Wow... maybe I should go to the school for children that can't math good.
triangulate.scad http://forum.openscad.org/file/t2140/triangulate.scad
--
Sent from: http://forum.openscad.org/
Don't be so severe with yourself! Your code is cleaner than my own. I
haven't checked it in depth but it seems to be ok now. Nice work.
Ronaldo wrote
Don't be so severe with yourself! Your code is cleaner than my own. I
haven't checked it in depth but it seems to be ok now. Nice work.
...
It can get in trouble when there are colinear points.
Something like:
test=[ [10,0],[0,0],[10,-30],[10,-20],[10,-10]];
Is a legitimate (ish) polygon, but the algorithm will clip point 1 first,
and be left with 4 vertices on a line which it can't handle.
Also, it should really have input checking.
--
Sent from: http://forum.openscad.org/
On 18/02/18 23:10, Revar Desmera wrote:
Sadly, CGAL will barf frequently even with known good coplanar face points. CGAL is only really reliable with triangles, in my experience.
I discovered this when using the skin () module from
list-comprehensions, as the top and bottom of the shape aren't
triangulated and can cause cgal errors, so I added the option to do
this. I ended up leaving the option enabled the whole time.
Unfortunately I've done some other hacking around so I don't think this
code will drop straight in. (BTW, RangeToVec could maybe be done with
new "each" function.)
function cap(start, end, order) = [for (p = [start+1:end-1])
[start, p+order, p+(1-order)]]; // Order = 0 ascending, 1 descending
triangles = [
for(index = [1:N-1])
for(t = profile_triangles(index))
t
];
start_cap = npstart == true ? cap(start=0, end=P-1, order=0) :
[RangeToVec([0:P-1])];
end_cap = npend == true ? cap (start=P*(N-1), end=PN-1, order=1)
: [RangeToVec([PN-1 : -1 : P*(N-1)])];
polyhedron(convexity=2, points=profiles, faces=concat(start_cap,
triangles, end_cap));
If anyone cares, this version checks for the 'last ear' problem and handles
it.
triangulate.scad http://forum.openscad.org/file/t2140/triangulate.scad
--
Sent from: http://forum.openscad.org/
On 21/02/18 23:59, NateTG wrote:
If anyone cares, this version checks for the 'last ear' problem and handles
it.
triangulate.scadhttp://forum.openscad.org/file/t2140/triangulate.scad
I definitely care because skin () doesn't triangulate the end caps of
the object. I added triangulation that will handle convex shapes only
and may see how to build your function into it instead.
Perhaps polyhedron () should have an option to triangulate any face that
has >3 vertices? I'd much prefer that this be in the guts of OpenSCAD
rather than in "user land".
Hmmm, how does this work for polygons? I don't recall seeing issues with
complex extruded polygons due to >3 vertex faces causing cgal mayhem.
Polyhedron does triangulate faces with more than three sides. It gives a
warning first though and a few recent versions have a bug that makes it an
error.
On 22 Feb 2018 8:58 a.m., "Gadgetmind" lists@foxhill.co.uk wrote:
On 21/02/18 23:59, NateTG wrote:
If anyone cares, this version checks for the 'last ear' problem and handles
it.
triangulate.scad http://forum.openscad.org/file/t2140/triangulate.scad http://forum.openscad.org/file/t2140/triangulate.scad
I definitely care because skin () doesn't triangulate the end caps of the
object. I added triangulation that will handle convex shapes only and may
see how to build your function into it instead.
Perhaps polyhedron () should have an option to triangulate any face that
has >3 vertices? I'd much prefer that this be in the guts of OpenSCAD
rather than in "user land".
Hmmm, how does this work for polygons? I don't recall seeing issues with
complex extruded polygons due to >3 vertex faces causing cgal mayhem.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
On 22/02/18 10:08, nop head wrote:
Polyhedron does triangulate faces with more than three sides. It gives
a warning first though and a few recent versions have a bug that makes
it an error.
Ah, OK. I've seen the retry warning due to non-planar but, as you say,
it's usually followed by an error. Has the bug been fixed?
Might being able to force the triangulation save rendering time?