# HG changeset patch # User Sascha L. Teichmann # Date 1569425149 -7200 # Node ID 508075a5694e94be3bf1e3ff870adac9590671fa # Parent b7d31a449dd2232b1fc79d30de2e906f9e9720e5 Only keep the indices of the triangles of the border of the iso patches. The inner ones do not contribute to the border geometries. diff -r b7d31a449dd2 -r 508075a5694e cmd/isoareas/main.go --- 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 } }