improved behaviour of distribution/histogram in presence of NaN

This commit is contained in:
Paolo Cignoni 2021-10-28 21:22:19 +02:00
parent 448c340d3a
commit a0d239ec26
1 changed files with 10 additions and 4 deletions

View File

@ -299,11 +299,14 @@ public:
static void ComputePerVertexQualityDistribution(const MeshType & m, Distribution<ScalarType> & h, bool selectionOnly = false) // V1.0 static void ComputePerVertexQualityDistribution(const MeshType & m, Distribution<ScalarType> & h, bool selectionOnly = false) // V1.0
{ {
tri::RequirePerVertexQuality(m); tri::RequirePerVertexQuality(m);
h.Clear();
for(ConstVertexIterator vi = m.vert.begin(); vi != m.vert.end(); ++vi) for(ConstVertexIterator vi = m.vert.begin(); vi != m.vert.end(); ++vi)
if(!(*vi).IsD() && ((!selectionOnly) || (*vi).IsS()) ) if(!(*vi).IsD() && ((!selectionOnly) || (*vi).IsS()) )
{ {
assert(!math::IsNAN((*vi).Q()) && "You should never try to compute Histogram with Invalid Floating points numbers (NaN)"); if(!math::IsNAN((*vi).Q()))
h.Add((*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 bool selectionOnly = false) // V1.0
{ {
tri::RequirePerFaceQuality(m); tri::RequirePerFaceQuality(m);
h.Clear();
for(ConstFaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi) for(ConstFaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi)
if(!(*fi).IsD() && ((!selectionOnly) || (*fi).IsS()) ) if(!(*fi).IsD() && ((!selectionOnly) || (*fi).IsS()) )
{ {
assert(!math::IsNAN((*fi).Q()) && "You should never try to compute Histogram with Invalid Floating points numbers (NaN)"); if(!math::IsNAN((*fi).Q()))
h.Add((*fi).Q()); h.Add((*fi).Q());
else
assert( "You should never try to compute Histogram with Invalid Floating points numbers (NaN)");
} }
} }