From f5d1b6c3374b9f3bb6bde1ad3342a76fab9aeacb Mon Sep 17 00:00:00 2001 From: cignoni Date: Mon, 14 Nov 2005 09:28:18 +0000 Subject: [PATCH] changed access to face functions (border, area) removed some typecast warnings --- vcg/complex/trimesh/clean.h | 55 ++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/vcg/complex/trimesh/clean.h b/vcg/complex/trimesh/clean.h index 9ec8b988..03e33b85 100644 --- a/vcg/complex/trimesh/clean.h +++ b/vcg/complex/trimesh/clean.h @@ -24,6 +24,10 @@ History $Log: not supported by cvs2svn $ +Revision 1.8 2005/10/11 16:03:40 rita_borgo +Added new functions belonging to triMeshInfo +Started the Self-Intersection routine + Revision 1.7 2005/10/03 15:57:53 rita_borgo Alligned with TriMeshInfo Code @@ -55,6 +59,7 @@ Initial Release #include #include +#include #include #include #include @@ -93,12 +98,11 @@ namespace vcg { vcg::face::Pos hei; /* classe di confronto per l'algoritmo di eliminazione vertici duplicati*/ - template class RemoveDuplicateVert_Compare{ public: - inline bool operator() (VertexIterator a, VertexIterator b) + inline bool operator()(VertexPointer &a, VertexPointer &b) { - return *a < *b; + return (*a).cP() < (*b).cP(); } }; @@ -147,12 +151,12 @@ namespace vcg { VertexIterator vi; int deleted=0; int k=0; - int num_vert = m.vert.size(); + size_t num_vert = m.vert.size(); std::vector perm(num_vert); for(vi=m.vert.begin(); vi!=m.vert.end(); ++vi, ++k) perm[k] = &(*vi); - RemoveDuplicateVert_Compare c_obj; + RemoveDuplicateVert_Compare c_obj; std::sort(perm.begin(),perm.end(),c_obj); @@ -262,7 +266,7 @@ namespace vcg { count_e +=3; //assume that we have to increase the number of edges with three for(int j=0; j<3; j++) { - if (fi->IsBorder(j)) //If this edge is a border edge + if (face::IsBorder(*fi,j)) //If this edge is a border edge boundary_e++; // then increase the number of boundary edges else if (IsManifold(*fi,j))//If this edge is manifold { @@ -321,7 +325,7 @@ namespace vcg { { if(fi->V(j)->IsS()) continue; - if((*fi).IsBorder(j))//found an unvisited border edge + if(face::IsBorder(*fi,j))//found an unvisited border edge { he.Set(&(*fi),j,fi->V(j)); //set the face-face iterator to the current face, edge and vertex vector hole; //start of a new hole @@ -339,7 +343,7 @@ namespace vcg { //cut and paste the additional hole. vector hole2; int index = find(hole.begin(),hole.end(),newpoint) - hole.begin(); - for(int i=index; iFFp(j); if( !(*l).IsS() ) @@ -425,16 +429,41 @@ namespace vcg { for(fi=m.face.begin(); fi!=m.face.end();++fi) - if((*fi).Area() == 0) + if(Area(*fi) == 0) count_fd++; return count_fd; } + /** + GENUS: A topologically invariant property of a surface defined as: + the largest number of nonintersecting simple closed curves that can be drawn on the surface without separating it. + Roughly speaking, it is the number of holes in a surface. + The genus g of a surface, also called the geometric genus, is related to the Euler characteristic $chi$ by $chi==2-2g$. + + The genus of a connected, orientable surface is an integer representing the maximum number of cuttings along closed + simple curves without rendering the resultant manifold disconnected. It is equal to the number of handles on it. - static float MeshGenus(MeshType &m, int count_uv, int numholes, int numcomponents, int count_e) + */ + static int MeshGenus(MeshType &m, int count_uv, int numholes, int numcomponents, int count_e) { int eulernumber = (m.vn-count_uv) + m.fn - count_e; return(-( 0.5 * (eulernumber - numholes) - numcomponents )); } +/* +Let a closed surface have genus g. Then the polyhedral formula generalizes to the Poincaré formula +chi=V-E+F, (1) + +where +chi(g)==2-2g (2) + +is the Euler characteristic, sometimes also known as the Euler-Poincaré characteristic. +The polyhedral formula corresponds to the special case g==0. +*/ + + static int EulerCharacteristic() + { + + } + static void IsRegularMesh(MeshType &m, bool Regular, bool Semiregular) { @@ -450,7 +479,7 @@ namespace vcg { for (int j=0; j<3; j++) { he.Set(&(*fi),j,fi->V(j)); - if (!(*fi).IsBorder(j) && !(*fi).IsBorder((j+2)%3) && !fi->V(j)->IsS()) + if (!face::IsBorder(*fi,j) && !face::IsBorder(*fi,(j+2)%3) && !fi->V(j)->IsS()) { hei=he; inc=1; @@ -512,7 +541,7 @@ namespace vcg { sf.pop(); for(int j=0;j<3;++j) { - if( !(*gi).IsBorder(j) ) + if( !face::IsBorder(*gi,j) ) { he.Set(&(*gi),0,gi->V(0)); l=he.f->FFp(j);