mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-30 00:09:37 +00:00
fix debug_vnf for case with collinear edges in a face
This commit is contained in:
parent
0048336ad3
commit
75f7a75ac2
1 changed files with 18 additions and 22 deletions
40
vnf.scad
40
vnf.scad
|
@ -906,6 +906,8 @@ function _vnf_sort_vertices(vnf, idx=[2,1,0]) =
|
||||||
) sorted_vnf;
|
) sorted_vnf;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Function: vnf_slice()
|
// Function: vnf_slice()
|
||||||
// Synopsis: Slice the faces of a VNF along an axis.
|
// Synopsis: Slice the faces of a VNF along an axis.
|
||||||
// SynTags: VNF
|
// SynTags: VNF
|
||||||
|
@ -1613,34 +1615,28 @@ module _show_faces(vertices, faces, size=1, filter) {
|
||||||
for (i = [0:1:len(faces)-1]) {
|
for (i = [0:1:len(faces)-1]) {
|
||||||
face = faces[i];
|
face = faces[i];
|
||||||
if (face[0] < 0 || face[1] < 0 || face[2] < 0 || face[0] >= vlen || face[1] >= vlen || face[2] >= vlen) {
|
if (face[0] < 0 || face[1] < 0 || face[2] < 0 || face[0] >= vlen || face[1] >= vlen || face[2] >= vlen) {
|
||||||
echo("BAD FACE: ", vlen=vlen, face=face);
|
echo(str("INVALID FACE: indices of face ",i," are out of bounds [0,",vlen-1,"]: face=",face));
|
||||||
} else if (is_undef(filter) || any(face,filter)) {
|
}
|
||||||
|
else if (is_undef(filter) || any(face,filter)) {
|
||||||
verts = select(vertices,face);
|
verts = select(vertices,face);
|
||||||
c = mean(verts);
|
normal = polygon_normal(verts);
|
||||||
v0 = verts[0];
|
if (is_undef(normal))
|
||||||
v1 = verts[1];
|
echo(str("DEGENERATE FACE: face ",i," has no normal vector, face=", face));
|
||||||
v2 = verts[2];
|
else {
|
||||||
dv0 = unit(v1 - v0);
|
axis = vector_axis(normal, DOWN);
|
||||||
dv1 = unit(v2 - v0);
|
ang = vector_angle(normal, DOWN);
|
||||||
nrm0 = cross(dv0, dv1);
|
theta = atan2(normal[1], normal[0]);
|
||||||
nrm1 = UP;
|
translate(mean(verts))
|
||||||
axis = vector_axis(nrm0, nrm1);
|
rotate(a=(180-ang), v=axis)
|
||||||
ang = vector_angle(nrm0, nrm1);
|
zrot(theta+90)
|
||||||
theta = atan2(nrm0[1], nrm0[0]);
|
linear_extrude(height=size/10, center=true, convexity=10) {
|
||||||
translate(c) {
|
|
||||||
rotate(a=180-ang, v=axis) {
|
|
||||||
zrot(theta-90)
|
|
||||||
linear_extrude(height=size/10, center=true, convexity=10) {
|
|
||||||
union() {
|
|
||||||
text(text=str(i), size=size, halign="center");
|
text(text=str(i), size=size, halign="center");
|
||||||
text(text=str("_"), size=size, halign="center");
|
text(text=str("_"), size=size, halign="center");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue