finished coding merging functionality
This commit is contained in:
@@ -320,13 +320,12 @@ struct
|
||||
|
||||
local
|
||||
fun loop (x, y, ex, ey, grid) =
|
||||
if x > 0 then
|
||||
if quadHasSameColour (x, y, ex, ey, grid) then
|
||||
loop (x - 1, y, x, ey, grid)
|
||||
else
|
||||
ex
|
||||
else
|
||||
if x < 0 then
|
||||
0
|
||||
else if quadHasSameColour (x, y, ex, ey, grid) then
|
||||
loop (x - 1, y, x, ey, grid)
|
||||
else
|
||||
ex
|
||||
in
|
||||
fun getLeftmostX ({x, y, ex, ey, data}, grid) =
|
||||
loop (x - 1, y, x, ey, grid)
|
||||
@@ -348,7 +347,7 @@ struct
|
||||
|
||||
local
|
||||
fun loop (x, y, ex, ey, grid) =
|
||||
if y = 0 orelse ey = 0 then
|
||||
if y < 0 then
|
||||
0
|
||||
else if quadHasSameColour (x, y, ex, ey, grid) then
|
||||
loop (x, y - 1, ex, y, grid)
|
||||
@@ -356,7 +355,7 @@ struct
|
||||
ey
|
||||
in
|
||||
fun getTopmostY ({x, y, ex, ey, data}, grid) =
|
||||
if y <= 0 orelse ey <= 0 then
|
||||
if y < 0 orelse ey <= 0 then
|
||||
0
|
||||
else if quadHasSameColour (x, y, ex, ey, grid) then
|
||||
loop (x, y - 1, ex, y, grid)
|
||||
@@ -465,13 +464,14 @@ struct
|
||||
end
|
||||
|
||||
fun merge (tree, grid) =
|
||||
let val tree = mergeVertical (tree, grid)
|
||||
in toBintree tree
|
||||
let
|
||||
val tree = mergeVertical (tree, grid)
|
||||
val tree = mergeHorizontal (tree, grid)
|
||||
in
|
||||
toBintree tree
|
||||
end
|
||||
|
||||
(* temporarily shadow previous "toTriangles" function.
|
||||
* When this is done being implemented, rename to "toTrianglesCompressed" *)
|
||||
fun toTriangles
|
||||
fun toTrianglesMerged
|
||||
( windowWidth
|
||||
, windowHeight
|
||||
, squares
|
||||
@@ -483,17 +483,8 @@ struct
|
||||
) =
|
||||
let
|
||||
val qtree = buildTree (0, 0, size, squares)
|
||||
val bintree = toBintree qtree
|
||||
val bintree = merge (qtree, squares)
|
||||
|
||||
val list = BinTree.toList bintree
|
||||
val length = List.length list
|
||||
val _ = print ("length = " ^ Int.toString length ^ "\n")
|
||||
|
||||
val _ = print "start fold\n"
|
||||
val _ = List.foldl (fn (item, _) => printItem item) () list
|
||||
val _ = print "finish fold\n"
|
||||
|
||||
val f = folder
|
||||
( windowWidth
|
||||
, windowHeight
|
||||
|
||||
Reference in New Issue
Block a user