1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-01 04:20:27 +02:00

refactor: we don't need sort

This commit is contained in:
Justin Lin
2022-04-15 09:31:51 +08:00
parent ed4d8efb55
commit 9599d5434c
2 changed files with 8 additions and 11 deletions

View File

@@ -1,4 +1,5 @@
use <../../util/has.scad>;
use <../../__comm__/_pt2_hash.scad>;
use <../../util/set/hashset_has.scad>;
function _mz_wang_tiles_top(x, y) =
let(
@@ -21,13 +22,14 @@ function _mz_wang_tiles_top_right(x, y) =
)
[[nx + 1, ny + 2], [nx + 2, ny + 1]];
hash = function(p) _pt2_hash(p);
function _mz_wang_tile_type(dots, x, y) =
let(
px = x * 2 + 1,
py = y * 2 + 1,
c1 = !has(dots, [px, py + 1], sorted = true) ? 1 : 0,
c2 = !has(dots, [px + 1, py], sorted = true) ? 2 : 0,
c3 = !has(dots, [px, py - 1], sorted = true) ? 4 : 0,
c4 = !has(dots, [px - 1, py], sorted = true) ? 8 : 0
c1 = !hashset_has(dots, [px, py + 1], hash = hash) ? 1 : 0,
c2 = !hashset_has(dots, [px + 1, py], hash = hash) ? 2 : 0,
c3 = !hashset_has(dots, [px, py - 1], hash = hash) ? 4 : 0,
c4 = !hashset_has(dots, [px - 1, py], hash = hash) ? 8 : 0
)
c1 + c2 + c3 + c4;

View File

@@ -11,9 +11,7 @@
use <../__comm__/_pt2_hash.scad>;
use <_impl/_mz_wang_tiles_impl.scad>;
use <mz_square_get.scad>;
use <../util/sorted.scad>;
use <../util/set/hashset.scad>;
use <../util/set/hashset_elems.scad>;
function mz_wang_tiles(cells, left_border = true, bottom_border = true) =
let(
@@ -45,10 +43,7 @@ function mz_wang_tiles(cells, left_border = true, bottom_border = true) =
[type == "TOP_WALL" || type == "NO_WALL" ? 1 : 0, y * 2 + 1]
]
),
dot_pts = sorted(
hashset_elems(hashset(all, hash = function(p) _pt2_hash(p))),
function(a, b) let(d = a - b) d.y == 0 ? d.x : d.y
)
dot_pts = hashset(all, hash = function(p) _pt2_hash(p))
)
[
for(y = [0:rows - 1], x = [0:columns - 1])