1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-29 11:58:39 +01:00

because [each undef] is []

This commit is contained in:
Justin Lin 2022-04-28 09:08:22 +08:00
parent d06455082e
commit aff15eae5e

View File

@ -22,21 +22,16 @@ module sf_thickenT(points, thickness, triangles = undef, direction = "BOTH", con
real_triangles = is_undef(triangles) ? tri_delaunay([for(p = points) __to2d(p)]) : triangles;
function connected_tris(leng_pts, triangles) =
let(
leng = len(triangles),
cnt_tris = [for(i = [0:leng_pts - 1]) []]
)
_connected_tris(triangles, leng, leng_pts, cnt_tris);
let(leng = len(triangles))
_connected_tris(triangles, leng, leng_pts, []);
function _connected_tris(triangles, leng, leng_pts, cnt_tris, i = 0) =
i == leng ? cnt_tris :
let(
tri = reverse(triangles[i]),
tri = reverse(triangles[i]), // OpenSCAD requires clockwise
n_cnt_tris = [
for(k = [0:leng_pts - 1])
contains(tri, k) ?
// OpenSCAD requires clockwise
[each cnt_tris[k], tri] : cnt_tris[k]
contains(tri, k) ? [each cnt_tris[k], tri] : cnt_tris[k]
]
)
_connected_tris(triangles, leng, leng_pts, n_cnt_tris, i + 1);