Repository navigation
Expand file tree
/
Copy pathsimple_1.go
More file actions
67 lines (58 loc) · 1.7 KB
/
Copy pathsimple_1.go
File metadata and controls
67 lines (58 loc) · 1.7 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package constdp
import (
"github.com/TopoSimplify/common"
"github.com/TopoSimplify/node"
"github.com/TopoSimplify/split"
"github.com/intdxdt/fan"
"github.com/intdxdt/iter"
)
func deformNodes(id *iter.Igen, nodes map[*node.Node]struct{}) []node.Node {
var self *ConstDP
var ha, hb node.Node
var results = make([]node.Node, 0, len(nodes)*2)
for hull := range nodes {
self = hull.Instance.(*ConstDP)
var scoreFn = self.Score
if self.SquareScore != nil {
scoreFn = self.SquareScore
}
if hull.Range.Size() > 1 {
ha, hb = split.AtScoreSelection(id, hull, scoreFn, common.Geometry)
results = append(results, ha, hb)
hull.Instance.State().MarkDirty() //after split mark instance as dirty
} else {
results = append(results, *hull)
}
}
return results
}
func deformNodes_(id *iter.Igen, nodes map[*node.Node]struct{}) []node.Node {
var stream = make(chan interface{}, 4*ConcurProcs)
var exit = make(chan struct{})
defer close(exit)
go streamDeformNodes(stream, nodes)
var out = fan.Stream(stream, processDeformNodes(id), ConcurProcs, exit)
var results = make([]node.Node, 0, len(nodes)*2)
for sel := range out {
splits := sel.([]node.Node)
results = append(results, splits...)
}
return results
}
func streamDeformNodes(stream chan interface{}, nodes map[*node.Node]struct{}) {
for o := range nodes {
stream <- o
}
close(stream)
}
func processDeformNodes(id *iter.Igen) func(v interface{}) interface{} {
return func(v interface{}) interface{} {
var hull = v.(*node.Node)
var self = hull.Instance.(*ConstDP)
if hull.Range.Size() > 1 {
var ha, hb = split.AtScoreSelection(id, hull, self.Score, common.Geometry)
return []node.Node{ha, hb}
}
return []node.Node{*hull}
}
}