Skip to content

Commit

Permalink
insertion error seems to be fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
gzmask committed Apr 4, 2015
1 parent d022b5b commit e62f8d6
Show file tree
Hide file tree
Showing 11 changed files with 458 additions and 30 deletions.
Binary file modified resources/.DS_Store
Binary file not shown.
Binary file added resources/pic/box-node-nums.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/pic/d1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resources/pic/d2.png
Binary file not shown.
Binary file modified resources/pic/final-box-edge-order.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resources/pic/final-route-B.png
Binary file not shown.
8 changes: 4 additions & 4 deletions src/slicer/draw.clj
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@
(q/line (* x3 wpx) (* y3 hpx) (* x1 wpx) (* y1 hpx)))
[[[x1 y1 & z1][x2 y2 & z2]]] ;line
(do
(q/text-size 12)
(q/line (* x1 wpx) (* y1 hpx) (* x2 wpx) (* y2 hpx))
(let [[x3 y3] (line-center [x1 y1] [x2 y2])]
(q/text s (* x3 wpx) (* y3 hpx)))
(q/line (* x1 wpx) (* y1 hpx) (* x2 wpx) (* y2 hpx)))
(q/text-size 12)
(q/text s (* x3 wpx) (* y3 hpx))))
[[x1 y1 & z1]] ;point
(do (q/line (- (* x1 wpx) (/ wpx 10)) (- (* y1 hpx) (/ hpx 10)) (+ (* x1 wpx) (/ wpx 10)) (+ (* y1 hpx) (/ hpx 10)))
(q/line (- (* x1 wpx) (/ wpx 10)) (+ (* y1 hpx) (/ hpx 10)) (+ (* x1 wpx) (/ wpx 10)) (- (* y1 hpx) (/ hpx 10))))))
Expand All @@ -75,7 +75,7 @@
(q/background 200))
draw (fn []
(q/translate (/ screen-width 2) (/ screen-height 2))
(q/scale 1 -1) ;; matching the 3D printer coordinate
;(q/scale 1 -1) ;; matching the 3D printer coordinate
;(q/translate 178 470)
(doseq [node-or-geo nodes-or-geos]
(match [(number? node-or-geo)]
Expand Down
34 changes: 25 additions & 9 deletions src/slicer/eulerian.clj
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,29 @@
; need search again for the position
; sometimes place after, sometimes place before
index (.indexOf walked-edges edge)
;_ (debugger walked-edges "walked-edges")
;_ (debugger (first (s/intersection (first walked-edges) (last walked-edges))) "first and last:")
;_ (debugger (first (s/intersection (nth walked-edges index) (nth walked-edges (inc index)))) "this and after:")
insert-index (cond
;first and last node has the start node
(=
(first (s/intersection (first walked-edges) (last walked-edges)))
node)
0
;current and one after has the start node
(=
(first (s/intersection (nth walked-edges index) (nth walked-edges (inc index))))
node)
(inc index) ;insert between current and one after
;current and one before has the start node
(=
(first (s/intersection (nth walked-edges index) (nth walked-edges (dec index))))
node)
index ;insert between current and one after
:else (throw (Exception. "loop insertion failed"))
)
]
[node
(if (= node (s/difference
(nth walked-edges index)
(nth walked-edges (inc index))))
(inc index)
index)
])))
[node insert-index])))

;(get-start-node [#{1 2} #{2 3}] #{#{3 4} #{4 1} #{4 5}})
;(get-start-node [#{6 2} #{2 3}] #{#{3 4} #{4 1} #{4 5}})
Expand Down Expand Up @@ -282,8 +297,9 @@
new-loop (random-loop-walk start-node unwalked-edges)
last-seg (subvec walked-edges index-start-node (count walked-edges))
new-walked-edges (into (into first-seg new-loop) last-seg)
_ (debugger new-loop "new-loop:")
_ (debugger index-start-node "index-start-node:")
;_ (debugger new-loop "new-loop:")
;_ (debugger start-node "start-node:")
;_ (debugger index-start-node "index-start-node:")
]
(recur all-edges nodes new-walked-edges))))

Expand Down
Loading

0 comments on commit e62f8d6

Please sign in to comment.