Commits

bergsoe committed 46ce1b1

Use new [Index.nearest] utility.

Comments (0)

Files changed (1)

                 | [] -> None
                 | qs -> Some (add_all s n_tree qs)
 
-      let nearest s q_attractor dist constr =
-        let norm n_tree =
-          let q_tree = get_q (Tree.get n_tree) in
-            dist q_tree q_attractor
-        in
-          match Index.option_shortest s.index norm with
-            | None -> None
-            | Some node as result ->
-                let q_tree = get_q (Tree.get node) in
-                  if PaplConstraint.accept constr
-                    (q_tree, q_attractor)
-                  then result
-                  else None
+      let nearest s dist constr q_attractor =
+        let get node = get_q (Tree.get node) in
+          Index.nearest s.index get dist constr q_attractor
 
       let connect_constr =
         match M.connect_constr with
           | Some connect_constr -> connect_constr
 
       let connect s q_attractor =
-        nearest s q_attractor M.connect_dist connect_constr
+        nearest s M.connect_dist connect_constr q_attractor
     end
 
     module MakePointBidir
           | Some None -> None
           | Some (Some q_attractor) ->
               match Default.nearest
-                s.index q_attractor M.expand_dist expand_constr with
+                s.index M.expand_dist expand_constr q_attractor with
                   | None -> None
                   | Some n_tree ->
                       let q_tree = get_q (Tree.get n_tree) in