From 804ee386e46441c2accbe7b68886044242885cc1 Mon Sep 17 00:00:00 2001 From: Nico Pietroni nicopietroni Date: Fri, 18 Sep 2009 10:15:07 +0000 Subject: [PATCH] added AbstractArea, corrected some bugs and added parameter num to Interpolate function to limit the interpolation on a fixed number of elements --- .../filter_isoparametrization/tangent_space.h | 54 +++++++++++++------ 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/src/meshlabplugins/filter_isoparametrization/tangent_space.h b/src/meshlabplugins/filter_isoparametrization/tangent_space.h index d7fda977c..67ca08bed 100644 --- a/src/meshlabplugins/filter_isoparametrization/tangent_space.h +++ b/src/meshlabplugins/filter_isoparametrization/tangent_space.h @@ -7,23 +7,16 @@ class TangentSpace{ typedef IsoParametrization::CoordType CoordType; typedef IsoParametrization::ScalarType ScalarType; - IsoParametrization *isoParam; + vcg::SimpleTempData > *ProjMatrix; public: - + IsoParametrization *isoParam; bool isoParamTheta(int i, vcg::Point2 p, vcg::Point3 &res) const{ return isoParam->Theta(i,p,res); - - vcg::Point3 c(0,0,10);//(0.5,sqrt(3.0)/2.0,0); - vcg::Point3 b(1,0,0); - vcg::Point3 a(0,0,0); - res = a*p[0]+b*p[1]+c*(1-p[0]-p[1]) - +vcg::Point3(4,4,4); - return true; } // @@ -32,6 +25,15 @@ public: CoordType &pos3D){ isoParamTheta(i,UV,pos3D); } + + bool Theta(const int &I, + const vcg::Point2 &alpha_beta, // alphaBeta + std::vector &face, + std::vector &baryVal) + { + int ret=isoParam->Theta(I,alpha_beta,face,baryVal); + return (ret!=-1); + } ///initialize the sampler void Init(IsoParametrization *_isoParam,ScalarType radius=(ScalarType)0.1) @@ -334,7 +336,12 @@ public: { ParamFace* face=NULL; CoordType baryVal; - isoParam->Theta(I,alpha_beta,face,baryVal); + int dom=isoParam->Theta(I,alpha_beta,face,baryVal); + if (dom==-1) + { + projMatr.SetIdentity(); + return; + } ParamVertex *v0=face->V(0); ParamVertex *v1=face->V(1); ParamVertex *v2=face->V(2); @@ -417,44 +424,57 @@ public: return true; } + ScalarType AbstractArea() + { + ScalarType Cnum=sqrt(3.0)/4.0; + return(isoParam->AbsMesh()->fn*Cnum); + } + // WEIGHTED INTERPOLATION OF POINTS IN TANGENT SPACE /// weights MUST be normalized bool Interpolate(const std::vector &I, const std::vector > &alpha_beta, const std::vector &weights, int &I_res, - vcg::Point2 &alpha_beta_res) + vcg::Point2 &alpha_beta_res, + int *num=NULL) { + int size; + if (num==NULL) + size=alpha_beta.size(); + else + size=*num; + int IndexDomain; - int kind=isoParam->InterpolationSpace(I,IndexDomain); + int kind=isoParam->InterpolationSpace(I,IndexDomain,num); if (kind==-1) return false; std::vector > transformed; - transformed.resize(alpha_beta.size()); + transformed.resize(size); ///interpolate in a face if (kind==0) { - for (int i=0;iGE2(IndexDomain,alpha_beta[i],transformed[i]); } else ///interpolate in a diamond if (kind==1) { - for (int i=0;iGE1(I[i],alpha_beta[i],IndexDomain,transformed[i]); } else { - for (int i=0;iGE0(I[i],alpha_beta[i],IndexDomain,transformed[i]); } /// do the interpolation vcg::Point2 UV_interp=vcg::Point2(0,0); - for (int i=0;i