-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathln.go
50 lines (42 loc) · 1.15 KB
/
ln.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package deform
import (
"github.com/TopoSimplify/plugin/hdb"
"github.com/TopoSimplify/plugin/knn"
"github.com/TopoSimplify/plugin/node"
"github.com/TopoSimplify/plugin/opts"
)
//find context deformation list
func Select(options *opts.Opts, hullDB *hdb.Hdb, hull *node.Node) []*node.Node {
var n int
var h *node.Node
var inters, contig bool
var dict = make(map[[2]int]*node.Node, 0)
var ctxHulls = knn.NodeNeighbours(hullDB, hull, knn.EpsilonDist)
// for each item in the context list
for i := range ctxHulls {
// find which item to deform against current hull
h = ctxHulls[i]
inters, contig, n = node.IsContiguous(hull, h)
if !inters {
continue
}
var sa, sb *node.Node
if contig && n > 1 { //contiguity with overlap greater than a vertex
sa, sb = contiguousCandidates(hull, h)
} else if !contig {
sa, sb = nonContiguousCandidates(options, hull, h)
}
// add candidate deformation hulls to selection list
if sa != nil {
dict[sa.Range.AsArray()] = sa
}
if sb != nil {
dict[sb.Range.AsArray()] = sb
}
}
var items = make([]*node.Node, 0, len(dict))
for _, v := range dict {
items = append(items, v)
}
return items
}