From b24b496f50e8e7ea019c15daf16b07dfe2db714c Mon Sep 17 00:00:00 2001 From: cignoni Date: Thu, 18 May 2006 13:59:20 +0000 Subject: [PATCH] Some minor optimizations --- vcg/complex/trimesh/clustering.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/vcg/complex/trimesh/clustering.h b/vcg/complex/trimesh/clustering.h index 14691b20..807ee30c 100644 --- a/vcg/complex/trimesh/clustering.h +++ b/vcg/complex/trimesh/clustering.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.1 2006/05/16 21:56:06 cignoni +First working Version + ****************************************************************************/ #ifndef __VCGLIB_CLUSTERING @@ -77,6 +80,9 @@ public: {return Hash();} }; + + +// template class AverageCell { @@ -86,7 +92,9 @@ class AverageCell inline void Add(MeshType &m, FaceType &f, int i) { p+=f.cV(i)->cP(); - n+=f.cV(i)->cN(); + // we prefer to use the un-normalized face normal so small faces facing away are dropped out + // and the resulting average is weighed with the size of the faces falling here. + n+=f.cN(); cnt++; } AverageCell(): p(0,0,0), n(0,0,0),cnt(0){} @@ -213,8 +221,9 @@ class Clustering if( N*(*ti).v[0]->n <0) ++badOrient; if( N*(*ti).v[1]->n <0) ++badOrient; if( N*(*ti).v[2]->n <0) ++badOrient; - if(badOrient>=2) + if(badOrient>2) swap(m.face[i].V(0),m.face[i].V(1)); + i++; }