diff --git a/vcg/complex/algorithms/smooth.h b/vcg/complex/algorithms/smooth.h index 646ff166..b3515c7d 100644 --- a/vcg/complex/algorithms/smooth.h +++ b/vcg/complex/algorithms/smooth.h @@ -208,8 +208,9 @@ public: // // This function simply accumulate over a TempData all the positions of the ajacent vertices // -static void AccumulateLaplacianInfo(MeshType &m, SimpleTempData &TD) +static void AccumulateLaplacianInfo(MeshType &m, SimpleTempData &TD, bool cotangentFlag=false) { + float weight =1.0f; FaceIterator fi; for(fi=m.face.begin();fi!=m.face.end();++fi) { @@ -217,10 +218,15 @@ static void AccumulateLaplacianInfo(MeshType &m, SimpleTempDataP(); - TD[(*fi).V1(j)].sum+=(*fi).V(j)->P(); - ++TD[(*fi).V(j)].cnt; - ++TD[(*fi).V1(j)].cnt; + if(cotangentFlag) { + float angle = Angle(fi->P1(j)-fi->P2(j),fi->P0(j)-fi->P2(j)); + weight = tan(M_PI_2 - angle); + } + + TD[(*fi).V0(j)].sum+=(*fi).P1(j)*weight; + TD[(*fi).V1(j)].sum+=(*fi).P0(j)*weight; + TD[(*fi).V0(j)].cnt+=weight; + TD[(*fi).V1(j)].cnt+=weight; } } // si azzaera i dati per i vertici di bordo @@ -252,7 +258,7 @@ static void AccumulateLaplacianInfo(MeshType &m, SimpleTempData0 ) {