mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-15 03:05:41 +02:00
refactor
This commit is contained in:
@@ -15,6 +15,9 @@ module function_grapher(points, thickness, style = "FACES", slicing = "SLASH") {
|
|||||||
rows = len(points);
|
rows = len(points);
|
||||||
columns = len(points[0]);
|
columns = len(points[0]);
|
||||||
|
|
||||||
|
yi_range = [0:rows - 2];
|
||||||
|
xi_range = [0:columns - 2];
|
||||||
|
|
||||||
// Increasing $fn will be slow when you use "LINES", "HULL_FACES" or "HULL_LINES".
|
// Increasing $fn will be slow when you use "LINES", "HULL_FACES" or "HULL_LINES".
|
||||||
|
|
||||||
module faces() {
|
module faces() {
|
||||||
@@ -34,16 +37,16 @@ module function_grapher(points, thickness, style = "FACES", slicing = "SLASH") {
|
|||||||
leng_pts = len(top_pts);
|
leng_pts = len(top_pts);
|
||||||
|
|
||||||
top_tri_faces1 = slicing == "SLASH" ? [
|
top_tri_faces1 = slicing == "SLASH" ? [
|
||||||
for(yi = [0:rows - 2])
|
for(yi = yi_range)
|
||||||
for(xi = [0:columns - 2])
|
for(xi = xi_range)
|
||||||
[
|
[
|
||||||
xy_to_index(xi, yi, columns),
|
xy_to_index(xi, yi, columns),
|
||||||
xy_to_index(xi + 1, yi + 1, columns),
|
xy_to_index(xi + 1, yi + 1, columns),
|
||||||
xy_to_index(xi + 1, yi, columns)
|
xy_to_index(xi + 1, yi, columns)
|
||||||
]
|
]
|
||||||
] : [
|
] : [
|
||||||
for(yi = [0:rows - 2])
|
for(yi = yi_range)
|
||||||
for(xi = [0:columns - 2])
|
for(xi = xi_range)
|
||||||
[
|
[
|
||||||
xy_to_index(xi, yi, columns),
|
xy_to_index(xi, yi, columns),
|
||||||
xy_to_index(xi, yi + 1, columns),
|
xy_to_index(xi, yi + 1, columns),
|
||||||
@@ -52,16 +55,16 @@ module function_grapher(points, thickness, style = "FACES", slicing = "SLASH") {
|
|||||||
];
|
];
|
||||||
|
|
||||||
top_tri_faces2 = slicing == "SLASH" ? [
|
top_tri_faces2 = slicing == "SLASH" ? [
|
||||||
for(yi = [0:rows - 2])
|
for(yi = yi_range)
|
||||||
for(xi = [0:columns - 2])
|
for(xi = xi_range)
|
||||||
[
|
[
|
||||||
xy_to_index(xi, yi, columns),
|
xy_to_index(xi, yi, columns),
|
||||||
xy_to_index(xi, yi + 1, columns),
|
xy_to_index(xi, yi + 1, columns),
|
||||||
xy_to_index(xi + 1, yi + 1, columns)
|
xy_to_index(xi + 1, yi + 1, columns)
|
||||||
]
|
]
|
||||||
] : [
|
] : [
|
||||||
for(yi = [0:rows - 2])
|
for(yi = yi_range)
|
||||||
for(xi = [0:columns - 2])
|
for(xi = xi_range)
|
||||||
[
|
[
|
||||||
xy_to_index(xi, yi + 1, columns),
|
xy_to_index(xi, yi + 1, columns),
|
||||||
xy_to_index(xi + 1, yi + 1, columns),
|
xy_to_index(xi + 1, yi + 1, columns),
|
||||||
@@ -80,7 +83,7 @@ module function_grapher(points, thickness, style = "FACES", slicing = "SLASH") {
|
|||||||
];
|
];
|
||||||
|
|
||||||
side_faces1 = [
|
side_faces1 = [
|
||||||
for(xi = [0:columns - 2])
|
for(xi = xi_range)
|
||||||
let(
|
let(
|
||||||
idx1 = xy_to_index(xi, 0, columns),
|
idx1 = xy_to_index(xi, 0, columns),
|
||||||
idx2 = xy_to_index(xi + 1, 0, columns)
|
idx2 = xy_to_index(xi + 1, 0, columns)
|
||||||
@@ -94,7 +97,7 @@ module function_grapher(points, thickness, style = "FACES", slicing = "SLASH") {
|
|||||||
];
|
];
|
||||||
|
|
||||||
side_faces2 = [
|
side_faces2 = [
|
||||||
for(yi = [0:rows - 2])
|
for(yi = yi_range)
|
||||||
let(
|
let(
|
||||||
xi = columns - 1,
|
xi = columns - 1,
|
||||||
idx1 = xy_to_index(xi, yi, columns),
|
idx1 = xy_to_index(xi, yi, columns),
|
||||||
@@ -109,7 +112,7 @@ module function_grapher(points, thickness, style = "FACES", slicing = "SLASH") {
|
|||||||
];
|
];
|
||||||
|
|
||||||
side_faces3 = [
|
side_faces3 = [
|
||||||
for(xi = [0:columns - 2])
|
for(xi = xi_range)
|
||||||
let(
|
let(
|
||||||
yi = rows - 1,
|
yi = rows - 1,
|
||||||
idx1 = xy_to_index(xi, yi, columns),
|
idx1 = xy_to_index(xi, yi, columns),
|
||||||
@@ -124,7 +127,7 @@ module function_grapher(points, thickness, style = "FACES", slicing = "SLASH") {
|
|||||||
];
|
];
|
||||||
|
|
||||||
side_faces4 = [
|
side_faces4 = [
|
||||||
for(yi = [0:rows - 2])
|
for(yi = yi_range)
|
||||||
let(
|
let(
|
||||||
idx1 = xy_to_index(0, yi, columns),
|
idx1 = xy_to_index(0, yi, columns),
|
||||||
idx2 = xy_to_index(0, yi + 1, columns)
|
idx2 = xy_to_index(0, yi + 1, columns)
|
||||||
@@ -193,8 +196,8 @@ module function_grapher(points, thickness, style = "FACES", slicing = "SLASH") {
|
|||||||
if(style == "FACES") {
|
if(style == "FACES") {
|
||||||
faces();
|
faces();
|
||||||
} else {
|
} else {
|
||||||
for(yi = [0:rows - 2]) {
|
for(yi = yi_range) {
|
||||||
for(xi = [0:columns - 2]) {
|
for(xi = xi_range) {
|
||||||
if(slicing == "SLASH") {
|
if(slicing == "SLASH") {
|
||||||
tri_to_graph([
|
tri_to_graph([
|
||||||
points[yi][xi],
|
points[yi][xi],
|
||||||
|
Reference in New Issue
Block a user