Mercurial > gemma
changeset 4592:680f1d8802f0
STRTree: Add a builder that ignores triangles which are filtered out before.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 09 Oct 2019 11:50:33 +0200 |
parents | f456ce0a6a0e |
children | 3632cfc44b69 |
files | pkg/octree/strtree.go |
diffstat | 1 files changed, 25 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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{})