removed useless code (two functions were repeated)

This commit is contained in:
Paolo Cignoni 2008-05-02 11:35:45 +00:00
parent 4114e0e60a
commit 629e129152
1 changed files with 4 additions and 104 deletions

View File

@ -24,6 +24,10 @@
History History
$Log: not supported by cvs2svn $ $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 Revision 1.5 2007/02/02 01:39:58 tarini
added three general-utility global functions for texture coordinates: SmoothTextureCoords, IsFoldFree, MarkFolds (see descriptions) 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<class MESH_TYPE>
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<class MESH_TYPE>
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<typename MESH_TYPE::FaceContainer, short> 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<class MESH_TYPE>
void SmoothTextureCoords(MESH_TYPE &m){
assert(m.HasPerVertexTexture());
typedef typename MESH_TYPE::VertexType::TextureType::PointType PointType;
SimpleTempData<typename MESH_TYPE::VertContainer, int> div(m.vert);
SimpleTempData<typename MESH_TYPE::VertContainer, PointType > 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 } } // End namespace vcg::tri
#endif // __VCGLIB__TEXTCOOORD_OPTIMIZATION #endif // __VCGLIB__TEXTCOOORD_OPTIMIZATION