changeset 2521:e26000628764

Clip triangle in STR tree leaves correctly.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 05 Mar 2019 18:32:07 +0100
parents 347dfa4bafa1
children 24bab584f0a1
files pkg/octree/strtree.go
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/octree/strtree.go	Tue Mar 05 17:45:55 2019 +0100
+++ b/pkg/octree/strtree.go	Tue Mar 05 18:32:07 2019 +0100
@@ -49,6 +49,8 @@
 
 	stack := []int32{s.index[0]}
 
+	vertices := s.tin.Vertices
+
 	for len(stack) > 0 {
 		top := stack[len(stack)-1]
 		stack = stack[:len(stack)-1]
@@ -69,7 +71,16 @@
 		} else { // leaf
 			top = -top - 1
 			for i, n := int32(0), s.index[top+1]; i < n; i++ {
-				removed[s.index[top+2+i]] = struct{}{}
+				idx := s.index[top+2+i]
+				ti := s.tin.Triangles[idx]
+				t := Triangle{
+					vertices[ti[0]],
+					vertices[ti[1]],
+					vertices[ti[2]],
+				}
+				if p.IntersectionWithTriangle(&t) != IntersectionInside {
+					removed[idx] = struct{}{}
+				}
 			}
 		}
 	}