mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-19 04:51:26 +02:00
refactor
This commit is contained in:
@@ -116,17 +116,21 @@ function _isolines_of(cell_pts, threshold) =
|
|||||||
function _marching_squares_isolines(points, threshold) =
|
function _marching_squares_isolines(points, threshold) =
|
||||||
let(labeled_pts = _isolines_pn_label(points, threshold))
|
let(labeled_pts = _isolines_pn_label(points, threshold))
|
||||||
[
|
[
|
||||||
for(y = [0:len(labeled_pts) - 2], x = [0:len(labeled_pts[0]) - 2])
|
for(y = [0:len(labeled_pts) - 2])
|
||||||
let(
|
let(
|
||||||
p0 = labeled_pts[y][x],
|
labeled_pts_y = labeled_pts[y],
|
||||||
p1 = labeled_pts[y + 1][x],
|
labeled_pts_y_1 = labeled_pts[y + 1]
|
||||||
p2 = labeled_pts[y + 1][x + 1],
|
)
|
||||||
p3 = labeled_pts[y][x + 1],
|
for(x = [0:len(labeled_pts[0]) - 2])
|
||||||
cell_pts = [p0, p1, p2, p3],
|
each _isolines_of(
|
||||||
isolines_lt = _isolines_of(cell_pts, threshold)
|
[
|
||||||
|
labeled_pts_y[x],
|
||||||
|
labeled_pts_y_1[x],
|
||||||
|
labeled_pts_y_1[x + 1],
|
||||||
|
labeled_pts_y[x + 1]
|
||||||
|
],
|
||||||
|
threshold
|
||||||
)
|
)
|
||||||
if(isolines_lt != [])
|
|
||||||
each isolines_lt
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -143,9 +147,8 @@ function _isobands_tri_label(pts, lower, upper) =
|
|||||||
[
|
[
|
||||||
for(p = row)
|
for(p = row)
|
||||||
let(
|
let(
|
||||||
z = p.z,
|
label = p.z < lower ? 0 :
|
||||||
label = z < lower ? "0" :
|
p.z > upper ? 2 : 1
|
||||||
z >= lower && z <= upper ? "1" : "2"
|
|
||||||
)
|
)
|
||||||
[each p, label]
|
[each p, label]
|
||||||
]
|
]
|
||||||
@@ -1391,17 +1394,18 @@ function _isobands_of(cell_pts, lower, upper) =
|
|||||||
function _marching_squares_isobands(points, lower, upper) =
|
function _marching_squares_isobands(points, lower, upper) =
|
||||||
let(labeled_pts = _isobands_tri_label(points, lower, upper))
|
let(labeled_pts = _isobands_tri_label(points, lower, upper))
|
||||||
[
|
[
|
||||||
for(y = [0:len(labeled_pts) - 2], x = [0:len(labeled_pts[0]) - 2])
|
for(y = [0:len(labeled_pts) - 2])
|
||||||
let(
|
let(labeled_pts_y = labeled_pts[y], labeled_pts_y_1 = labeled_pts[y + 1])
|
||||||
p0 = labeled_pts[y][x],
|
for(x = [0:len(labeled_pts[0]) - 2])
|
||||||
p1 = labeled_pts[y + 1][x],
|
each _isobands_of(
|
||||||
p2 = labeled_pts[y + 1][x + 1],
|
[
|
||||||
p3 = labeled_pts[y][x + 1],
|
labeled_pts_y[x],
|
||||||
cell_pts = [p0, p1, p2, p3],
|
labeled_pts_y_1[x],
|
||||||
isobands_lt = _isobands_of(cell_pts, lower, upper)
|
labeled_pts_y_1[x + 1],
|
||||||
)
|
labeled_pts_y[x + 1]
|
||||||
if(isobands_lt != [])
|
],
|
||||||
each isobands_lt
|
lower, upper
|
||||||
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user