From 65933201d733a0625bcd5c84606ca9d93fc4ca5a Mon Sep 17 00:00:00 2001 From: cignoni Date: Mon, 7 Apr 2008 08:20:26 +0000 Subject: [PATCH] Added texture topology computation --- vcg/complex/trimesh/update/topology.h | 112 ++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/vcg/complex/trimesh/update/topology.h b/vcg/complex/trimesh/update/topology.h index 488f65b0..a2716e09 100644 --- a/vcg/complex/trimesh/update/topology.h +++ b/vcg/complex/trimesh/update/topology.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.20 2008/04/04 10:27:34 cignoni +minor changes to the topology correctness checks + Revision 1.19 2007/05/29 00:07:06 ponchio VFi++ -> ++VFi @@ -263,6 +266,115 @@ static void VertexFace(MeshType &m) } } + + +/// Auxiliairy data structure for computing face face adjacency information. +// It identifies and edge storing two vertex pointer and a face pointer where it belong. +class PEdgeTex +{ +public: + + typename FaceType::TexCoordType v[2]; // the two Vertex pointer are ordered! + FacePointer f; // the face where this edge belong + int z; // index in [0..2] of the edge of the face + + PEdgeTex() {} + +void Set( FacePointer pf, const int nz ) +{ + assert(pf!=0); + assert(nz>=0); + assert(nz<3); + + v[0] = pf->WT(nz); + v[1] = pf->WT((nz+1)%3); + assert(v[0] != v[1]); // The face pointed by 'f' is Degenerate (two coincident vertexes) + + if( v[1] < v[0] ) swap(v[0],v[1]); + f = pf; + z = nz; +} + +inline bool operator < ( const PEdgeTex & pe ) const +{ + if( v[0] e; + FaceIterator pf; + typename std::vector::iterator p; + + if( m.fn == 0 ) return; + + e.resize(m.fn*3); // Alloco il vettore ausiliario + p = e.begin(); + for(pf=m.face.begin();pf!=m.face.end();++pf) // Lo riempio con i dati delle facce + if( ! (*pf).IsD() ) + for(int j=0;j<3;++j) + { + (*p).Set(&(*pf),j); + ++p; + } + assert(p==e.end()); + sort(e.begin(), e.end()); // Lo ordino per vertici + + int ne = 0; // Numero di edge reali + + typename std::vector::iterator pe,ps; + ps = e.begin();pe=e.begin(); + //for(ps = e.begin(),pe=e.begin();pe<=e.end();++pe) // Scansione vettore ausiliario + do + { + if( pe==e.end() || (*pe) != (*ps) ) // Trovo blocco di edge uguali + { + typename std::vector::iterator q,q_next; + for (q=ps;q=0); + assert((*q).z< 3); + q_next = q; + ++q_next; + assert((*q_next).z>=0); + assert((*q_next).z< 3); + (*q).f->FFp(q->z) = (*q_next).f; // Collegamento in lista delle facce + (*q).f->FFi(q->z) = (*q_next).z; + } + assert((*q).z>=0); + assert((*q).z< 3); + (*q).f->FFp((*q).z) = ps->f; + (*q).f->FFi((*q).z) = ps->z; + ps = pe; + ++ne; // Aggiorno il numero di edge + } + if(pe==e.end()) break; + ++pe; + } while(true); +} + + + + + ///test correctness of VFtopology static void TestVertexFace(MeshType &m) {