vnf_validate() minor bugfixes.

This commit is contained in:
Garth Minette 2022-07-13 23:03:47 -07:00
parent b39e67da0e
commit f8ea3fb305

View file

@ -1403,13 +1403,13 @@ module debug_vnf(vnf, faces=true, vertices=true, opacity=0.5, size=1, convexity=
// label_faces = If true, shows labels at the center of each face that show the face number. (Module only) Default: false // label_faces = If true, shows labels at the center of each face that show the face number. (Module only) Default: false
// wireframe = If true, shows edges more clearly so you can see them in Thrown Together mode. (Module only) Default: false // wireframe = If true, shows edges more clearly so you can see them in Thrown Together mode. (Module only) Default: false
// adjacent = If true, only display faces adjacent to a vertex listed in the errors. (Module only) Default: false // adjacent = If true, only display faces adjacent to a vertex listed in the errors. (Module only) Default: false
// Example: BIG_FACE Warnings; Faces with More Than 3 Vertices. CGAL often will fail to accept that a face is planar after a rotation, if it has more than 3 vertices. // Example(3D,Edges): BIG_FACE Warnings; Faces with More Than 3 Vertices. CGAL often will fail to accept that a face is planar after a rotation, if it has more than 3 vertices.
// vnf = skin([ // vnf = skin([
// path3d(regular_ngon(n=3, d=100),0), // path3d(regular_ngon(n=3, d=100),0),
// path3d(regular_ngon(n=5, d=100),100) // path3d(regular_ngon(n=5, d=100),100)
// ], slices=0, caps=true, method="tangent"); // ], slices=0, caps=true, method="tangent");
// vnf_validate(vnf); // vnf_validate(vnf);
// Example: NONPLANAR Errors; Face Vertices are Not Coplanar // Example(3D,Edges): NONPLANAR Errors; Face Vertices are Not Coplanar
// a = [ 0, 0,-50]; // a = [ 0, 0,-50];
// b = [-50,-50, 50]; // b = [-50,-50, 50];
// c = [-50, 50, 50]; // c = [-50, 50, 50];
@ -1419,10 +1419,10 @@ module debug_vnf(vnf, faces=true, vertices=true, opacity=0.5, size=1, convexity=
// [a, b, e], [a, c, b], [a, d, c], [a, e, d], [b, c, d, e] // [a, b, e], [a, c, b], [a, d, c], [a, e, d], [b, c, d, e]
// ]); // ]);
// vnf_validate(vnf); // vnf_validate(vnf);
// Example: MULTCONN Errors; More Than Two Faces Attached to the Same Edge. This confuses CGAL, and can lead to failed renders. // Example(3D,Edges): MULTCONN Errors; More Than Two Faces Attached to the Same Edge. This confuses CGAL, and can lead to failed renders.
// vnf = vnf_triangulate(linear_sweep(union(square(50), square(50,anchor=BACK+RIGHT)), height=50)); // vnf = vnf_triangulate(linear_sweep(union(square(50), square(50,anchor=BACK+RIGHT)), height=50));
// vnf_validate(vnf); // vnf_validate(vnf);
// Example: REVERSAL Errors; Faces Reversed Across Edge // Example(3D,Edges): REVERSAL Errors; Faces Reversed Across Edge
// vnf1 = skin([ // vnf1 = skin([
// path3d(square(100,center=true),0), // path3d(square(100,center=true),0),
// path3d(square(100,center=true),100), // path3d(square(100,center=true),100),
@ -1434,27 +1434,26 @@ module debug_vnf(vnf, faces=true, vertices=true, opacity=0.5, size=1, convexity=
// [[-50,-50,100], [ 50,-50,100], [ 50, 50,100]], // [[-50,-50,100], [ 50,-50,100], [ 50, 50,100]],
// ])]); // ])]);
// vnf_validate(vnf); // vnf_validate(vnf);
// Example: T_JUNCTION Errors; Vertex is Mid-Edge on Another Face. // Example(3D,Edges): T_JUNCTION Errors; Vertex is Mid-Edge on Another Face.
// vnf1 = skin([ // vnf = [
// path3d(square(100,center=true),0), // [
// path3d(square(100,center=true),100), // each path3d(square(100,center=true),0),
// ], slices=0, caps=false); // each path3d(square(100,center=true),100),
// vnf = vnf_join([vnf1, vnf_from_polygons([ // [0,-50,100],
// [[-50,-50,0], [50,50,0], [-50,50,0]], // ], [
// [[-50,-50,0], [50,-50,0], [50,50,0]], // [0,2,1], [0,3,2], [0,8,4], [0,1,8], [1,5,8],
// [[-50,-50,100], [-50,50,100], [0,50,100]], // [0,4,3], [4,7,3], [1,2,5], [2,6,5], [3,7,6],
// [[-50,-50,100], [0,50,100], [0,-50,100]], // [3,6,2], [4,5,6], [4,6,7],
// [[0,-50,100], [0,50,100], [50,50,100]], // ]
// [[0,-50,100], [50,50,100], [50,-50,100]], // ];
// ])]);
// vnf_validate(vnf); // vnf_validate(vnf);
// Example: FACE_ISECT Errors; Faces Intersect // Example(3D,Edges): FACE_ISECT Errors; Faces Intersect
// vnf = vnf_join([ // vnf = vnf_join([
// vnf_triangulate(linear_sweep(square(100,center=true), height=100)), // vnf_triangulate(linear_sweep(square(100,center=true), height=100)),
// move([75,35,30],p=vnf_triangulate(linear_sweep(square(100,center=true), height=100))) // move([75,35,30],p=vnf_triangulate(linear_sweep(square(100,center=true), height=100)))
// ]); // ]);
// vnf_validate(vnf,size=2,check_isects=true); // vnf_validate(vnf,size=2,check_isects=true);
// Example: HOLE_EDGE Errors; Edges Adjacent to Holes. // Example(3D,Edges): HOLE_EDGE Errors; Edges Adjacent to Holes.
// vnf = skin([ // vnf = skin([
// path3d(regular_ngon(n=4, d=100),0), // path3d(regular_ngon(n=4, d=100),0),
// path3d(regular_ngon(n=5, d=100),100) // path3d(regular_ngon(n=5, d=100),100)
@ -1562,7 +1561,7 @@ function vnf_validate(vnf, show_warns=true, check_isects=false) =
pt = line_closest_point([a,c],b,SEGMENT) pt = line_closest_point([a,c],b,SEGMENT)
) )
if (approx(pt,b)) if (approx(pt,b))
_vnf_validate_err("T_JUNCTION", [b]) _vnf_validate_err("T_JUNCTION", [ib])
]), ]),
issues = concat(issues, t_juncts) issues = concat(issues, t_juncts)
) t_juncts? issues : ) t_juncts? issues :
@ -1686,7 +1685,7 @@ module vnf_validate(vnf, size=1, show_warns=true, check_isects=false, opacity=0.
clr = fault[2]; clr = fault[2];
msg = fault[3]; msg = fault[3];
idxs = fault[4]; idxs = fault[4];
pts = [for (i=idxs) if(i>=0 && i<len(verts)) verts[i]]; pts = [for (i=idxs) if(is_finite(i) && i>=0 && i<len(verts)) verts[i]];
echo(str(typ, " ", err, " (", clr ,"): ", msg, " at ", pts, " indices: ", idxs)); echo(str(typ, " ", err, " (", clr ,"): ", msg, " at ", pts, " indices: ", idxs));
color(clr) { color(clr) {
if (is_vector(pts[0])) { if (is_vector(pts[0])) {