1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-06 14:56:47 +02:00
This commit is contained in:
Justin Lin
2019-06-15 21:14:16 +08:00
parent 2110b9cb31
commit 03ac58acaa

View File

@@ -18,7 +18,6 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale =
len_path_pts = len(pth_pts); len_path_pts = len(pth_pts);
len_path_pts_minus_one = len_path_pts - 1; len_path_pts_minus_one = len_path_pts - 1;
module axis_angle_path_extrude() { module axis_angle_path_extrude() {
twist_step_a = twist / len_path_pts; twist_step_a = twist / len_path_pts;
@@ -47,16 +46,16 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale =
// get rotation matrice for sections // get rotation matrice for sections
function local_ang_vects(j) = function local_ang_vects(j) =
j == 0 ? [] : local_ang_vects_sub(j); [
for(i = j; i > 0; i = i - 1)
function local_ang_vects_sub(j) = let(
let( vt0 = pth_pts[i] - pth_pts[i - 1],
vt0 = pth_pts[j] - pth_pts[j - 1], vt1 = pth_pts[i + 1] - pth_pts[i],
vt1 = pth_pts[j + 1] - pth_pts[j], a = acos((vt0 * vt1) / (norm(vt0) * norm(vt1))),
a = acos((vt0 * vt1) / (norm(vt0) * norm(vt1))), v = cross(vt0, vt1)
v = cross(vt0, vt1) )
) [a, v]
concat([[a, v]], local_ang_vects(j - 1)); ];
rot_matrice = [ rot_matrice = [
for(ang_vect = local_ang_vects(len_path_pts - 2)) for(ang_vect = local_ang_vects(len_path_pts - 2))
@@ -132,27 +131,25 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale =
let( let(
fst_section = fst_section =
translate_pts(local_rotate_section(0, 0, [1, 1, 1]), pth_pts[0]), translate_pts(local_rotate_section(0, 0, [1, 1, 1]), pth_pts[0]),
end_i = len_path_pts - 1,
remain_sections = [ remain_sections = [
for(i = [0:len_path_pts - 2]) for(i = 0; i < end_i; i = i + 1)
translate_pts( translate_pts(
local_rotate_section(i, i * twist_step_a, [1, 1, 1] + scale_step_vt * i), local_rotate_section(i, i * twist_step_a, [1, 1, 1] + scale_step_vt * i),
pth_pts[i + 1] pth_pts[i + 1]
) )
] ]
) concat([fst_section], remain_sections); ) concat([fst_section], remain_sections);
sects = sections(); sects = sections();
function calculated_sections() = calculated_sections =
closed && pth_pts[0] == pth_pts[len_path_pts_minus_one] ? closed && pth_pts[0] == pth_pts[len_path_pts_minus_one] ?
concat(sects, [sects[0]]) : // round-robin concat(sects, [sects[0]]) : // round-robin
sects; sects;
polysections( polysections(
calculated_sections(), calculated_sections,
triangles = triangles triangles = triangles
); );
@@ -187,28 +184,24 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale =
) + p1 ) + p1
]; ];
function path_extrude_inner(index) = path_extrude_inner =
index == len_path_pts ? [] : [
concat( for(i = 1; i < len_path_pts; i = i + 1)
[section(pth_pts[index - 1], pth_pts[index], index)], section(pth_pts[i - 1], pth_pts[i], i)
path_extrude_inner(index + 1) ];
);
function calculated_sections() = calculated_sections =
let(sections = path_extrude_inner(1))
closed && pth_pts[0] == pth_pts[len_path_pts_minus_one] ? closed && pth_pts[0] == pth_pts[len_path_pts_minus_one] ?
concat(sections, [sections[0]]) : // round-robin concat(path_extrude_inner, [path_extrude_inner[0]]) : // round-robin
concat([section(pth_pts[0], pth_pts[1], 0)], sections); concat([section(pth_pts[0], pth_pts[1], 0)], path_extrude_inner);
sections = calculated_sections();
polysections( polysections(
sections, calculated_sections,
triangles = triangles triangles = triangles
); );
// hook for testing // hook for testing
test_path_extrude(sections); test_path_extrude(calculated_sections);
} }
if(method == "AXIS_ANGLE") { if(method == "AXIS_ANGLE") {
@@ -219,7 +212,6 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale =
} }
} }
// override to test // override to test
module test_path_extrude(sections) { module test_path_extrude(sections) {