mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-13 18:24:28 +02:00
rename
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
function _contours_pn_label(pts, sigma) =
|
function _isolines_pn_label(pts, sigma) =
|
||||||
[
|
[
|
||||||
for(row = pts)
|
for(row = pts)
|
||||||
[for(p = row) [p[0], p[1], p[2], p[2] - sigma >= 0]]
|
[for(p = row) [p[0], p[1], p[2], p[2] - sigma >= 0]]
|
||||||
];
|
];
|
||||||
|
|
||||||
function _contours_corner_value(cell_pts) =
|
function _isolines_corner_value(cell_pts) =
|
||||||
let(
|
let(
|
||||||
c0 = cell_pts[0][3] ? 1 : 0,
|
c0 = cell_pts[0][3] ? 1 : 0,
|
||||||
c1 = cell_pts[1][3] ? 2 : 0,
|
c1 = cell_pts[1][3] ? 2 : 0,
|
||||||
@@ -23,23 +23,23 @@ function interpolated_pt(p0, p1, sigma) =
|
|||||||
)
|
)
|
||||||
[x0 + v[0] * t, y0 + v[1] * t];
|
[x0 + v[0] * t, y0 + v[1] * t];
|
||||||
|
|
||||||
function _case1_contours(cell_pts, sigma) = [
|
function _case1_isolines(cell_pts, sigma) = [
|
||||||
[interpolated_pt(cell_pts[0], cell_pts[1], sigma), interpolated_pt(cell_pts[0], cell_pts[3], sigma)]
|
[interpolated_pt(cell_pts[0], cell_pts[1], sigma), interpolated_pt(cell_pts[0], cell_pts[3], sigma)]
|
||||||
];
|
];
|
||||||
|
|
||||||
function _case2_contours(cell_pts, sigma) = [
|
function _case2_isolines(cell_pts, sigma) = [
|
||||||
[interpolated_pt(cell_pts[0], cell_pts[3], sigma), interpolated_pt(cell_pts[2], cell_pts[3], sigma)]
|
[interpolated_pt(cell_pts[0], cell_pts[3], sigma), interpolated_pt(cell_pts[2], cell_pts[3], sigma)]
|
||||||
];
|
];
|
||||||
|
|
||||||
function _case3_contours(cell_pts, sigma) = [
|
function _case3_isolines(cell_pts, sigma) = [
|
||||||
[interpolated_pt(cell_pts[0], cell_pts[1], sigma), interpolated_pt(cell_pts[2], cell_pts[3], sigma)]
|
[interpolated_pt(cell_pts[0], cell_pts[1], sigma), interpolated_pt(cell_pts[2], cell_pts[3], sigma)]
|
||||||
];
|
];
|
||||||
|
|
||||||
function _case4_contours(cell_pts, sigma) = [
|
function _case4_isolines(cell_pts, sigma) = [
|
||||||
[interpolated_pt(cell_pts[1], cell_pts[2], sigma), interpolated_pt(cell_pts[2], cell_pts[3], sigma)]
|
[interpolated_pt(cell_pts[1], cell_pts[2], sigma), interpolated_pt(cell_pts[2], cell_pts[3], sigma)]
|
||||||
];
|
];
|
||||||
|
|
||||||
function _case5_contours(cell_pts, sigma) =
|
function _case5_isolines(cell_pts, sigma) =
|
||||||
let(mdpz = ((cell_pts[0] + cell_pts[1]) / 2)[2])
|
let(mdpz = ((cell_pts[0] + cell_pts[1]) / 2)[2])
|
||||||
mdpz >= sigma ?
|
mdpz >= sigma ?
|
||||||
[
|
[
|
||||||
@@ -52,19 +52,19 @@ function _case5_contours(cell_pts, sigma) =
|
|||||||
[interpolated_pt(cell_pts[1], cell_pts[2], sigma), interpolated_pt(cell_pts[2], cell_pts[3], sigma)]
|
[interpolated_pt(cell_pts[1], cell_pts[2], sigma), interpolated_pt(cell_pts[2], cell_pts[3], sigma)]
|
||||||
];
|
];
|
||||||
|
|
||||||
function _case6_contours(cell_pts, sigma) = [
|
function _case6_isolines(cell_pts, sigma) = [
|
||||||
[interpolated_pt(cell_pts[1], cell_pts[2], sigma), interpolated_pt(cell_pts[0], cell_pts[3], sigma)]
|
[interpolated_pt(cell_pts[1], cell_pts[2], sigma), interpolated_pt(cell_pts[0], cell_pts[3], sigma)]
|
||||||
];
|
];
|
||||||
|
|
||||||
function _case7_contours(cell_pts, sigma) = [
|
function _case7_isolines(cell_pts, sigma) = [
|
||||||
[interpolated_pt(cell_pts[0], cell_pts[1], sigma), interpolated_pt(cell_pts[1], cell_pts[2], sigma)]
|
[interpolated_pt(cell_pts[0], cell_pts[1], sigma), interpolated_pt(cell_pts[1], cell_pts[2], sigma)]
|
||||||
];
|
];
|
||||||
|
|
||||||
function _case8_contours(cell_pts, sigma) = _case7_contours(cell_pts, sigma);
|
function _case8_isolines(cell_pts, sigma) = _case7_isolines(cell_pts, sigma);
|
||||||
|
|
||||||
function _case9_contours(cell_pts, sigma) = _case6_contours(cell_pts, sigma);
|
function _case9_isolines(cell_pts, sigma) = _case6_isolines(cell_pts, sigma);
|
||||||
|
|
||||||
function _case10_contours(cell_pts, sigma) =
|
function _case10_isolines(cell_pts, sigma) =
|
||||||
let(mdpz = ((cell_pts[0] + cell_pts[1]) / 2)[2])
|
let(mdpz = ((cell_pts[0] + cell_pts[1]) / 2)[2])
|
||||||
mdpz >= sigma ?
|
mdpz >= sigma ?
|
||||||
[
|
[
|
||||||
@@ -77,28 +77,28 @@ function _case10_contours(cell_pts, sigma) =
|
|||||||
[interpolated_pt(cell_pts[0], cell_pts[3], sigma), interpolated_pt(cell_pts[2], cell_pts[3], sigma)]
|
[interpolated_pt(cell_pts[0], cell_pts[3], sigma), interpolated_pt(cell_pts[2], cell_pts[3], sigma)]
|
||||||
];
|
];
|
||||||
|
|
||||||
function _case11_contours(cell_pts, sigma) = _case4_contours(cell_pts, sigma);
|
function _case11_isolines(cell_pts, sigma) = _case4_isolines(cell_pts, sigma);
|
||||||
|
|
||||||
function _case12_contours(cell_pts, sigma) = _case3_contours(cell_pts, sigma);
|
function _case12_isolines(cell_pts, sigma) = _case3_isolines(cell_pts, sigma);
|
||||||
|
|
||||||
function _case13_contours(cell_pts, sigma) = _case2_contours(cell_pts, sigma);
|
function _case13_isolines(cell_pts, sigma) = _case2_isolines(cell_pts, sigma);
|
||||||
|
|
||||||
function _case14_contours(cell_pts, sigma) = _case1_contours(cell_pts, sigma);
|
function _case14_isolines(cell_pts, sigma) = _case1_isolines(cell_pts, sigma);
|
||||||
|
|
||||||
function _contours_of(cell_pts, sigma) =
|
function _isolines_of(cell_pts, sigma) =
|
||||||
let(cv = _contours_corner_value(cell_pts))
|
let(cv = _isolines_corner_value(cell_pts))
|
||||||
cv == 0 ? [] :
|
cv == 0 ? [] :
|
||||||
cv == 1 ? _case1_contours(cell_pts, sigma) :
|
cv == 1 ? _case1_isolines(cell_pts, sigma) :
|
||||||
cv == 8 ? _case2_contours(cell_pts, sigma) :
|
cv == 8 ? _case2_isolines(cell_pts, sigma) :
|
||||||
cv == 9 ? _case3_contours(cell_pts, sigma) :
|
cv == 9 ? _case3_isolines(cell_pts, sigma) :
|
||||||
cv == 4 ? _case4_contours(cell_pts, sigma) :
|
cv == 4 ? _case4_isolines(cell_pts, sigma) :
|
||||||
cv == 5 ? _case5_contours(cell_pts, sigma) :
|
cv == 5 ? _case5_isolines(cell_pts, sigma) :
|
||||||
cv == 12 ? _case6_contours(cell_pts, sigma) :
|
cv == 12 ? _case6_isolines(cell_pts, sigma) :
|
||||||
cv == 13 ? _case7_contours(cell_pts, sigma) :
|
cv == 13 ? _case7_isolines(cell_pts, sigma) :
|
||||||
cv == 2 ? _case8_contours(cell_pts, sigma) :
|
cv == 2 ? _case8_isolines(cell_pts, sigma) :
|
||||||
cv == 3 ? _case9_contours(cell_pts, sigma) :
|
cv == 3 ? _case9_isolines(cell_pts, sigma) :
|
||||||
cv == 10 ? _case10_contours(cell_pts, sigma) :
|
cv == 10 ? _case10_isolines(cell_pts, sigma) :
|
||||||
cv == 11 ? _case11_contours(cell_pts, sigma) :
|
cv == 11 ? _case11_isolines(cell_pts, sigma) :
|
||||||
cv == 6 ? _case12_contours(cell_pts, sigma) :
|
cv == 6 ? _case12_isolines(cell_pts, sigma) :
|
||||||
cv == 7 ? _case13_contours(cell_pts, sigma) :
|
cv == 7 ? _case13_isolines(cell_pts, sigma) :
|
||||||
cv == 14 ? _case14_contours(cell_pts, sigma) : [];
|
cv == 14 ? _case14_isolines(cell_pts, sigma) : [];
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
use <experimental/_impl/_marching_squares_impl.scad>;
|
use <experimental/_impl/_marching_squares_impl.scad>;
|
||||||
|
|
||||||
function marching_squares(points, sigma) =
|
function marching_squares(points, sigma) =
|
||||||
let(labeled_pts = _contours_pn_label(points, sigma))
|
let(labeled_pts = _isolines_pn_label(points, sigma))
|
||||||
[
|
[
|
||||||
for(y = [0:len(labeled_pts) - 2])
|
for(y = [0:len(labeled_pts) - 2])
|
||||||
[
|
[
|
||||||
@@ -12,9 +12,9 @@ function marching_squares(points, sigma) =
|
|||||||
p2 = labeled_pts[y + 1][x + 1],
|
p2 = labeled_pts[y + 1][x + 1],
|
||||||
p3 = labeled_pts[y][x + 1],
|
p3 = labeled_pts[y][x + 1],
|
||||||
cell_pts = [p0, p1, p2, p3],
|
cell_pts = [p0, p1, p2, p3],
|
||||||
contours_lt = _contours_of(cell_pts, sigma)
|
isolines_lt = _isolines_of(cell_pts, sigma)
|
||||||
)
|
)
|
||||||
if(contours_lt != [])
|
if(isolines_lt != [])
|
||||||
each contours_lt
|
each isolines_lt
|
||||||
]
|
]
|
||||||
];
|
];
|
Reference in New Issue
Block a user