# HG changeset patch # User Sascha L. Teichmann # Date 1569848360 -7200 # Node ID 9c65cef72753d4881e24a0ff6ab42e36907d2d70 # Parent befb94e3a953615669a17a33e4fe7097820f6d98 Fixed bit mask usage. diff -r befb94e3a953 -r 9c65cef72753 cmd/isoareas/main.go --- a/cmd/isoareas/main.go Mon Sep 30 11:22:41 2019 +0200 +++ b/cmd/isoareas/main.go Mon Sep 30 14:59:20 2019 +0200 @@ -23,7 +23,6 @@ "math/bits" "math/rand" "os" - "sort" "strconv" "strings" "time" @@ -254,20 +253,6 @@ } } - for l, c := range classes { - sorted := sort.SliceIsSorted(c, func(i, j int) bool { - return c[i] < c[j] - }) - log.Printf("class[%d] sorted: %t\n", l, sorted) - } - - for l, c := range cuts { - sorted := sort.SliceIsSorted(c, func(i, j int) bool { - return c[i].index < c[j].index - }) - log.Printf("cut[%d] sorted: %t\n", l, sorted) - } - // connect the arcs in a cut list to longer arcs. for _, c := range cuts { @@ -290,11 +275,11 @@ ns := neighbors(tri, idx) mask := where(ns, c) switch bits.OnesCount8(mask) { - case 0: + case 3: // Totally insides do not contribute to the geometries. inside++ continue allInClass - case 3: + case 0: // Isolated are areas w/o connections to the rest. isolated++ ti := tri.Triangles[idx*3 : idx*3+3] @@ -367,6 +352,9 @@ /* for e := pb.open.Front(); e != nil; e = e.Next() { line := e.Value.(octree.LineStringZ) + if !line.CCW() { + line.Reverse() + } pb.polygons = append(pb.polygons, line) } */ @@ -436,7 +424,7 @@ func where(neighbors, indices []int32) byte { var mask byte for i, n := range neighbors { - if n < 0 || !contains(n/3, indices) { + if n >= 0 && contains(n/3, indices) { mask |= 1 << i } }