added functionalities to evaluate distortion wrt a cross field
This commit is contained in:
parent
46f8492f05
commit
83f0deca4d
|
@ -24,6 +24,7 @@
|
||||||
#ifndef VCG_PARAM_DISTORTION
|
#ifndef VCG_PARAM_DISTORTION
|
||||||
#define VCG_PARAM_DISTORTION
|
#define VCG_PARAM_DISTORTION
|
||||||
#include <vcg/complex/algorithms/parametrization/uv_utils.h>
|
#include <vcg/complex/algorithms/parametrization/uv_utils.h>
|
||||||
|
#include <vcg/complex/algorithms/parametrization/tangent_field_operators.h>
|
||||||
|
|
||||||
namespace vcg {
|
namespace vcg {
|
||||||
namespace tri{
|
namespace tri{
|
||||||
|
@ -151,7 +152,7 @@ namespace vcg {
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum DistType{AreaDist,EdgeDist,AngleDist};
|
enum DistType{AreaDist,EdgeDist,AngleDist,CrossDist};
|
||||||
|
|
||||||
///return the absolute difference between angle in 3D space and texture space
|
///return the absolute difference between angle in 3D space and texture space
|
||||||
///Actually the difference in cos space
|
///Actually the difference in cos space
|
||||||
|
@ -168,7 +169,7 @@ namespace vcg {
|
||||||
{
|
{
|
||||||
ScalarType Angle_3D=AngleRad3D(f,e);
|
ScalarType Angle_3D=AngleRad3D(f,e);
|
||||||
ScalarType Angle_UV=AngleRadUV(f,e);
|
ScalarType Angle_UV=AngleRadUV(f,e);
|
||||||
ScalarType diff=fabs(Angle_3D-Angle_UV);///Angle_3D;
|
ScalarType diff=fabs(Angle_3D-Angle_UV)/Angle_3D;///Angle_3D;
|
||||||
return diff;
|
return diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,9 +177,9 @@ namespace vcg {
|
||||||
///in absolute value
|
///in absolute value
|
||||||
static ScalarType AngleDistortion(const FaceType *f)
|
static ScalarType AngleDistortion(const FaceType *f)
|
||||||
{
|
{
|
||||||
return AngleRadDistortion(f,0) +
|
return (AngleRadDistortion(f,0) +
|
||||||
AngleRadDistortion(f,1) +
|
AngleRadDistortion(f,1) +
|
||||||
AngleRadDistortion(f,2);
|
AngleRadDistortion(f,2))/3.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
///return the global scaling factors from 3D to UV
|
///return the global scaling factors from 3D to UV
|
||||||
|
@ -270,24 +271,69 @@ namespace vcg {
|
||||||
return UDdist;
|
return UDdist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void SetQasCrossDirDistortion(MeshType &m)
|
||||||
|
{
|
||||||
|
//first save the old UV dir
|
||||||
|
std::vector<CoordType> Dir1,Dir2;
|
||||||
|
for (size_t i=0;i<m.face.size();i++)
|
||||||
|
{
|
||||||
|
Dir1.push_back(m.face[i].PD1());
|
||||||
|
Dir2.push_back(m.face[i].PD2());
|
||||||
|
}
|
||||||
|
vcg::tri::CrossField<MeshType>::InitDirFromWEdgeUV(m);
|
||||||
|
|
||||||
|
//then compute angle deficit
|
||||||
|
for (size_t i=0;i<m.face.size();i++)
|
||||||
|
{
|
||||||
|
CoordType transfPD1=vcg::tri::CrossField<MeshType>::K_PI(Dir1[i],
|
||||||
|
m.face[i].PD1(),
|
||||||
|
m.face[i].N());
|
||||||
|
transfPD1.Normalize();
|
||||||
|
ScalarType AngleDeficit=vcg::Angle(transfPD1,m.face[i].PD1());
|
||||||
|
AngleDeficit=math::ToDeg(AngleDeficit);
|
||||||
|
if ((AngleDeficit>45)||(AngleDeficit<0))
|
||||||
|
{
|
||||||
|
std::cout<<"Warnign A Deficit "<<AngleDeficit<<std::endl;
|
||||||
|
}
|
||||||
|
// assert(AngleDeficit<45);
|
||||||
|
// assert(AngleDeficit>=0);
|
||||||
|
m.face[i].Q()=(AngleDeficit)/(ScalarType)45;
|
||||||
|
}
|
||||||
|
|
||||||
|
//finally restore the original directions
|
||||||
|
for (size_t i=0;i<m.face.size();i++)
|
||||||
|
{
|
||||||
|
m.face[i].PD1()=Dir1[i];
|
||||||
|
m.face[i].PD2()=Dir2[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void SetQasDistorsion(MeshType &m,
|
static void SetQasDistorsion(MeshType &m,
|
||||||
DistType DType=AreaDist)
|
DistType DType=AreaDist)
|
||||||
{
|
{
|
||||||
|
if (DType==CrossDist)
|
||||||
|
{
|
||||||
|
SetQasCrossDirDistortion(m);
|
||||||
|
vcg::tri::UpdateQuality<MeshType>::VertexFromFace(m,true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ScalarType edge_scale,area_scale;
|
ScalarType edge_scale,area_scale;
|
||||||
MeshScalingFactor(m,area_scale,edge_scale);
|
MeshScalingFactor(m,area_scale,edge_scale);
|
||||||
for (int i=0;i<m.face.size();i++)
|
for (int i=0;i<m.face.size();i++)
|
||||||
{
|
{
|
||||||
if (m.face[i].IsD())continue;
|
if (m.face[i].IsD())continue;
|
||||||
if (DType==AreaDist)
|
if (DType==AreaDist)
|
||||||
m.face[i].Q()=1-AreaDistortion(&m.face[i],area_scale);
|
m.face[i].Q()=AreaDistortion(&m.face[i],area_scale);
|
||||||
else
|
else
|
||||||
if (DType==AngleDist)
|
if (DType==AngleDist)
|
||||||
m.face[i].Q()=1-AngleDistortion(&m.face[i]);
|
m.face[i].Q()=AngleDistortion(&m.face[i]);
|
||||||
else
|
else
|
||||||
m.face[i].Q()=3-EdgeDistortion(&m.face[i],0,edge_scale)-
|
m.face[i].Q()=(EdgeDistortion(&m.face[i],0,edge_scale)+
|
||||||
EdgeDistortion(&m.face[i],1,edge_scale)-
|
EdgeDistortion(&m.face[i],1,edge_scale)+
|
||||||
EdgeDistortion(&m.face[i],2,edge_scale);
|
EdgeDistortion(&m.face[i],2,edge_scale))/3.0;
|
||||||
}
|
}
|
||||||
|
vcg::tri::UpdateQuality<MeshType>::VertexFromFace(m,true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue