# HG changeset patch # User Sascha L. Teichmann # Date 1551351091 -3600 # Node ID efe332e985b91cc21c1ef7ab791a3c68ed9e6069 # Parent 25e2578b76f3f477dd314618fd77ae9876e36b1c Calculate the iso lines of the difference. diff -r 25e2578b76f3 -r efe332e985b9 cmd/octreediff/main.go --- a/cmd/octreediff/main.go Wed Feb 27 17:44:44 2019 +0100 +++ b/cmd/octreediff/main.go Thu Feb 28 11:51:31 2019 +0100 @@ -327,6 +327,52 @@ now = time.Now() log.Printf("building octree took %v\n", now.Sub(last)) last = now + + tree := builder.Tree() + + log.Printf("min/max: %f %f\n", tree.Min.Z, tree.Max.Z) + + var heights []float64 + + switch { + case tree.Min.Z >= 0: // All values positive. + for v := 0.0; v <= tree.Max.Z; v += 0.1 { + if v >= tree.Min.Z { + heights = append(heights, v) + } + } + case tree.Max.Z <= 0: // All values negative. + for v := 0.0; v >= tree.Min.Z; v -= 0.1 { + if v <= tree.Max.Z { + heights = append(heights, v) + } + } + default: // Positive and negative. + for v := 0.1; v <= tree.Max.Z; v += 0.1 { + heights = append(heights, v) + } + for i, j := 0, len(heights)-1; i < j; i, j = i+1, j-1 { + heights[i], heights[j] = heights[j], heights[i] + } + for v := 0.0; v >= tree.Min.Z; v -= 0.1 { + heights = append(heights, v) + } + } + + var dataSize int + + octree.DoContours(tree, heights, func(res *octree.ContourResult) { + // TODO: Store them. + log.Printf("%f: segments: %d\n", res.Height, len(res.Lines)) + dataSize += len(res.Lines.AsWKB2D()) + }) + + now = time.Now() + log.Printf("Number of iso lines: %d\n", len(heights)) + log.Printf("Total WKB size: %.2fMB\n", float64(dataSize)/(1024*1024)) + log.Printf("generating iso lines took %v\n", now.Sub(last)) + last = now + return nil }) }