From 2987126008bef7fb61ee80f9b62ab177877da28e Mon Sep 17 00:00:00 2001 From: cnr-isti-vclab Date: Fri, 7 Jan 2005 16:38:09 +0000 Subject: [PATCH] Added Oriented/Orientable but still some errors on those routines --- apps/trimeshinfo/main.cpp | 349 ++++++++++++++++++++++---------------- 1 file changed, 199 insertions(+), 150 deletions(-) diff --git a/apps/trimeshinfo/main.cpp b/apps/trimeshinfo/main.cpp index 93ae7b81..462e1d56 100644 --- a/apps/trimeshinfo/main.cpp +++ b/apps/trimeshinfo/main.cpp @@ -24,15 +24,20 @@ History $Log: not supported by cvs2svn $ +Revision 1.2 2005/01/03 16:13:09 rita_borgo +Added Standard comments + ****************************************************************************/ #include -#include // anche questo +#include +#include using namespace std; #include #include +#include #include // mi sembra di averlo aggiunto! @@ -49,7 +54,7 @@ using namespace std; #include using namespace vcg; - +using namespace face; class MyFace; class MyEdge; @@ -74,8 +79,8 @@ void main(int argc,char ** argv){ MyMesh m; //load the mesh //argv[1]=(char*)"c:\\checkup\\debug\\column1m.ply"; - //argv[1] = "C:\\Documents and Settings\\Rita\\Desktop\\MeshReader\\prova2.ply"; - vcg::tri::io::ImporterPLY::Open(m,argv[1]); + argv[1] = "C:\\Documents and Settings\\Rita\\Desktop\\MeshReader\\trimeshinfo\\Debug\\prova0.ply"; + OpenMesh(argv[1],m); FILE * index; index = fopen((string(argv[1])+string("2.html")).c_str(),"w"); fprintf(index,"

Checkup: This is the check up result for %s

\n\n\n", argv[1]); @@ -89,122 +94,63 @@ void main(int argc,char ** argv){ fprintf(index, "

Object color(4b): %f %f %f

