Mercurial > gemma
diff pkg/octree/vertex.go @ 796:0cc97135717c
More fixes to vertical triangle intersection.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 27 Sep 2018 11:40:02 +0200 |
parents | bd5f38eb6153 |
children | 1a808929c2c5 |
line wrap: on
line diff
--- a/pkg/octree/vertex.go Thu Sep 27 10:57:39 2018 +0200 +++ b/pkg/octree/vertex.go Thu Sep 27 11:40:02 2018 +0200 @@ -237,17 +237,27 @@ out := make(MultiLineStringZ, 0, len(positions)) + var ignored int + for i := range positions { curr := positions[i].line if l := len(out); l > 0 { - if last := out[l-1]; last[len(last)-1].EpsEquals(curr[0]) { + last := out[l-1] + + if last[len(last)-1].EpsEquals(curr[0]) { out[l-1] = append(last[:len(last)-1], curr...) continue } + if position(last[len(last)-1]) > position(curr[0]) { + ignored++ + continue + } } out = append(out, curr) } + log.Printf("ignored parts: %d\n", ignored) + return out } @@ -450,6 +460,10 @@ var out LineStringZ + defer func() { + log.Printf("length out: %d\n", len(out)) + }() + edges: for i := 0; i < 3 && len(out) < 2; i++ { j := (i + 1) % 3 @@ -461,7 +475,7 @@ o1 := onPlane(s1) o2 := onPlane(s2) - log.Printf("s1, s2: %t %t\n", o1, o2) + log.Printf("s1, s2: %t %t (%f %f)\n", o1, o2, s1, s2) switch { case o1 && o2: @@ -527,8 +541,6 @@ log.Println("Intersection -----------------------------") t1 := relative(t[i], t[j])(x, y) - log.Printf("rel p1: %f\n", relative(t[i], t[j])(t[i].X, t[i].Y)) - log.Printf("rel p2: %f\n", relative(t[i], t[j])(t[j].X, t[j].Y)) log.Printf("relative pos: %f\n", t1) if !inRange(t1) { continue edges @@ -613,8 +625,6 @@ } } - log.Printf("length out: %d\n", len(out)) - // supress single point touches. if len(out) == 1 { out = out[:0]