Mercurial > gemma
diff pkg/mesh/vertex.go @ 5413:99f32f0dc70c marking-single-beam
Added tools to classify vertices by their heights with class breaks.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 07 Jul 2021 11:42:25 +0200 |
parents | 866eae1bd888 |
children | 31b0e865e7a0 |
line wrap: on
line diff
--- a/pkg/mesh/vertex.go Wed Jul 07 10:58:14 2021 +0200 +++ b/pkg/mesh/vertex.go Wed Jul 07 11:42:25 2021 +0200 @@ -1134,6 +1134,36 @@ return out } +// FilterRemoved returns an iterator that only delivers the vertices +// which indices are not marked as removed. +func (mpz MultiPointZ) FilterRemoved(removed map[int]struct{}) func() (Vertex, bool) { + var idx int + return func() (Vertex, bool) { + for { + if idx >= len(mpz) { + return Vertex{}, false + } + if _, rm := removed[idx]; rm { + idx++ + continue + } + break + } + return mpz[idx], true + } +} + +// MinMaxVertex runs over a point iterator and figures out its boundary. +func MinMaxVertex(points func() (Vertex, bool)) (Vertex, Vertex) { + min := Vertex{math.MaxFloat64, math.MaxFloat64, math.MaxFloat64} + max := Vertex{-math.MaxFloat64, -math.MaxFloat64, -math.MaxFloat64} + for v, ok := points(); ok; v, ok = points() { + min.Minimize(v) + max.Maximize(v) + } + return min, max +} + // AsWKB returns a WKB representation of the given point cloud. func (mpz MultiPointZ) AsWKB() []byte { size := 1 + 4 + 4 + len(mpz)*(1+4+3*8)