1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-14 10:44:48 +02:00

path 2d to 3d automatically

This commit is contained in:
Justin Lin
2017-05-17 09:35:38 +08:00
parent dbc69b80c2
commit b8c9748043

View File

@@ -18,8 +18,9 @@ include <__private__/__to3d.scad>;
module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale = 1.0, closed = false) { module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale = 1.0, closed = false) {
sh_pts = len(shape_pts[0]) == 3 ? shape_pts : [for(p = shape_pts) __to3d(p)]; sh_pts = len(shape_pts[0]) == 3 ? shape_pts : [for(p = shape_pts) __to3d(p)];
pth_pts = len(path_pts[0]) == 3 ? path_pts : [for(p = path_pts) __to3d(p)];
len_path_pts = len(path_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;
scale_step_vt = __is_vector(scale) ? scale_step_vt = __is_vector(scale) ?
@@ -32,8 +33,8 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale =
function first_section() = function first_section() =
let( let(
p1 = path_pts[0], p1 = pth_pts[0],
p2 = path_pts[1], p2 = pth_pts[1],
dx = p2[0] - p1[0], dx = p2[0] - p1[0],
dy = p2[1] - p1[1], dy = p2[1] - p1[1],
dz = p2[2] - p1[2], dz = p2[2] - p1[2],
@@ -68,11 +69,11 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale =
function path_extrude_inner(index) = function path_extrude_inner(index) =
index == len_path_pts ? [] : index == len_path_pts ? [] :
concat( concat(
[section(path_pts[index - 1], path_pts[index], index)], [section(pth_pts[index - 1], pth_pts[index], index)],
path_extrude_inner(index + 1) path_extrude_inner(index + 1)
); );
if(closed && path_pts[0] == path_pts[len_path_pts_minus_one]) { if(closed && pth_pts[0] == pth_pts[len_path_pts_minus_one]) {
// round-robin // round-robin
sections = path_extrude_inner(1); sections = path_extrude_inner(1);
polysections( polysections(