# HG changeset patch # User Sascha L. Teichmann # Date 1570614633 -7200 # Node ID 680f1d8802f0c388196cc1201c75eb2048ab155b # Parent f456ce0a6a0ec6e73f77a2a780120e863f8f5561 STRTree: Add a builder that ignores triangles which are filtered out before. diff -r f456ce0a6a0e -r 680f1d8802f0 pkg/octree/strtree.go --- a/pkg/octree/strtree.go Wed Oct 09 11:40:11 2019 +0200 +++ b/pkg/octree/strtree.go Wed Oct 09 11:50:33 2019 +0200 @@ -48,6 +48,31 @@ s.index[0] = root } +func (s *STRTree) BuildWithout(t *Tin, remove map[int32]struct{}) { + + if s.Entries == 0 { + s.Entries = STRTreeDefaultEntries + } + + s.tin = t + + all := make([]int32, 0, len(t.Triangles)-len(remove)) + + for i := range all { + idx := int32(i) + if _, found := remove[idx]; !found { + all = append(all, idx) + } + all[i] = int32(i) + } + + s.index = append(s.index, 0) + + root := s.build(all) + + s.index[0] = root +} + func (s *STRTree) Clip(p *Polygon) map[int32]struct{} { removed := make(map[int32]struct{})