mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-02-24 17:42:44 +01:00
refactor
This commit is contained in:
parent
0e37195ede
commit
48603db468
@ -1,3 +1,4 @@
|
||||
use <experimental/_impl/_sf_square_surfaces.scad>;
|
||||
use <experimental/sf_solidify.scad>;
|
||||
use <experimental/tf_bend.scad>;
|
||||
|
||||
@ -9,38 +10,22 @@ use <experimental/tf_bend.scad>;
|
||||
invert: inverts how the gray levels are translated into height values.
|
||||
*/
|
||||
module sf_bend(levels, radius, thickness, angle, invert = false) {
|
||||
surface = _sf_square_surfaces(levels, thickness, invert);
|
||||
rows = len(levels);
|
||||
columns = len(levels[0]);
|
||||
size = [columns - 1, rows - 1];
|
||||
|
||||
surface1 = [
|
||||
for(r = [0:rows - 1])
|
||||
[
|
||||
for(c = [0:columns - 1])
|
||||
let(lv = invert ? 255 - levels[rows - r - 1][c] : levels[rows - r - 1][c])
|
||||
[c, r, lv / 255 * thickness]
|
||||
]
|
||||
];
|
||||
|
||||
surface2 = [
|
||||
for(r = [0:rows - 1])
|
||||
[
|
||||
for(c = [0:columns - 1])
|
||||
[c, r, 0]
|
||||
]
|
||||
];
|
||||
|
||||
offset_z = invert ? thickness : 0;
|
||||
sf_solidify(
|
||||
[
|
||||
for(row = surface1)
|
||||
for(row = surface[0])
|
||||
[
|
||||
for(p = row)
|
||||
tf_bend(size, p, radius + offset_z, angle)
|
||||
]
|
||||
],
|
||||
[
|
||||
for(row = surface2)
|
||||
for(row = surface[1])
|
||||
[
|
||||
for(p = row) tf_bend(size, p, radius, angle)
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user