changeset 680:c79c7be29a7a octree

octree: Small fix in horizontal traversal.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 19 Sep 2018 18:07:28 +0200
parents 899116318d58
children a8d32a11b113
files cmd/octree2contour/loader.go cmd/octree2contour/main.go
diffstat 2 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/cmd/octree2contour/loader.go	Wed Sep 19 17:35:00 2018 +0200
+++ b/cmd/octree2contour/loader.go	Wed Sep 19 18:07:28 2018 +0200
@@ -142,7 +142,7 @@
 		max float64
 	}
 
-	if h < ot.min.z || h > ot.max.z {
+	if h < ot.min.z || ot.max.z < h {
 		return
 	}
 
--- a/cmd/octree2contour/main.go	Wed Sep 19 17:35:00 2018 +0200
+++ b/cmd/octree2contour/main.go	Wed Sep 19 18:07:28 2018 +0200
@@ -9,18 +9,25 @@
 var (
 	one  = flag.Bool("o", false, "create only a single contour")
 	step = flag.Float64("s", 0.5, "step with")
-	max  = flag.Float64("m", 10, "max height from lowest poiint")
+	max  = flag.Float64("m", 10, "max height from lowest point")
 )
 
 func process(tree *octree) {
+	var triangles int
+	start := time.Now()
 	if *one {
-		var triangles int
 		tree.horizontal(*step, func([]int32) {
 			triangles++
 		})
-		log.Printf("num triangles: %d\n", triangles)
 	} else {
+		for h := tree.min.z; h <= tree.max.z; h += *step {
+			tree.horizontal(h, func([]int32) {
+				triangles++
+			})
+		}
 	}
+	log.Printf("traversal took: %v\n", time.Since(start))
+	log.Printf("num triangles: %d\n", triangles)
 }
 
 func main() {