From d941439fbb3dd6df1c73dce9848ffb3da2845d59 Mon Sep 17 00:00:00 2001 From: nicopietroni Date: Fri, 16 Mar 2012 13:47:42 +0000 Subject: [PATCH] corrected several bugs and done several changes --- .../algorithms/parametrization/distorsion.h | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/vcg/complex/algorithms/parametrization/distorsion.h b/vcg/complex/algorithms/parametrization/distorsion.h index ab5400d5..f335e985 100644 --- a/vcg/complex/algorithms/parametrization/distorsion.h +++ b/vcg/complex/algorithms/parametrization/distorsion.h @@ -35,7 +35,7 @@ namespace vcg { typedef typename MeshType::CoordType CoordType; typedef typename MeshType::ScalarType ScalarType; - static ScalarType Area3D(FaceType *f) + static ScalarType Area3D(const FaceType *f) { CoordType vp0=f->P(0); CoordType vp1=f->P(1); @@ -69,7 +69,7 @@ namespace vcg { return (UVlenght); } - static ScalarType Angle3D(FaceType *f,int e) + static ScalarType Angle3D(const FaceType *f,int e) { assert((e>=0)&&(e<3)); CoordType p0=f->P((e+2)%3); @@ -84,7 +84,7 @@ namespace vcg { return angle; } - static ScalarType AngleUV(FaceType *f,int e) + static ScalarType AngleUV(const FaceType *f,int e) { vcg::Point2 uv0=f->V((e+2)%3)->T().P(); vcg::Point2 uv1=f->V(e)->T().P(); @@ -101,13 +101,23 @@ namespace vcg { ///return the variance of angle, normalized ///in absolute value - static ScalarType AngleDistorsion(FaceType *f,int e) + static ScalarType AngleDistorsion(const FaceType *f,int e) { ScalarType Angle_3D=Angle3D(f,e); ScalarType Angle_UV=AngleUV(f,e); - ScalarType diff=fabs(Angle_3D-Angle_UV)/Angle_3D; + ScalarType diff=fabs(Angle_3D-Angle_UV);///Angle_3D; return diff; } + + ///return the variance of angle, normalized + ///in absolute value + static ScalarType AngleDistorsion(const FaceType *f) + { + ScalarType angleDist=0; + for (int i=0;i<3;i++) + angleDist+=AngleDistorsion(f,i); + return angleDist; + } ///return the global scaling factor from 3D to UV static ScalarType ScalingFactor(MeshType &m, @@ -181,6 +191,18 @@ namespace vcg { int num=Folded(m); return (num>(m.fn)/2); } + + static ScalarType AngleDistorsion(const MeshType &m) + { + ScalarType UDdist=0; + for (int i=0;i