Mercurial > gemma
changeset 3609:e1021fd60190
Removed statistics from elimination of triangles.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 05 Jun 2019 12:15:05 +0200 |
parents | f96def15847e |
children | 81473293cd9a |
files | pkg/imports/sr.go pkg/octree/triangulation.go |
diffstat | 2 files changed, 9 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/imports/sr.go Wed Jun 05 12:11:35 2019 +0200 +++ b/pkg/imports/sr.go Wed Jun 05 12:15:05 2019 +0200 @@ -364,7 +364,7 @@ feedback.Info("No boundary given.") feedback.Info("Eliminate triangles with long edges.") - tri.ConcaveHull(0.98) + tri.ConcaveHull(50.0) } // TODO: Implement me!
--- a/pkg/octree/triangulation.go Wed Jun 05 12:11:35 2019 +0200 +++ b/pkg/octree/triangulation.go Wed Jun 05 12:15:05 2019 +0200 @@ -23,9 +23,6 @@ "fmt" "log" "math" - "sort" - - "gonum.org/v1/gonum/stat" ) type Triangulation struct { @@ -42,13 +39,13 @@ return &Triangulation{points, t.convexHull(), t.triangles, t.halfedges}, err } -func (t *Triangulation) ConcaveHull(quantile float64) []int32 { +func (t *Triangulation) ConcaveHull(tooLong float64) []int32 { - numTris := len(t.Triangles) / 3 + tooLong *= tooLong - // Calculate the max edge lengths per triangle. - lengths := make([]float64, numTris) - for i := range lengths { + var oldCandidates []int32 + + for i, num := 0, len(t.Triangles)/3; i < num; i++ { idx := i * 3 var max float64 vs := t.Triangles[idx : idx+3] @@ -58,15 +55,11 @@ max = l } } - lengths[i] = max + if max > tooLong { + oldCandidates = append(oldCandidates, int32(i)) + } } - qs := make([]float64, len(lengths)) - copy(qs, lengths) - sort.Float64s(qs) - q := stat.Quantile(quantile, stat.LinInterp, qs, nil) - log.Printf("info: %.2f%% quantile: %.2f\n", quantile, math.Sqrt(q)) - removed := map[int32]bool{} isBorder := func(n int32) bool { @@ -80,15 +73,6 @@ return false } - oldCandidates := make([]int32, 0, int(math.Ceil(float64(numTris)*(1.0-quantile)))) - log.Printf("info: cap candidates: %d\n", cap(oldCandidates)) - - for i, length := range lengths { - if length >= q { - oldCandidates = append(oldCandidates, int32(i)) - } - } - var newCandidates []int32 for len(oldCandidates) > 0 {