So the remeshing was done by a boolean operation. That's another thing.
But it would not turn triangles to purple ...
--
View this message in context: http://forum.openscad.org/Can-t-find-what-s-wrong-here-use-import-stl-and-difference-tp19123p19175.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
You are right. The remeshing is the responsible of the retriangulation. I
will have to analyse this more carefully.
However, I have tried your animation code from elsewhere with the following
change:
use <Naca_sweep.scad>
N = 100;
t = 100;
T1 = -100*($t-.5);
T2 = 250*($t-.5);
render() union(){
translate([400,0,-50]) cube(100);
sweep([gen(0, T1), gen(200, T2)]);
}
function gen(shift=0, T = 0) =
[for (i=[0:360/N:360]) [tsin(i), tcos(i), Tsin(2i)+shift]];
Surprisingly, CGAL rejects your sweep except for T1=T2=0. How to explain
that?
ERROR: Alternate construction failed. CGAL error in CGAL_Nef_polyhedron3():
CGAL ERROR: assertion violation! Expr: e->incident_sface() !=
SFace_const_handle() File:
/opt/mxe/usr/x86_64-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h
Line: 326
2016-11-16 20:29 GMT-02:00 Parkinbot rudolf@parkinbot.com:
So the remeshing was done by a boolean operation. That's another thing.
But it would not turn triangles to purple ...
To me this is not a big surprise, even I don't know which part of CGAL
OpenSCAD uses for which task. But it seems F5 and F6 don't use the same
calls or F6 is missing a call. Usually I'm happy when code works within it's
specification and I'm not interested very much in cases that crudely violate
these rules. (You would never try to put 5 elephants into a VW beatle, even
a joke says: It's very easy. Place two at the front seats and three at the
rear bench seat.)
I would never have tried out obviously pathologic stuff like that, if
Johan's first design didn't amaze me somehow. And it is not worth spending
much time on it.
But, to bring it to an end, you will also be surprised that your example
works well with quads, wenn setting N=4
use
<Naca_sweep.scad>
N = 4;
t = 100;
$t = 0;
T1 = -100*($t-.5);
T2 = 250*($t-.5);
render()
union(){
translate([400,0,-50]) cube(100);
sweep([gen(0, T1), gen(200, T2)]);
}
function gen(shift=0, T = 0) =
let (offs = 45)
[for (i=[offs:360/N:359+offs]) [tsin(i), tcos(i), Tsin(2i)+shift]];
--
View this message in context: http://forum.openscad.org/Can-t-find-what-s-wrong-here-use-import-stl-and-difference-tp19123p19178.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
On Nov 16, 2016, at 18:32, Ronaldo Persiano rcmpersiano@gmail.com wrote:
ERROR: Alternate construction failed. CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: e->incident_sface() != SFace_const_handle() File: /opt/mxe/usr/x86_64-w64-mingw32.static/include/CGAL/Nef_S2/SM_const_decorator.h Line: 326
Could someone provide me with an (as small as possible) scad example, preferrably without using any libraries, which exhibits this behavior?
-Marius
On Nov 16, 2016, at 16:28, Ronaldo Persiano rcmpersiano@gmail.com wrote:
If CGAL triangulation algorithm is not 100% robust, we are in trouble.
The primary trouble right now is more code to maintain and potential for other bugs on our end; our code for working around that is a more robust than CGAL, but not very pretty:
https://github.com/openscad/openscad/blob/master/src/GeometryUtils.cc#L193
-Marius
The discussion is about how non-planar polygons are triangulated.
It is so tedious to construct a polygon by denoting vertices and faces. But
you might trust your own library skins.scad more. The resulting object is
quite simple with small N.
use
<skin.scad>
N = 100; // when >4 render() fails
t = 100;
T = 85; // T==0, render() succeeds for any N>2
// without render(), another peculiarity:
// N==100 && T==85, triangulation works but flips, when T==86
//render()
union(){
translate([400,0,-50]) cube(100);
skin([gen(0), gen(200, T)]);
}
function gen(shift=0, T = 0) =
[for (i=[0:360/N:359]) [tsin(i), tcos(i), Tsin(2i)+shift]];
--
View this message in context: http://forum.openscad.org/Can-t-find-what-s-wrong-here-use-import-stl-and-difference-tp19123p19181.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Kintel, you asked for it:
N = 50; // number of discretization points
t = 100; // cylinder radius
T1 = -100*($t-.5); // Z scale top
T2 = 250*($t-.5); // Z scale bottom
// uncomment the next line to see the issue in animation
//render()
union(){
translate([400,0,-50]) cube(100);
g1 = gen(0, T1);
g2 = gen(200, T2);
show_closed_mesh([g1,g2]);
}
function gen(shift=0, T = 0) =
[for (i=[0:360/N:360]) [tsin(i), tcos(i), Tsin(2i)+shift]]; echo($t);
module show_closed_mesh(mesh) {
// generates a solid for a closed mesh adding two faces to close the top
and bottom
function mesh_faces(mesh) =
let( n = len(mesh), m = len(mesh[0]) )
concat( [ for(i=[0:n-2]) for(j=[0:m-2])
[ im+j+1, im+j , (i+1)*m+j ] ] ,
[ for(i=[0:n-2]) for(j=[0:m-2])
[ (i+1)*m+j, (i+1)m+j+1, im+j+1 ] ]
) ;
// process mesh
mesh_vertices = [ for(line=mesh) for(pt=line) pt ];
mesh_faces = mesh_faces(mesh);
mv = len(mesh_vertices);
mvlen = mv + len(mesh[0]);
mv2len = mvlen + len(mesh[0]);
// process faces
face_vertices = concat(mesh[0], mesh[len(mesh)-1]) ;
face_polygons = [ [for(i=[mv:mvlen-1]) i ],
[for(i=[mv2len-1:-1:mvlen]) i ] ];
polyhedron(
points = concat(mesh_vertices, face_vertices),
faces = concat(mesh_faces, face_polygons),
convexity = 10
);
}
It is the same polyhedron that have been generated before. And the same
issue.
Happy debugging :)
--
View this message in context: http://forum.openscad.org/Can-t-find-what-s-wrong-here-use-import-stl-and-difference-tp19123p19182.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
I think I've run into the same thing myself, except that CGAL fails silently,
and just doesn't generate anything. I'm working with a model of the Bell X1
I downloaded from the Smithsonian (http://3d.si.edu/downloads/1341).
I too had faith in NetFabb & MeshLab. But (thanks to your post) I loaded
the supposedly fixed file into Meshmixer, and it found (and fixed) some more
errors. Meshmixer doesn't find some of the errors that NetFabb & MeshLab
find, so I guess you need all 3.
Frank
--
View this message in context: http://forum.openscad.org/Can-t-find-what-s-wrong-here-use-import-stl-and-difference-tp19123p19183.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Parkinbot wrote
But, to bring it to an end, you will also be surprised that your example
works well with quads, wenn setting N=4
Rudolf,
With N=4, the top and bottom faces are planar. In this case, there is no
need of "Alternate construction" (AKA OpenSCAD triangulation). It seems the
issue happens when the "Alternate construction" lands inside CGAL. No
surprise.
--
View this message in context: http://forum.openscad.org/Can-t-find-what-s-wrong-here-use-import-stl-and-difference-tp19123p19184.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Ronaldo, please run the code I have given for this. It rotates by 45° to
escape the 4 fix points.
--
View this message in context: http://forum.openscad.org/Can-t-find-what-s-wrong-here-use-import-stl-and-difference-tp19123p19186.html
Sent from the OpenSCAD mailing list archive at Nabble.com.