Added Requirements. Refactored some funcs and uniformed naming of functions...

This commit is contained in:
Paolo Cignoni 2013-09-10 10:49:01 +00:00
parent e65be2aa17
commit b849524274
1 changed files with 184 additions and 176 deletions

View File

@ -76,15 +76,21 @@ class Stat
}
static std::pair<float,float> ComputePerVertexQualityMinMax( MeshType & m)
{
// assert(0);
tri::RequirePerVertexQuality(m);
typename MeshType::template PerMeshAttributeHandle < std::pair<float,float> > mmqH;
mmqH = tri::Allocator<MeshType>::template GetPerMeshAttribute <std::pair<float,float> >(m,"minmaxQ");
std::pair<float,float> minmax = std::make_pair(std::numeric_limits<float>::max(),-std::numeric_limits<float>::max());
VertexIterator vi;
for(vi = m.vert.begin(); vi != m.vert.end(); ++vi)
for(VertexIterator vi = m.vert.begin(); vi != m.vert.end(); ++vi)
if(!(*vi).IsD())
{
if( (*vi).Q() < minmax.first) minmax.first=(*vi).Q();
if( (*vi).Q() > minmax.second) minmax.second=(*vi).Q();
}
mmqH() = minmax;
return minmax;
}
@ -93,8 +99,10 @@ class Stat
std::pair<float,float> pp=ComputePerFaceQualityMinMax(m);
minV=pp.first; maxV=pp.second;
}
static std::pair<float,float> ComputePerFaceQualityMinMax( MeshType & m)
{
tri::RequirePerFaceQuality(m);
std::pair<float,float> minmax = std::make_pair(std::numeric_limits<float>::max(),-std::numeric_limits<float>::max());
FaceIterator fi;
@ -133,8 +141,7 @@ class Stat
{
ScalarType area=0;
FaceIterator fi;
for(fi = m.face.begin(); fi != m.face.end(); ++fi)
for(FaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi)
if(!(*fi).IsD())
area += DoubleArea(*fi);
@ -143,8 +150,8 @@ class Stat
static void ComputePerVertexQualityDistribution( MeshType & m, Distribution<float> &h, bool selectionOnly = false) // V1.0
{
VertexIterator vi;
for(vi = m.vert.begin(); vi != m.vert.end(); ++vi)
tri::RequirePerVertexQuality(m);
for(VertexIterator 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)");
@ -154,8 +161,8 @@ class Stat
static void ComputePerFaceQualityDistribution( MeshType & m, Distribution<float> &h, bool selectionOnly = false) // V1.0
{
FaceIterator fi;
for(fi = m.face.begin(); fi != m.face.end(); ++fi)
tri::RequirePerFaceQuality(m);
for(FaceIterator 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)");
@ -165,6 +172,7 @@ class Stat
static void ComputePerFaceQualityHistogram( MeshType & m, Histogramf &h, bool selectionOnly=false,int HistSize=10000 )
{
tri::RequirePerFaceQuality(m);
std::pair<float,float> minmax = tri::Stat<MeshType>::ComputePerFaceQualityMinMax(m);
h.Clear();
h.SetRange( minmax.first,minmax.second, HistSize );
@ -177,12 +185,12 @@ class Stat
static void ComputePerVertexQualityHistogram( MeshType & m, Histogramf &h, bool selectionOnly = false, int HistSize=10000 ) // V1.0
{
VertexIterator vi;
tri::RequirePerVertexQuality(m);
std::pair<float,float> minmax = ComputePerVertexQualityMinMax(m);
h.Clear();
h.SetRange( minmax.first,minmax.second, HistSize);
for(vi = m.vert.begin(); vi != m.vert.end(); ++vi)
for(VertexIterator 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)");
@ -198,7 +206,7 @@ class Stat
{
std::vector<float> QV;
QV.reserve(m.vn);
for(vi = m.vert.begin(); vi != m.vert.end(); ++vi)
for(VertexIterator vi = m.vert.begin(); vi != m.vert.end(); ++vi)
if(!(*vi).IsD()) QV.push_back((*vi).Q());
std::nth_element(QV.begin(),QV.begin()+m.vn/100,QV.end());
@ -208,13 +216,13 @@ class Stat
h.Clear();
h.SetRange(newmin, newmax, HistSize*50);
for(vi = m.vert.begin(); vi != m.vert.end(); ++vi)
for(VertexIterator vi = m.vert.begin(); vi != m.vert.end(); ++vi)
if(!(*vi).IsD() && ((!selectionOnly) || (*vi).IsS()) )
h.Add((*vi).Q());
}
}
static void ComputeEdgeHistogram( MeshType & m, Histogramf &h)
static void ComputeEdgeLengthHistogram( MeshType & m, Histogramf &h)
{
assert(m.edge.size()>0);
h.Clear();
@ -228,14 +236,14 @@ class Stat
}
}
static ScalarType ComputeEdgeAverage(MeshType & m)
static ScalarType ComputeEdgeLengthAverage(MeshType & m)
{
Histogramf h;
ComputeEdgeHistogram(m,h);
ComputeEdgeLengthHistogram(m,h);
return h.Avg();
}
static void ComputeFaceEdgeDistribution( MeshType & m, Distribution<float> &h)
static void ComputeFaceEdgeLengthDistribution( MeshType & m, Distribution<float> &h)
{
h.Clear();
tri::UpdateFlags<MeshType>::FaceBorderFromNone(m);
@ -253,7 +261,7 @@ class Stat
}
}
static ScalarType ComputeFaceEdgeAverage(MeshType & m)
static ScalarType ComputeFaceEdgeLengthAverage(MeshType & m)
{
double sum=0;
for(FaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi)