diff cmd/octree2contour/loader.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 a8672ba9ebad
children 9db4ae29ded9
line wrap: on
line diff
--- a/cmd/octree2contour/loader.go	Thu Sep 20 00:13:47 2018 +0200
+++ b/cmd/octree2contour/loader.go	Thu Sep 20 11:32:03 2018 +0200
@@ -129,7 +129,7 @@
 	return tree, nil
 }
 
-func (ot *octree) horizontal(h float64, fn func([]int32)) {
+func (ot *octree) horizontal(h float64, fn func(*triangle)) {
 
 	type frame struct {
 		pos int32
@@ -178,14 +178,16 @@
 					continue
 				}
 				tri := ot.triangles[idx]
-				v0 := ot.vertices[tri[0]]
-				v1 := ot.vertices[tri[1]]
-				v2 := ot.vertices[tri[2]]
+				t := triangle{
+					ot.vertices[tri[0]],
+					ot.vertices[tri[1]],
+					ot.vertices[tri[2]],
+				}
 
-				if !(math.Min(v0.z, math.Min(v1.z, v2.z)) > h ||
-					math.Max(v0.z, math.Max(v1.z, v2.z)) < h) {
+				if !(math.Min(t[0].z, math.Min(t[1].z, t[2].z)) > h ||
+					math.Max(t[0].z, math.Max(t[1].z, t[2].z)) < h) {
 					dupes[idx] = struct{}{}
-					fn(tri)
+					fn(&t)
 				}
 			}
 		}