Renamed (and refactored to use Stat::MinMax function) method for ramp-coloring a mesh according to its Quality from UpdateColor::VertexQuality to UpdateColor::VertexQualityRamp.

Added UpdateColor::VertexQualityGray.
This commit is contained in:
Paolo Cignoni 2008-08-12 08:02:53 +00:00
parent 9e214da6ff
commit eb307140bb
1 changed files with 256 additions and 248 deletions
vcg/complex/trimesh/update

View File

@ -66,6 +66,8 @@ Changed name from plural to singular (normals->normal)
#include <math.h>
#include <vcg/space/color4.h>
#include <vcg/math/histogram.h>
#include <vcg/complex/trimesh/stat.h>
namespace vcg {
namespace tri {
@ -291,7 +293,7 @@ static void FaceQuality(UpdateMeshType &m, float minq, float maxq)
(*fi).C().ColorRamp(minq,maxq,(*fi).Q());
}
static void VertexQuality(UpdateMeshType &m, float minq, float maxq)
static void VertexQualityRamp(UpdateMeshType &m, float minq, float maxq)
{
typename UpdateMeshType::VertexIterator vi;
@ -300,19 +302,25 @@ static void VertexQuality(UpdateMeshType &m, float minq, float maxq)
(*vi).C().ColorRamp(minq,maxq,(*vi).Q());
}
static void VertexQuality(UpdateMeshType &m)
static void VertexQualityRamp(UpdateMeshType &m)
{
std::pair<float,float> minmax = Stat<UpdateMeshType>::ComputePerVertexQualityMinMax( m);
VertexQualityRamp(m,minmax.first,minmax.second);
}
static void VertexQualityGray(UpdateMeshType &m, const float minq, const float maxq)
{
// step 1: find the range
typename UpdateMeshType::VertexIterator vi;
float minq=std::numeric_limits<float>::max(),
maxq=-std::numeric_limits<float>::max();
for(vi=m.vert.begin();vi!=m.vert.end();++vi)
if(!(*vi).IsD())
{
minq=vcg::math::Min<float>(minq,(*vi).Q());
maxq=vcg::math::Max<float>(maxq,(*vi).Q());
(*vi).C().SetGrayShade( ((*vi).Q()-minq)/(maxq-minq));
}
VertexQuality(m,minq,maxq);
static void VertexQualityGray(UpdateMeshType &m)
{
std::pair<float,float> minmax = Stat<UpdateMeshType>::ComputePerVertexQualityMinMax( m);
VertexQualityGray(m,minmax.first,minmax.second);
}
//Fill the mesh with the selected color.