From 629e12915274d5bc8ae76b38d496ed70c5b05fad Mon Sep 17 00:00:00 2001 From: cignoni Date: Fri, 2 May 2008 11:35:45 +0000 Subject: [PATCH] removed useless code (two functions were repeated) --- vcg/complex/trimesh/textcoord_optimization.h | 108 +------------------ 1 file changed, 4 insertions(+), 104 deletions(-) diff --git a/vcg/complex/trimesh/textcoord_optimization.h b/vcg/complex/trimesh/textcoord_optimization.h index 0534de6d..a9f013b4 100644 --- a/vcg/complex/trimesh/textcoord_optimization.h +++ b/vcg/complex/trimesh/textcoord_optimization.h @@ -24,6 +24,10 @@ History $Log: not supported by cvs2svn $ +Revision 1.6 2007/02/02 04:11:00 tarini +added parameter theta (from conformal to equiareal) to AreaPresTextureOptimizer. +Improved feature lists (comments). + Revision 1.5 2007/02/02 01:39:58 tarini added three general-utility global functions for texture coordinates: SmoothTextureCoords, IsFoldFree, MarkFolds (see descriptions) @@ -444,110 +448,6 @@ void SmoothTextureCoords(MESH_TYPE &m){ -/* texture coords general utility functions */ -/*++++++++++++++++++++++++++++++++++++++++++*/ - -// returns false if any fold is present (faster than MarkFolds) -template -bool IsFoldFree(MESH_TYPE &m){ - - assert(m.HasPerVertexTexture()); - - typedef typename MESH_TYPE::VertexType::TextureType::PointType PointType; - typedef typename MESH_TYPE::VertexType::TextureType::PointType::ScalarType ScalarType; - - ScalarType lastsign=0; - for (typename MESH_TYPE::FaceIterator f=m.face.begin(); f!=m.face.end(); f++){ - ScalarType sign=((f->V(1)->T().P()-f->V(0)->T().P()) ^ (f->V(2)->T().P()-f->V(0)->T().P())); - if (sign!=0) { - if (sign*lastsign<0) return false; - lastsign=sign; - } - } - return true; -} - -// detects and marks folded faces, by setting their quality to 0 (or 1 otherwise) -// returns number of folded faces -template -int MarkFolds(MESH_TYPE &m){ - - assert(m.HasPerVertexTexture()); - assert(m.HasPerFaceQuality()); - - typedef typename MESH_TYPE::VertexType::TextureType::PointType PointType; - typedef typename MESH_TYPE::VertexType::TextureType::PointType::ScalarType ScalarType; - - SimpleTempData sign(m.face); - sign.Start(0); - - // first pass, determine predominant sign - int npos=0, nneg=0; - ScalarType lastsign=0; - for (typename MESH_TYPE::FaceIterator f=m.face.begin(); f!=m.face.end(); f++){ - ScalarType fsign=((f->V(1)->T().P()-f->V(0)->T().P()) ^ (f->V(2)->T().P()-f->V(0)->T().P())); - if (fsign<0) { sign[f]=-1; nneg++; } - if (fsign>0) { sign[f]=+1; npos++; } - } - - // second pass, detect folded faces - int res=0; - short gsign= (nneg>npos)?-1:+1; - for (typename MESH_TYPE::FaceIterator f=m.face.begin(); f!=m.face.end(); f++){ - if (sign[f]*gsign<0){ - res++; - f->Q()=0; - } else f->Q()=1; - } - - sign.Stop(); - - return res; -} - -// Smooths texture coords. -// (can be useful to remove folds, -// e.g. these created when obtaining tecture coordinates after projections) -template -void SmoothTextureCoords(MESH_TYPE &m){ - - assert(m.HasPerVertexTexture()); - - typedef typename MESH_TYPE::VertexType::TextureType::PointType PointType; - - SimpleTempData div(m.vert); - SimpleTempData sum(m.vert); - - div.Start(); - sum.Start(); - - for (typename MESH_TYPE::VertexIterator v=m.vert.begin(); v!=m.vert.end(); v++) { - sum[v].Zero(); - div[v]=0; - } - - for (typename MESH_TYPE::FaceIterator f=m.face.begin(); f!=m.face.end(); f++){ - div[f->V(0)] +=2; sum[f->V(0)] += f->V(2)->T().P(); sum[f->V(0)] += f->V(1)->T().P(); - div[f->V(1)] +=2; sum[f->V(1)] += f->V(0)->T().P(); sum[f->V(1)] += f->V(2)->T().P(); - div[f->V(2)] +=2; sum[f->V(2)] += f->V(1)->T().P(); sum[f->V(2)] += f->V(0)->T().P(); - } - - for (typename MESH_TYPE::VertexIterator v=m.vert.begin(); v!=m.vert.end(); v++) // if (!v->IsB()) - { - if (v->div>0) { - v->T().P() = sum[v]/div[v]; - } - } - - div.Stop(); - sum.Stop(); - -} - - - - - } } // End namespace vcg::tri #endif // __VCGLIB__TEXTCOOORD_OPTIMIZATION