1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-22 14:23:23 +02:00
This commit is contained in:
Justin Lin
2022-03-12 22:08:36 +08:00
parent 57914a8245
commit 2f7aea6147

View File

@@ -16,29 +16,22 @@ function _triangulate_snipable(shape_pts, u, v, w, n, indices, epsilon = 0.0001)
c = shape_pts[indices[w]], c = shape_pts[indices[w]],
determinant = cross([b.x - a.x, b.y - a.y], [c.x - a.x, c.y - a.y]) determinant = cross([b.x - a.x, b.y - a.y], [c.x - a.x, c.y - a.y])
) )
epsilon > determinant ? epsilon <= determinant && _triangulate_snipable_sub(shape_pts, n, u, v, w, a, b, c, indices);
false : _triangulate_snipable_sub(shape_pts, n, u, v, w, a, b, c, indices);
function _triangulate_snipable_sub(shape_pts, n, u, v, w, a, b, c, indices, p = 0) = function _triangulate_snipable_sub(shape_pts, n, u, v, w, a, b, c, indices, p = 0) =
p == n ? true : ( p == n || (
((p == u) || (p == v) || (p == w)) ? _triangulate_snipable_sub(shape_pts, n, u, v, w, a, b, c, indices, p + 1) : ( ([p, p, p] == [u, v, w] && _triangulate_snipable_sub(shape_pts, n, u, v, w, a, b, c, indices, p + 1)) ||
_triangulate_in_triangle(a, b, c, shape_pts[indices[p]]) ? (_triangulate_snipable_sub(shape_pts, n, u, v, w, a, b, c, indices, p + 1) && !_triangulate_in_triangle(a, b, c, shape_pts[indices[p]]))
false : _triangulate_snipable_sub(shape_pts, n, u, v, w, a, b, c, indices, p + 1)
)
); );
// remove the elem at idx v from indices // remove the elem at idx v from indices
function _triangulate_remove_v(indices, v, num_of_vertices) = function _triangulate_remove_v(indices, v, num_of_vertices) =
let(nv_minuns_one = num_of_vertices - 1) let(nv_minuns_one = num_of_vertices - 1)
v == 0 ? [for(i = 1; i <= nv_minuns_one; i = i + 1) indices[i]] : ( v == 0 ? [for(i = 1; i <= nv_minuns_one; i = i + 1) indices[i]] :
v == nv_minuns_one ? [for(i = 0; i < v; i = i + 1) indices[i]] : concat( v == nv_minuns_one ? [for(i = 0; i < v; i = i + 1) indices[i]] :
[for(i = 0; i < v; i = i + 1) indices[i]], [for(i = 0; i <= nv_minuns_one; i = i + 1) if(i != v) indices[i]];
[for(i = v + 1; i <= nv_minuns_one; i = i + 1) indices[i]]
)
);
function _triangulate_zero_or_value(num_of_vertices, value) = function _triangulate_zero_or_value(num_of_vertices, value) = num_of_vertices <= value ? 0 : value;
num_of_vertices <= value ? 0 : value;
function _triangulate_real_triangulate_sub(shape_pts, collector, indices, v, num_of_vertices, count, epsilon) = function _triangulate_real_triangulate_sub(shape_pts, collector, indices, v, num_of_vertices, count, epsilon) =
let( let(
@@ -69,10 +62,9 @@ function _triangulate_snip(shape_pts, collector, indices, u, v, w, num_of_vertic
); );
function _triangulate_real_triangulate(shape_pts, collector, indices, v, num_of_vertices, count, epsilon) = function _triangulate_real_triangulate(shape_pts, collector, indices, v, num_of_vertices, count, epsilon) =
count <= 0 ? [] : ( count <= 0 ? [] :
num_of_vertices == 2 ? num_of_vertices == 2 ? collector :
collector : _triangulate_real_triangulate_sub(shape_pts, collector, indices, v, num_of_vertices, count - 1, epsilon) _triangulate_real_triangulate_sub(shape_pts, collector, indices, v, num_of_vertices, count - 1, epsilon);
);
function _tri_ear_clipping_impl(shape_pts, epsilon) = function _tri_ear_clipping_impl(shape_pts, epsilon) =
let( let(