remove dead code
This commit is contained in:
@ -21,54 +21,6 @@
|
|||||||
)
|
)
|
||||||
(:gen-class))
|
(:gen-class))
|
||||||
|
|
||||||
|
|
||||||
#_(def res (double 1/2))
|
|
||||||
#_(def num-holes 30)
|
|
||||||
|
|
||||||
#_(defn voxel-sphere
|
|
||||||
[tree op origin radius res]
|
|
||||||
(let [rg (range (- radius) (+ radius res) res)
|
|
||||||
coll (for [x rg, y rg, z rg
|
|
||||||
:let [v (vec3 x y z)]
|
|
||||||
:when (<= (g/mag v) radius)] (g/+ origin v))]
|
|
||||||
(svo/apply-voxels op tree coll)))
|
|
||||||
|
|
||||||
#_(time
|
|
||||||
(def v
|
|
||||||
(reduce
|
|
||||||
(fn [tree [op o r]] (voxel-sphere tree op o r res))
|
|
||||||
(svo/voxeltree 32 res)
|
|
||||||
(concat
|
|
||||||
;; create big sphere
|
|
||||||
[[svo/set-at (vec3 15 15 15) 14]]
|
|
||||||
;; remove several smaller spheres
|
|
||||||
(repeatedly
|
|
||||||
num-holes
|
|
||||||
#(vector
|
|
||||||
svo/delete-at
|
|
||||||
(vec3 (m/random 32) (m/random 32) (m/random 32))
|
|
||||||
(m/random 4 8)))))))
|
|
||||||
|
|
||||||
#_(def construct
|
|
||||||
(let [tree (svo/voxeltree 8 res)]
|
|
||||||
(svo/set-at tree (vec3 4 4 4))))
|
|
||||||
|
|
||||||
#_(defn frames-to-voxels
|
|
||||||
"Frame size must be cubic."
|
|
||||||
[frames & [inside-val]]
|
|
||||||
(let [size (count frames)
|
|
||||||
border 4
|
|
||||||
tree (svo/voxeltree (+ size (* border 2)) res)
|
|
||||||
coll (for [z (range size)
|
|
||||||
y (range size)
|
|
||||||
x (range size)
|
|
||||||
:let [frame (nth frames (- size z 1))]
|
|
||||||
:when (sim/inside? (ui/cell-value (:render frame) x y) inside-val)]
|
|
||||||
(vec3 (+ x border) (+ y border) (+ z border)))]
|
|
||||||
(svo/apply-voxels svo/set-at tree coll)))
|
|
||||||
|
|
||||||
;; {:pos v :vel v :rad r}
|
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
;;; geometry
|
;;; geometry
|
||||||
;;;
|
;;;
|
||||||
@ -145,27 +97,6 @@
|
|||||||
[p bounds]
|
[p bounds]
|
||||||
(every? true? (map #(single-in-bounds? %1 %2) p bounds)))
|
(every? true? (map #(single-in-bounds? %1 %2) p bounds)))
|
||||||
|
|
||||||
#_(defn next-point
|
|
||||||
"Return the next position and velocity, or nil if it falls outside
|
|
||||||
the domain bounds."
|
|
||||||
[pos vel bounds]
|
|
||||||
(let [next-pos (next-pos pos vel)
|
|
||||||
next-vel (next-vel vel)]
|
|
||||||
(when (in-bounds? next-pos bounds)
|
|
||||||
[next-pos next-vel])))
|
|
||||||
|
|
||||||
#_(defn trajectory
|
|
||||||
"Return the points of the trajectory from the initial point until
|
|
||||||
the point exits the domain."
|
|
||||||
[trace bounds]
|
|
||||||
(loop [pts []
|
|
||||||
p pos
|
|
||||||
v vel]
|
|
||||||
(let [[next-pos next-vel] (next-point p v bounds)]
|
|
||||||
(if (not next-pos)
|
|
||||||
pts
|
|
||||||
(recur (conj pts next-pos) next-pos next-vel)))))
|
|
||||||
|
|
||||||
(defn trace-trajectory
|
(defn trace-trajectory
|
||||||
[trace bounds]
|
[trace bounds]
|
||||||
(loop [pts []
|
(loop [pts []
|
||||||
@ -208,27 +139,3 @@
|
|||||||
(with-open [o (io/output-stream "sample.ply")]
|
(with-open [o (io/output-stream "sample.ply")]
|
||||||
(let [tree #_sampletree (sample-tree count)]
|
(let [tree #_sampletree (sample-tree count)]
|
||||||
(mio/write-ply o (g/tessellate (iso/surface-mesh tree 5 0.85)))))))
|
(mio/write-ply o (g/tessellate (iso/surface-mesh tree 5 0.85)))))))
|
||||||
|
|
||||||
;;;
|
|
||||||
;;;
|
|
||||||
;;;
|
|
||||||
|
|
||||||
#_(defn voxelburst
|
|
||||||
"Return a set of points."
|
|
||||||
[origin trace-count bounds]
|
|
||||||
(reduce set/union (trajectories origin trace-count bounds)))
|
|
||||||
|
|
||||||
#_(defn make-tree [size count]
|
|
||||||
(let [tree (svo/voxeltree size (double 1/2))]
|
|
||||||
(svo/set-at tree (vec3 4 4 4))))
|
|
||||||
|
|
||||||
#_(defn write-ply
|
|
||||||
[name tree & [resolution inside-val]]
|
|
||||||
(time
|
|
||||||
(doseq [i (list resolution)]
|
|
||||||
(with-open [o (io/output-stream (string/join (list name "-" i ".ply")))]
|
|
||||||
(mio/write-ply o (g/tessellate (iso/surface-mesh tree i (or inside-val 0.5))))))))
|
|
||||||
|
|
||||||
#_(defn -main
|
|
||||||
[& [name count grid-size resolution]]
|
|
||||||
(write-ply name (make-tree) resolution))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user