Mercurial > gemma
changeset 4535:508075a5694e iso-areas
Only keep the indices of the triangles of the border of the iso patches.
The inner ones do not contribute to the border geometries.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 25 Sep 2019 17:25:49 +0200 |
parents | b7d31a449dd2 |
children | 3130c005abef |
files | cmd/isoareas/main.go |
diffstat | 1 files changed, 12 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/cmd/isoareas/main.go Wed Sep 25 15:39:55 2019 +0200 +++ b/cmd/isoareas/main.go Wed Sep 25 17:25:49 2019 +0200 @@ -135,16 +135,20 @@ } log.Println("inside classes:") - for _, c := range classes { - var eliminated int + for i, c := range classes { + remain := make([]int32, 0, len(c)) + for _, idx := range c { - if inner(tri, idx, c) { - eliminated++ + // Eliminate triangles that do not contribute + // any border to the final outline. + if !inner(tri, idx, c) { + remain = append(remain, idx) } } log.Printf("\t%d (%d) %.2f%%\n", - len(c)-eliminated, len(c), - 100*float64(eliminated)/float64(len(c))) + len(remain), len(c), + 100*float64(len(remain))/float64(len(c))) + classes[i] = remain } log.Println("cuts:") @@ -168,10 +172,9 @@ return false } n /= 3 - p := sort.Search(len(indices), func(i int) bool { + if p := sort.Search(len(indices), func(i int) bool { return indices[i] >= n - }) - if p >= len(indices) || indices[p] != n { + }); p >= len(indices) || indices[p] != n { return false } }