\n\n", Color[0], Color[1], Color[2]); - /*fprintf(index,"BOUNDING BOX\n\n"); - if (m.bbox.IsEmpty()) - fprintf(index,"There's no info about bounding box/n/n"); - else - { - Point3f Center=m.bbox.Center(); - fprintf(index,"Bounding box center: %f %f %f \n", Center.V(0),Center.V(1),Center.V(2)); - Point3f Dim=m.bbox.Dim(); - fprintf(index,"Bounding box dimensions: %f %f %f \n", abs(Dim.V(0)),abs(Dim.V(1)),abs(Dim.V(2))); - fprintf(index,"Bounding box volume: %f \n", abs(m.bbox.Volume())); - fprintf(index,"Bounding box diagonal: %f \n", m.bbox.Diag()); - fprintf(index,"Bounding box vertices are: %f %f %f \n", m.bbox.P(0).V(0), m.bbox.P(0).V(1), m.bbox.P(0).V(2)); - fprintf(index," %f %f %f \n", m.bbox.P(1).V(0), m.bbox.P(1).V(1), m.bbox.P(1).V(2)); - fprintf(index," %f %f %f \n", m.bbox.P(2).V(0), m.bbox.P(2).V(1), m.bbox.P(2).V(2)); - fprintf(index," %f %f %f \n", m.bbox.P(3).V(0), m.bbox.P(3).V(1), m.bbox.P(3).V(2)); - fprintf(index," %f %f %f \n", m.bbox.P(4).V(0), m.bbox.P(4).V(1), m.bbox.P(4).V(2)); - fprintf(index," %f %f %f \n", m.bbox.P(5).V(0), m.bbox.P(5).V(1), m.bbox.P(5).V(2)); - fprintf(index," %f %f %f \n", m.bbox.P(6).V(0), m.bbox.P(6).V(1), m.bbox.P(6).V(2)); - fprintf(index," %f %f %f \n", m.bbox.P(7).V(0), m.bbox.P(7).V(1), m.bbox.P(7).V(2)); - - } - - fprintf(index,"CAMERA INFO\n\n"); - if (m.camera.UberFlags()==NULL) - fprintf(index, "No Camera Info\n\n"); - else - { - fprintf(index,"Flags: %s\n", m.camera.UberFlags()); - if (m.camera.IsOrtho()) - fprintf(index,"Ortogonal Camera:Yes\n"); - else - fprintf(index,"Ortogonal Camera:No\n"); - fprintf(index,"Focal Distance: %f\n", m.camera.f); - fprintf(index,"End of frustum: %f\n", m.camera.farend); - fprintf(index,"Radial lens distortion coefficients: %f %f %f %f \n", m.camera.k[0],m.camera.k[1],m.camera.k[2],m.camera.k[3]); - fprintf(index,"Pixel/size ratio: %f\n\n", m.camera.viewportM); - } - - fprintf(index,"SHOT INFO\n\n"); - if (m.shot.IsValid()) - fprintf(index, "No Shot Info\n\n"); - - fprintf(index,"VERTEX INFO\n\n"); - if (m.HasPerVertexNormal()) - fprintf(index, "Per Vertex Normal: YES\n"); - else - fprintf(index, "Per Vertex Normal: NO\n"); - if (m.HasPerVertexColor()) - fprintf(index, "Per Vertex Color: YES\n"); - else - fprintf(index, "Per Vertex Color: NO\n"); - if (m.HasPerVertexMark()) - fprintf(index, "Per Vertex Mark: YES\n"); - else - fprintf(index, "Per Vertex Mark: NO\n"); - if (m.HasPerVertexQuality()) - fprintf(index, "Per Vertex Quality: YES\n"); - else - fprintf(index, "Per Vertex Quality: NO\n"); - if (m.HasPerVertexTexture()) - fprintf(index, "Per Vertex Texture: YES\n\n"); - else - fprintf(index, "Per Vertex Texture: NO\n\n"); - -fprintf(index,"FACE INFO\n\n"); - if (m.HasPerFaceNormal()) - fprintf(index, "Per Face Normal: YES\n"); - else - fprintf(index, "Per Face Normal: NO\n"); - if (m.HasPerFaceColor()) - fprintf(index, "Per Face Color: YES\n"); - else - fprintf(index, "Per Face Color: NO\n"); - if (m.HasPerFaceMark()) - fprintf(index, "Per Face Mark: YES\n"); - else - fprintf(index, "Per Face Mark: NO\n"); - if (m.HasPerFaceQuality()) - fprintf(index, "Per Face Quality: YES\n\n"); - else - fprintf(index, "Per Face Quality: NO\n\n"); - -fprintf(index,"WEDGE INFO\n\n"); - if (m.HasPerWedgeNormal()) - fprintf(index, "Per Wedge Normal: YES\n"); - else - fprintf(index, "Per Wedge Normal: NO\n"); - if (m.HasPerWedgeColor()) - fprintf(index, "Per Wedge Color: YES\n"); - else - fprintf(index, "Per Wedge Color: NO\n"); - /*if (m.HasPerWedgeMark()) - fprintf(index, "Per Wedge Mark: YES\n"); - else - fprintf(index, "Per Wedge Mark: NO\n"); - if (m.HasPerWedgeQuality()) - fprintf(index, "Per Wedge Quality: YES\n"); - else - fprintf(index, "Per Wedge Quality: NO\n"); - if (m.HasPerWedgeTexture()) - fprintf(index, "Per Wedge Texture: YES\n\n"); - else - fprintf(index, "Per Wedge Texture: NO\n\n"); - - fprintf(index,"TOPOLOGY INFO\n\n"); - if (m.HasFFTopology()) - fprintf(index, "FFTopology: YES\n"); - else - { - fprintf(index, "FFTopology: NO\n");*/ + vcg::tri::UpdateTopology::FaceFace(m); - /*} - if (m.HasVFTopology()) - fprintf(index, "VFTopology: YES\n\n"); + + // IS MANIFOLD + + MyMesh::FaceIterator f; + MyMesh::FaceIterator g; + vcg::face::Pos he; + vcg::face::Pos hei; + int j; + int man=0; + bool Manifold = true; + bool Manifold_lib = true; + for(f=m.face.begin();f!=m.face.end();++f) + { + for (j=0;j<3;++j) + { + if(!IsManifold(*f,j)) + { + Manifold_lib = false; + f= m.face.end(); + break; + } + } + } + if (!Manifold_lib) + fprintf(index, "

Manifold from lib gives: NO

"); else - fprintf(index, "VFTopology: NO\n\n");*/ + fprintf(index, "

Manifold from lib gives: YES

"); + + for(f=m.face.begin();f!=m.face.end();++f) + { + for (j=0;j<3;++j) + { + if ((*f).IsBorder(j)) + {} + else if (&(*f) == (*f).FFp(j)->FFp((*f).FFi(j))) + {} + else + { + hei.Set(&(*f), j , f->V(j)); + he=hei; + he.NextF(); + while (he.f!=hei.f) + { + man++; + he.NextF(); + } + Manifold=false; + } + } + } + if (!Manifold) + fprintf(index, "

Manifold from Matteo gives: NO

