diff --git a/vcg/complex/trimesh/smooth.h b/vcg/complex/trimesh/smooth.h index e4b5d9dc..e7ece35a 100644 --- a/vcg/complex/trimesh/smooth.h +++ b/vcg/complex/trimesh/smooth.h @@ -643,6 +643,43 @@ static void VertexColorLaplacian(MeshType &m, int step, bool SmoothSelected=fals } // end for step }; +static void FaceColorLaplacian(MeshType &m, int step, bool SmoothSelected=false, vcg::CallBackPos * cb=0) +{ + ColorSmoothInfo csi; + csi.r=0; csi.g=0; csi.b=0; csi.cnt=0; + SimpleTempData TD(m.face,csi); + + for(int i=0;iC()[0]; + TD[*fi].g+=(*fi).FFp(j)->C()[1]; + TD[*fi].b+=(*fi).FFp(j)->C()[2]; + TD[*fi].a+=(*fi).FFp(j)->C()[3]; + ++TD[*fi].cnt; + } + } + for(fi=m.face.begin();fi!=m.face.end();++fi) + if(!(*fi).IsD() && TD[*fi].cnt>0 ) + if(!SmoothSelected || (*fi).IsS()) + { + (*fi).C()[0] = (unsigned int) ceil((float) (TD[*fi].r / TD[*fi].cnt)); + (*fi).C()[1] = (unsigned int) ceil((float) (TD[*fi].g / TD[*fi].cnt)); + (*fi).C()[2] = (unsigned int) ceil((float) (TD[*fi].b / TD[*fi].cnt)); + (*fi).C()[3] = (unsigned int) ceil((float) (TD[*fi].a / TD[*fi].cnt)); + } + } // end for step +}; // Laplacian smooth of the quality.