mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 22:28:16 +01:00
flat isolines/isobands
This commit is contained in:
parent
3921f5c7fc
commit
5c37382c26
@ -118,13 +118,11 @@ module image_slicer(levels, level_step, contour_width) {
|
|||||||
|
|
||||||
module contours(points, z, contour_width) {
|
module contours(points, z, contour_width) {
|
||||||
union() {
|
union() {
|
||||||
for(row = marching_squares(points, [0, z])) {
|
for(iso_band = marching_squares(points, [0, z])) {
|
||||||
for(iso_band = row) {
|
|
||||||
polygon([for(p = iso_band) [p[0], p[1]]]);
|
polygon([for(p = iso_band) [p[0], p[1]]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for(z = [level_step:level_step:255]) {
|
for(z = [level_step:level_step:255]) {
|
||||||
linear_extrude((max_h - z) / level_step)
|
linear_extrude((max_h - z) / level_step)
|
||||||
|
@ -111,7 +111,6 @@ function _marching_squares_isolines(points, sigma) =
|
|||||||
let(labeled_pts = _isolines_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])
|
||||||
[
|
|
||||||
for(x = [0:len(labeled_pts[0]) - 2])
|
for(x = [0:len(labeled_pts[0]) - 2])
|
||||||
let(
|
let(
|
||||||
p0 = labeled_pts[y][x],
|
p0 = labeled_pts[y][x],
|
||||||
@ -123,7 +122,6 @@ function _marching_squares_isolines(points, sigma) =
|
|||||||
)
|
)
|
||||||
if(isolines_lt != [])
|
if(isolines_lt != [])
|
||||||
each isolines_lt
|
each isolines_lt
|
||||||
]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -940,7 +938,7 @@ function _case2010_isobands(cell_pts, lower, upper) =
|
|||||||
function _isobands_of(cell_pts, lower, upper) =
|
function _isobands_of(cell_pts, lower, upper) =
|
||||||
let(cv = _isobands_corner_value(cell_pts))
|
let(cv = _isobands_corner_value(cell_pts))
|
||||||
// no contour
|
// no contour
|
||||||
cv == "0000" ? [] :
|
cv == "0000" || cv == "2222" ? [] :
|
||||||
// single square
|
// single square
|
||||||
cv == "1111" ? [[for(i = 3; i >= 0; i = i - 1) [cell_pts[i][0], cell_pts[i][1]]]] :
|
cv == "1111" ? [[for(i = 3; i >= 0; i = i - 1) [cell_pts[i][0], cell_pts[i][1]]]] :
|
||||||
// single triangle
|
// single triangle
|
||||||
@ -1026,15 +1024,12 @@ function _isobands_of(cell_pts, lower, upper) =
|
|||||||
cv == "1202" ? _case1202_isobands(cell_pts, lower, upper) :
|
cv == "1202" ? _case1202_isobands(cell_pts, lower, upper) :
|
||||||
cv == "1020" ? _case1020_isobands(cell_pts, lower, upper) :
|
cv == "1020" ? _case1020_isobands(cell_pts, lower, upper) :
|
||||||
cv == "0212" ? _case0212_isobands(cell_pts, lower, upper) :
|
cv == "0212" ? _case0212_isobands(cell_pts, lower, upper) :
|
||||||
cv == "2010" ? _case2010_isobands(cell_pts, lower, upper) :
|
_case2010_isobands(cell_pts, lower, upper);
|
||||||
// no contour
|
|
||||||
[]; // 2222
|
|
||||||
|
|
||||||
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])
|
for(y = [0:len(labeled_pts) - 2])
|
||||||
[
|
|
||||||
for(x = [0:len(labeled_pts[0]) - 2])
|
for(x = [0:len(labeled_pts[0]) - 2])
|
||||||
let(
|
let(
|
||||||
p0 = labeled_pts[y][x],
|
p0 = labeled_pts[y][x],
|
||||||
@ -1046,7 +1041,6 @@ function _marching_squares_isobands(points, lower, upper) =
|
|||||||
)
|
)
|
||||||
if(isobands_lt != [])
|
if(isobands_lt != [])
|
||||||
each isobands_lt
|
each isobands_lt
|
||||||
]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -11,14 +11,11 @@ points = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
for(row = marching_squares(points, 0.1)) {
|
for(isoline = marching_squares(points, 0.1)) {
|
||||||
for(isoline = row) {
|
|
||||||
hull_polyline2d(isoline, width = .1);
|
hull_polyline2d(isoline, width = .1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
translate([12, 0]) for(row = marching_squares(points, [-.2, .2])) {
|
translate([12, 0])
|
||||||
for(isoband = row) {
|
for(isoband = marching_squares(points, [-.2, .2])) {
|
||||||
polygon([for(p = isoband) [p[0], p[1]]]);
|
polygon([for(p = isoband) [p[0], p[1]]]);
|
||||||
}
|
|
||||||
}
|
}
|
@ -111,9 +111,7 @@ points = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for(z = [0:40:255]) {
|
for(z = [0:40:255]) {
|
||||||
for(row = marching_squares(points, z)) {
|
for(isoline = marching_squares(points, z)) {
|
||||||
for(isoline = row) {
|
|
||||||
hull_polyline2d(isoline, width = .25);
|
hull_polyline2d(isoline, width = .25);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -27,6 +27,7 @@ Preview
|
|||||||
- `util/dedup`
|
- `util/dedup`
|
||||||
- `util/bsearch`
|
- `util/bsearch`
|
||||||
- `util/sort` supports `by = "vt"`
|
- `util/sort` supports `by = "vt"`
|
||||||
|
- `shape_circle`
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
- `helix_extrude`: wrong orientation when CLK
|
- `helix_extrude`: wrong orientation when CLK
|
Loading…
x
Reference in New Issue
Block a user