mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-11 01:04:07 +02:00
always sort before dedup
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
use <experimental/_impl/_mz_hamiltonian_impl.scad>;
|
use <experimental/_impl/_mz_hamiltonian_impl.scad>;
|
||||||
use <experimental/mz_blocks.scad>;
|
use <experimental/mz_blocks.scad>;
|
||||||
use <experimental/mz_get.scad>;
|
use <experimental/mz_get.scad>;
|
||||||
|
use <util/sort.scad>;
|
||||||
use <util/dedup.scad>;
|
use <util/dedup.scad>;
|
||||||
|
|
||||||
function mz_hamiltonian(rows, columns, start) =
|
function mz_hamiltonian(rows, columns, start) =
|
||||||
@@ -9,23 +10,22 @@ function mz_hamiltonian(rows, columns, start) =
|
|||||||
[1, 1],
|
[1, 1],
|
||||||
rows, columns
|
rows, columns
|
||||||
),
|
),
|
||||||
dot_pts = dedup(
|
all = concat(
|
||||||
concat(
|
[
|
||||||
[
|
for(block = blocks)
|
||||||
for(block = blocks)
|
let(
|
||||||
let(
|
x = mz_get(block, "x"),
|
||||||
x = mz_get(block, "x"),
|
y = mz_get(block, "y"),
|
||||||
y = mz_get(block, "y"),
|
wall_type = mz_get(block, "w"),
|
||||||
wall_type = mz_get(block, "w"),
|
pts = wall_type == "UPPER_WALL" ? _mz_hamiltonian_upper(x, y) :
|
||||||
pts = wall_type == "UPPER_WALL" ? _mz_hamiltonian_upper(x, y) :
|
wall_type == "RIGHT_WALL" ? _mz_hamiltonian_right(x, y) :
|
||||||
wall_type == "RIGHT_WALL" ? _mz_hamiltonian_right(x, y) :
|
wall_type == "UPPER_RIGHT_WALL" ? _mz_hamiltonian_upper_right(x, y) : []
|
||||||
wall_type == "UPPER_RIGHT_WALL" ? _mz_hamiltonian_upper_right(x, y) : []
|
)
|
||||||
)
|
each pts
|
||||||
each pts
|
],
|
||||||
],
|
[for(x = [0:columns * 2 - 1]) [x, 0]],
|
||||||
[for(x = [0:columns * 2 - 1]) [x, 0]],
|
[for(y = [0:rows * 2 - 1]) [0, y]]
|
||||||
[for(y = [0:rows * 2 - 1]) [0, y]]
|
),
|
||||||
)
|
dot_pts = dedup(sort(sort(all, by = "x"), by = "y"), sorted = true)
|
||||||
)
|
|
||||||
)
|
)
|
||||||
_mz_hamiltonian_travel(dot_pts, start, rows * columns * 4);
|
_mz_hamiltonian_travel(dot_pts, start, rows * columns * 4);
|
@@ -8,4 +8,7 @@ Preview
|
|||||||
|
|
||||||
- sweep
|
- sweep
|
||||||
- util/has
|
- util/has
|
||||||
- util/dedup
|
- util/dedup
|
||||||
|
|
||||||
|
bugs:
|
||||||
|
- util/sort: z not sorted
|
@@ -9,6 +9,9 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
use <pixel/_impl/_px_circle_impl.scad>;
|
use <pixel/_impl/_px_circle_impl.scad>;
|
||||||
|
use <util/sort.scad>;
|
||||||
use <util/dedup.scad>;
|
use <util/dedup.scad>;
|
||||||
|
|
||||||
function px_circle(radius, filled = false) = dedup(_px_circle_impl(radius, filled));
|
function px_circle(radius, filled = false) =
|
||||||
|
let(all = _px_circle_impl(radius, filled))
|
||||||
|
dedup(sort(sort(all, by = "x"), by = "y"), sorted = true);
|
@@ -9,7 +9,9 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
use <pixel/_impl/_px_cylinder_impl.scad>;
|
use <pixel/_impl/_px_cylinder_impl.scad>;
|
||||||
|
use <util/sort.scad>;
|
||||||
use <util/dedup.scad>;
|
use <util/dedup.scad>;
|
||||||
|
|
||||||
function px_cylinder(r, h, filled = false, thickness = 1) =
|
function px_cylinder(r, h, filled = false, thickness = 1) =
|
||||||
dedup(_px_cylinder_impl(r, h, filled, thickness));
|
let(all = _px_cylinder_impl(r, h, filled, thickness))
|
||||||
|
dedup(sort(sort(sort(all, by = "x"), by = "y"), by = "z"), sorted = true);
|
@@ -15,10 +15,8 @@ function px_polygon(points, filled = false) =
|
|||||||
idxes = search(y, sortedXY, num_returns_per_match = 0, index_col_num = 1)
|
idxes = search(y, sortedXY, num_returns_per_match = 0, index_col_num = 1)
|
||||||
)
|
)
|
||||||
[for(i = idxes) sortedXY[i]]
|
[for(i = idxes) sortedXY[i]]
|
||||||
]
|
],
|
||||||
)
|
all = concat(
|
||||||
dedup(
|
|
||||||
concat(
|
|
||||||
sortedXY,
|
sortedXY,
|
||||||
[
|
[
|
||||||
for(row = rows)
|
for(row = rows)
|
||||||
@@ -29,4 +27,5 @@ function px_polygon(points, filled = false) =
|
|||||||
if(in_shape(points, p)) p
|
if(in_shape(points, p)) p
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
)
|
||||||
|
dedup(sort(sort(all, by = "x"), by = "y"), sorted = true);
|
@@ -12,6 +12,7 @@ use <__comm__/__to3d.scad>;
|
|||||||
use <__comm__/__to2d.scad>;
|
use <__comm__/__to2d.scad>;
|
||||||
use <__comm__/__lines_from.scad>;
|
use <__comm__/__lines_from.scad>;
|
||||||
use <pixel/px_line.scad>;
|
use <pixel/px_line.scad>;
|
||||||
|
use <util/sort.scad>;
|
||||||
use <util/dedup.scad>;
|
use <util/dedup.scad>;
|
||||||
|
|
||||||
function px_polyline(points) =
|
function px_polyline(points) =
|
||||||
@@ -20,4 +21,8 @@ function px_polyline(points) =
|
|||||||
pts = is_2d ? [for(pt = points) __to3d(pt)] : points,
|
pts = is_2d ? [for(pt = points) __to3d(pt)] : points,
|
||||||
polyline = [for(line = __lines_from(pts)) each px_line(line[0], line[1])]
|
polyline = [for(line = __lines_from(pts)) each px_line(line[0], line[1])]
|
||||||
)
|
)
|
||||||
dedup(is_2d ? [for(pt = polyline) __to2d(pt)] : polyline);
|
dedup(is_2d ?
|
||||||
|
sort(sort([for(pt = polyline) __to2d(pt)], by = "x"), by = "y")
|
||||||
|
:
|
||||||
|
sort(sort(sort(polyline, by = "x"), by = "y"), by = "z")
|
||||||
|
, sorted = true);
|
Reference in New Issue
Block a user