Fixed manifold Test

This commit is contained in:
Paolo Cignoni 2005-09-30 15:48:46 +00:00
parent eb14792ee4
commit 1610300e86
1 changed files with 239 additions and 259 deletions

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.6 2005/09/30 14:13:01 rita_borgo
Problem: Text not aligned
Revision 1.5 2005/09/30 13:29:40 rita_borgo Revision 1.5 2005/09/30 13:29:40 rita_borgo
Fixed Manifold Test Fixed Manifold Test
@ -66,13 +69,10 @@ Added Standard comments
#include <string> #include <string>
#include <stack> #include <stack>
using namespace std; using namespace std;
#include<vcg/simplex/vertex/vertex.h> #include<vcg/simplex/vertex/vertex.h>
#include<vcg/simplex/face/with/afav.h> #include<vcg/simplex/face/with/afav.h>
#include<vcg/simplex/face/topology.h> #include<vcg/simplex/face/topology.h>
#include<vcg/simplex/face/pos.h> // mi sembra di averlo aggiunto! #include<vcg/simplex/face/pos.h> // mi sembra di averlo aggiunto!
#include<vcg/complex/trimesh/base.h> #include<vcg/complex/trimesh/base.h>
#include<vcg/complex/trimesh/update/topology.h> #include<vcg/complex/trimesh/update/topology.h>
#include <vcg/complex/trimesh/update/edges.h> #include <vcg/complex/trimesh/update/edges.h>
@ -84,35 +84,27 @@ using namespace std;
#include <wrap/io_trimesh/export_ply.h> #include <wrap/io_trimesh/export_ply.h>
#include <wrap/io_trimesh/export_stl.h> #include <wrap/io_trimesh/export_stl.h>
#include <wrap/io_trimesh/export_dxf.h> #include <wrap/io_trimesh/export_dxf.h>
#include "XMLTree.h" #include "XMLTree.h"
#include <wrap/io_trimesh/export_off.h> #include <wrap/io_trimesh/export_off.h>
// loader // loader
#include<wrap/io_trimesh/import_ply.h> #include<wrap/io_trimesh/import_ply.h>
#include "defs.h" #include "defs.h"
string ans;
using namespace vcg; using namespace vcg;
using namespace tri; using namespace tri;
using namespace face; using namespace face;
int prova1;
class MyFace; class MyFace;
class MyEdge; class MyEdge;
class MyVertex : public Vertex<float,MyEdge,MyFace>{}; class MyVertex : public Vertex<float,MyEdge,MyFace>{};
class MyFace :public FaceAFAV<MyVertex,MyEdge,MyFace>{}; class MyFace :public FaceAFAV<MyVertex,MyEdge,MyFace>{};
class MyMesh: public tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace > >{}; class MyMesh: public tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace > >{};
typedef MyMesh::VertexPointer VertexPointer; typedef MyMesh::VertexPointer VertexPointer;
typedef MyMesh::VertexIterator VertexIterator; typedef MyMesh::VertexIterator VertexIterator;
typedef Point3<MyMesh::ScalarType> Point3x; typedef Point3<MyMesh::ScalarType> Point3x;
typedef vector<Point3x> Hole; typedef vector<Point3x> Hole;
string ans;
void OpenMesh(const char *filename, MyMesh &m) void OpenMesh(const char *filename, MyMesh &m)
{ {
int err = tri::io::Importer<MyMesh>::Open(m,filename); int err = tri::io::Importer<MyMesh>::Open(m,filename);
@ -122,8 +114,6 @@ void OpenMesh(const char *filename, MyMesh &m)
} }
printf("read mesh `%s'\n", filename); printf("read mesh `%s'\n", filename);
} }
inline char* GetExtension(char* filename) inline char* GetExtension(char* filename)
{ {
for(int i=strlen(filename)-1; i >= 0; i--) for(int i=strlen(filename)-1; i >= 0; i--)
@ -134,11 +124,8 @@ inline char* GetExtension(char* filename)
else else
return NULL; return NULL;
} }
typedef MyMesh::VertexPointer VertexPointer; typedef MyMesh::VertexPointer VertexPointer;
typedef MyMesh::VertexIterator VertexIterator; typedef MyMesh::VertexIterator VertexIterator;
/* classe di confronto per l'algoritmo di individuazione vertici duplicati*/ /* classe di confronto per l'algoritmo di individuazione vertici duplicati*/
template <class VertexIterator> template <class VertexIterator>
class DuplicateVert_Compare{ class DuplicateVert_Compare{
@ -148,11 +135,8 @@ public:
return *a < *b; return *a < *b;
} }
}; };
static int DuplicateVertex( MyMesh & m )// V1.0 static int DuplicateVertex( MyMesh & m )// V1.0
{ {if(m.vert.size()==0 || m.vn==0)
if(m.vert.size()==0 || m.vn==0)
return 0; return 0;
std::map<VertexPointer, VertexPointer> mp; std::map<VertexPointer, VertexPointer> mp;
int i,j; int i,j;
@ -163,9 +147,7 @@ static int DuplicateVertex( MyMesh & m ) // V1.0
vector<VertexPointer> perm(num_vert); vector<VertexPointer> perm(num_vert);
for(vi=m.vert.begin(); vi!=m.vert.end(); ++vi, ++k) for(vi=m.vert.begin(); vi!=m.vert.end(); ++vi, ++k)
perm[k] = &(*vi); perm[k] = &(*vi);
DuplicateVert_Compare<VertexPointer> c_obj; DuplicateVert_Compare<VertexPointer> c_obj;
std::sort(perm.begin(),perm.end(),c_obj); std::sort(perm.begin(),perm.end(),c_obj);
j = 0; j = 0;
i = j; i = j;
@ -203,25 +185,19 @@ static int DuplicateVertex( MyMesh & m ) // V1.0
return deleted; return deleted;
} }
void main(int argc,char ** argv){ void main(int argc,char ** argv){
MyMesh m; MyMesh m;
bool DEBUG = true; bool DEBUG=false;
int k;
k=3;
int j; int j;
j=0; j=0;
cout<<"Punto 1"<<endl;
/*------------XML file part ------------------*/
static char* XML_SCHEMA_NAME = "protegekb"; /*------------XML file part ------------------*/static char* XML_SCHEMA_NAME = "protegekb";
XMLTree doc; XMLTree doc;
MainNode* mn = new MainNode; MainNode* mn = new MainNode;
/*--------------------------------------------*/ /*--------------------------------------------*/
cout<<"Punto 2"<<endl;
//load the mesh //load the mesh
//argv[1]=(char*)"c:\\checkup\\debug\\column1m.ply"; //argv[1]=(char*)"c:\\checkup\\debug\\column1m.ply";
@ -235,7 +211,7 @@ cout<<"Punto 2"<<endl;
" release date: "__DATE__"\n" " release date: "__DATE__"\n"
"-------------------------------\n\n"); "-------------------------------\n\n");
cout<<"Punto 3"<<endl;
if(DEBUG) if(DEBUG)
argv[1] = "C:\\sf\\apps\\msvc\\trimeshinfo\\Release\\tests\\kite_hole3.ply"; argv[1] = "C:\\sf\\apps\\msvc\\trimeshinfo\\Release\\tests\\kite_hole3.ply";
@ -249,12 +225,13 @@ cout<<"Punto 3"<<endl;
exit(-1); exit(-1);
} }
} }
cout<<"Punto 4"<<endl;
OpenMesh(argv[1],m); OpenMesh(argv[1],m);
cout<<"Punto 5"<<endl;
/*------------XML file part ------------------*/ /*------------XML file part ------------------*/
@ -281,7 +258,6 @@ cout<<"Punto 5"<<endl;
printf("\t Number of faces: %d \n", m.fn); printf("\t Number of faces: %d \n", m.fn);
cout<<"Punto 6"<<endl;
/*------------XML file part ------------------*/ /*------------XML file part ------------------*/
NodeGroup* ng = new NodeGroup; NodeGroup* ng = new NodeGroup;
@ -315,7 +291,6 @@ cout<<"Punto 6"<<endl;
ng->addNode(osn); ng->addNode(osn);
/*--------------------------------------------*/ /*--------------------------------------------*/
cout<<"Punto 7"<<endl;
if(m.HasPerFaceColor()||m.HasPerVertexColor()) if(m.HasPerFaceColor()||m.HasPerVertexColor())
@ -341,7 +316,7 @@ cout<<"Punto 7"<<endl;
/*--------------------------------------------*/ /*--------------------------------------------*/
} }
cout<<"Punto 8"<<endl;
vcg::tri::UpdateTopology<MyMesh>::FaceFace(m); vcg::tri::UpdateTopology<MyMesh>::FaceFace(m);
// IS MANIFOLD // IS MANIFOLD
@ -350,8 +325,13 @@ cout<<"Punto 7"<<endl;
vcg::face::Pos<MyMesh::FaceType> he; vcg::face::Pos<MyMesh::FaceType> he;
vcg::face::Pos<MyMesh::FaceType> hei; vcg::face::Pos<MyMesh::FaceType> hei;
for(fi=m.face.begin();fi!=m.face.end();++fi) for(fi=m.face.begin();fi!=m.face.end();fi++)
{
(*fi).ClearB(0);
(*fi).ClearB(1);
(*fi).ClearB(2);
(*fi).ClearS(); (*fi).ClearS();
}
int cf=0; int cf=0;
bool Manifold=true; bool Manifold=true;
@ -368,13 +348,12 @@ cout<<"Punto 7"<<endl;
--fi; --fi;
j=3; j=3;
} }
else if((!fi->HasFFAdjacency())&&(fi!=m.face.begin())) }
if((BorderCount(*fi)>0))
{ {
Manifold = false; Manifold = false;
fi= m.face.end(); fi= m.face.end();
--fi; --fi;
j=3;
}
} }
} }
@ -692,6 +671,7 @@ cout<<"Punto 7"<<endl;
// CONNECTED COMPONENTS // CONNECTED COMPONENTS
vector<int> nrfaces; vector<int> nrfaces;
nrfaces.reserve(1);
for(fi=m.face.begin();fi!=m.face.end();++fi) for(fi=m.face.begin();fi!=m.face.end();++fi)
(*fi).ClearS(); (*fi).ClearS();
gi=m.face.begin(); fi=gi; gi=m.face.begin(); fi=gi;
@ -703,7 +683,7 @@ cout<<"Punto 7"<<endl;
if (!(*fi).IsS()) if (!(*fi).IsS())
{ {
(*fi).SetS(); (*fi).SetS();
(*fi).Q()=Compindex; //(*fi).Q()=Compindex;
nrfaces.push_back(1); nrfaces.push_back(1);
sf.push(fi); sf.push(fi);
while (!sf.empty()) while (!sf.empty())
@ -776,7 +756,7 @@ cout<<"Punto 7"<<endl;
else//(!Manifold) else//(!Manifold)
{ {
fprintf( index,"<p>Genus: UNDEFINED, mesh is non-manifold </p>\n"); fprintf( index,"<p>Genus: UNDEFINED, mesh is non-manifold </p>\n");
printf( "Genus: UNDEFINED, mesh is non-manifold \n"); printf( "\t Genus: UNDEFINED, mesh is non-manifold \n");
} }
// REGULARITY // REGULARITY