From a0d239ec268014aad46a95fe3510b240f3446fb4 Mon Sep 17 00:00:00 2001 From: Paolo Cignoni Date: Thu, 28 Oct 2021 21:22:19 +0200 Subject: [PATCH] improved behaviour of distribution/histogram in presence of NaN --- vcg/complex/algorithms/stat.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/vcg/complex/algorithms/stat.h b/vcg/complex/algorithms/stat.h index f0e8502e..c9b0e7cb 100644 --- a/vcg/complex/algorithms/stat.h +++ b/vcg/complex/algorithms/stat.h @@ -299,11 +299,14 @@ public: static void ComputePerVertexQualityDistribution(const MeshType & m, Distribution & h, bool selectionOnly = false) // V1.0 { tri::RequirePerVertexQuality(m); + h.Clear(); for(ConstVertexIterator vi = m.vert.begin(); vi != m.vert.end(); ++vi) if(!(*vi).IsD() && ((!selectionOnly) || (*vi).IsS()) ) { - assert(!math::IsNAN((*vi).Q()) && "You should never try to compute Histogram with Invalid Floating points numbers (NaN)"); - h.Add((*vi).Q()); + if(!math::IsNAN((*vi).Q())) + h.Add((*vi).Q()); + else + assert( "You should never try to compute Histogram with Invalid Floating points numbers (NaN)"); } } @@ -311,11 +314,14 @@ public: bool selectionOnly = false) // V1.0 { tri::RequirePerFaceQuality(m); + h.Clear(); for(ConstFaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi) if(!(*fi).IsD() && ((!selectionOnly) || (*fi).IsS()) ) { - assert(!math::IsNAN((*fi).Q()) && "You should never try to compute Histogram with Invalid Floating points numbers (NaN)"); - h.Add((*fi).Q()); + if(!math::IsNAN((*fi).Q())) + h.Add((*fi).Q()); + else + assert( "You should never try to compute Histogram with Invalid Floating points numbers (NaN)"); } }