# HG changeset patch # User Sascha L. Teichmann # Date 1569514298 -7200 # Node ID 56f4e8cbfab7bcc9a1c5c29fdd28ee75b570bb94 # Parent 53b55f8116665cd3bf51d4eec4f530de71cf4190 Sew together triangles that totally inside a single class. diff -r 53b55f811666 -r 56f4e8cbfab7 cmd/isoareas/main.go --- a/cmd/isoareas/main.go Thu Sep 26 15:37:56 2019 +0200 +++ b/cmd/isoareas/main.go Thu Sep 26 18:11:38 2019 +0200 @@ -15,6 +15,7 @@ import ( "bufio" + "container/list" "fmt" "io" "log" @@ -142,14 +143,14 @@ log.Println("inside classes:") for i, c := range classes { - var pb polygonBuilder + pb := polygonBuilder{open: list.New()} var isolated, inside int allInClass: for _, idx := range c { ns := neighbors(tri, idx) - w := where(ns, c) - switch bits.OnesCount8(w) { + mask := where(ns, c) + switch bits.OnesCount8(mask) { case 0: // Totally insides do not contribute to the geometries. inside++ @@ -163,11 +164,67 @@ tri.Points[ti[1]], tri.Points[ti[2]]) continue allInClass + default: + ti := tri.Triangles[idx*3 : idx*3+3] + for j := 0; j < 3; j++ { + if mask&(1< 0 +} + // Join joins two lines leaving the first of the second out. func (ls LineStringZ) Join(other LineStringZ) LineStringZ { nline := make(LineStringZ, len(ls)+len(other)-1)