"); + else + fprintf(index, "

Manifold from Matteo gives: YES

"); + // COUNT EDGES @@ -235,9 +181,8 @@ fprintf(index,"WEDGE INFO\n\n"); // UNREFERENCED VERTEX int count_uv = 0; - MyMesh::FaceIterator f; MyMesh::VertexIterator v; - int j; + int deleted = 0; for(v=m.vert.begin();v!=m.vert.end();++v) @@ -256,49 +201,153 @@ fprintf(index,"WEDGE INFO\n\n"); for(f=m.face.begin();f!=m.face.end();++f) (*f).ClearS(); - MyMesh::FaceIterator g; g=m.face.begin(); f=g; - int flag=0; + int BEdges=0; int numholes=0; - vcg::face::Pos hei; - vcg::face::Pos he; - - while (f!=m.face.end()) + + for(f=g;f!=m.face.end();++f) { - flag=0; - for(f=g;f!=m.face.end();++f) + if(!(*f).IsS()) { for(j=0;j<3;j++) { - if ((*f).IsBorder(j) && !(*f).IsS()) + if ((*f).IsBorder(j)) { - (*f).SetS(); - flag=1; - g=f; - break; + BEdges++; + if(!(IsManifold(*f,j))) + { + (*f).SetS(); + hei.Set(&(*f),j,f->V(j)); + he=hei; + do + { + he.NextB(); + he.f->SetS(); + // BEdges++; + } + while (he.f!=hei.f); + numholes++; + } + } + } + } + } + fprintf(index, "

Number of holes: %d

\n

Number of border edges: %d

", numholes, BEdges); + + // CONNECTED COMPONENTS + + + for(f=m.face.begin();f!=m.face.end();++f) + (*f).ClearS(); + g=m.face.begin(); f=g; + int CountComp=0; int CountOrient=0; + stack sf; + MyMesh::FaceType *l; + for(f=m.face.begin();f!=m.face.end();++f) + { + if (!(*f).IsS()) + { + (*f).SetS(); + sf.push(f); + while (!sf.empty()) + { + g=sf.top(); + he.Set(&(*g),0,g->V(0)); + sf.pop(); + for(j=0;j<3;++j) + if( !(*g).IsBorder(j) ) + { + l=he.f->FFp(j); + if( !(*l).IsS() ) + { + (*l).SetS(); + sf.push(l); + } + } + } + CountComp++; + } + } + fprintf(index, "

Number of connected components: %d

", CountComp); + +// ORIENTABLE E ORIENTED MESH + + int flag=0; + bool Oriented=true; + if (!Manifold) + fprintf(index, "

Orientable Mesh: NO

"); + else + { + for(f=m.face.begin();f!=m.face.end();++f) + { + (*f).ClearS(); + // (*f).ClearR(); + } + g=m.face.begin(); f=g; + for(f=m.face.begin();f!=m.face.end();++f) + { + if (!(*f).IsS()) + { + (*f).SetS(); + sf.push(f); + + while (!sf.empty()) + { + g=sf.top(); + sf.pop(); + for(j=0;j<3;++j) + { + int prova = (*g).IsR(); + if( !(*g).IsBorder(j) ) + { + he.Set(&(*g),0,g->V(0)); + l=he.f->FFp(j); + if( !(*l).IsS() ) + { + (*l).SetS(); + sf.push(l); + } + he.Set(&(*g),j,g->V(j)); + hei.Set(he.f->FFp(j),he.f->FFi(j), (he.f->FFp(j))->V(he.f->FFi(j))); + if (he.v!=hei.v) // bene + { + if ((*l).IsS()) + {} + else + { + (*l).SetS(); + sf.push(l); + } + } + } + else if ((*l).IsS() && !(*l).IsR()) + { + flag=1; + break; + } + else + { + Oriented=false; + (*l).SetS(); + (*l).SetR(); + sf.push(l); + } + } } } if (flag==1) break; } - numholes++; - BEdges++; - if (j>2) break; - hei.Set(&(*g),j,g->V(j)); - he=hei; - // hei=he; - // do - // hei.Nextb() - // while(hei!=he); - do - { - he.NextB(); - he.f->SetS(); - BEdges++; - } - while (he.f!=hei.f); + if (flag==0) + fprintf(index, "

Orientable Mesh: YES

"); + else + fprintf(index, "

Orientable Mesh: NO

"); } - fprintf(index, "

Number of holes: %d

\n

Number of border edges: %d

", numholes, BEdges); + if (Oriented && Manifold) + fprintf(index, "

Oriented Mesh: YES

"); + else + fprintf(index, "

Oriented Mesh: NO

"); + fclose(index); }