Mercurial > gemma
diff cmd/octree2contour/main.go @ 687:be90ab542aa7 octree
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 20 Sep 2018 11:32:03 +0200 |
parents | a2f107f1e4e7 |
children | 614135d69823 |
line wrap: on
line diff
--- a/cmd/octree2contour/main.go Thu Sep 20 00:13:47 2018 +0200 +++ b/cmd/octree2contour/main.go Thu Sep 20 11:32:03 2018 +0200 @@ -17,7 +17,7 @@ type result struct { h float64 - triangles int + numPoints int } func processLevels( @@ -28,21 +28,23 @@ ) { defer wg.Done() for h := range jobs { - var triangles int - tree.horizontal(h, func([]int32) { - triangles++ + var points []vertex + tree.horizontal(h, func(t *triangle) { + points = t.intersectH(h, points) }) - results <- result{h, triangles} + results <- result{h, len(points)} } } func process(tree *octree) { - var triangles int + var numPoints int start := time.Now() if *one { - tree.horizontal(*step, func([]int32) { - triangles++ + var points []vertex + tree.horizontal(*step, func(t *triangle) { + points = t.intersectH(*step, points) }) + numPoints = len(points) } else { results := make(chan result) @@ -78,14 +80,13 @@ return all[i].h < all[j].h }) - var sum int for i := range all { a := &all[i] - sum += a.triangles - log.Printf("level %f: %d\n", a.h, a.triangles) + numPoints += a.numPoints + log.Printf("level %f: %d\n", a.h, a.numPoints) } - log.Printf("num triangles: %d\n", sum) } + log.Printf("num points: %d\n", numPoints) log.Printf("processing took: %s\n", time.Since(start)) }