Added Oriented/Orientable but still some errors on those routines

This commit is contained in:
Paolo Cignoni 2005-01-07 16:38:09 +00:00
parent c3627e348e
commit 2987126008
1 changed files with 199 additions and 150 deletions

View File

@ -24,15 +24,20 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.2 2005/01/03 16:13:09 rita_borgo
Added Standard comments
****************************************************************************/ ****************************************************************************/
#include <vector> #include <vector>
#include <string> // anche questo #include <string>
#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/pos.h> // mi sembra di averlo aggiunto! #include<vcg/simplex/face/pos.h> // mi sembra di averlo aggiunto!
@ -49,7 +54,7 @@ using namespace std;
#include<wrap/io_trimesh/import_ply.h> #include<wrap/io_trimesh/import_ply.h>
using namespace vcg; using namespace vcg;
using namespace face;
class MyFace; class MyFace;
class MyEdge; class MyEdge;
@ -74,8 +79,8 @@ void main(int argc,char ** argv){
MyMesh m; MyMesh m;
//load the mesh //load the mesh
//argv[1]=(char*)"c:\\checkup\\debug\\column1m.ply"; //argv[1]=(char*)"c:\\checkup\\debug\\column1m.ply";
//argv[1] = "C:\\Documents and Settings\\Rita\\Desktop\\MeshReader\\prova2.ply"; argv[1] = "C:\\Documents and Settings\\Rita\\Desktop\\MeshReader\\trimeshinfo\\Debug\\prova0.ply";
vcg::tri::io::ImporterPLY<MyMesh>::Open(m,argv[1]); OpenMesh(argv[1],m);
FILE * index; FILE * index;
index = fopen((string(argv[1])+string("2.html")).c_str(),"w"); index = fopen((string(argv[1])+string("2.html")).c_str(),"w");
fprintf(index,"<p>Checkup: This is the check up result for %s </p>\n\n\n", argv[1]); fprintf(index,"<p>Checkup: This is the check up result for %s </p>\n\n\n", argv[1]);
@ -89,122 +94,63 @@ void main(int argc,char ** argv){
fprintf(index, "<p>Object color(4b): %f %f %f </p>\n\n", Color[0], Color[1], Color[2]); fprintf(index, "<p>Object color(4b): %f %f %f </p>\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<MyMesh>::FaceFace(m); vcg::tri::UpdateTopology<MyMesh>::FaceFace(m);
/*}
if (m.HasVFTopology()) // IS MANIFOLD
fprintf(index, "VFTopology: YES\n\n");
MyMesh::FaceIterator f;
MyMesh::FaceIterator g;
vcg::face::Pos<MyMesh::FaceType> he;
vcg::face::Pos<MyMesh::FaceType> 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, "<p> Manifold from lib gives: NO </p>");
else else
fprintf(index, "VFTopology: NO\n\n");*/ fprintf(index, "<p> Manifold from lib gives: YES </p>");
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, "<p> Manifold from Matteo gives: NO </p>");
else
fprintf(index, "<p> Manifold from Matteo gives: YES </p>");
// COUNT EDGES // COUNT EDGES
@ -235,9 +181,8 @@ fprintf(index,"WEDGE INFO\n\n");
// UNREFERENCED VERTEX // UNREFERENCED VERTEX
int count_uv = 0; int count_uv = 0;
MyMesh::FaceIterator f;
MyMesh::VertexIterator v; MyMesh::VertexIterator v;
int j;
int deleted = 0; int deleted = 0;
for(v=m.vert.begin();v!=m.vert.end();++v) 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) for(f=m.face.begin();f!=m.face.end();++f)
(*f).ClearS(); (*f).ClearS();
MyMesh::FaceIterator g;
g=m.face.begin(); f=g; g=m.face.begin(); f=g;
int flag=0;
int BEdges=0; int numholes=0; int BEdges=0; int numholes=0;
vcg::face::Pos<MyMesh::FaceType> hei;
vcg::face::Pos<MyMesh::FaceType> he; for(f=g;f!=m.face.end();++f)
while (f!=m.face.end())
{ {
flag=0; if(!(*f).IsS())
for(f=g;f!=m.face.end();++f)
{ {
for(j=0;j<3;j++) for(j=0;j<3;j++)
{ {
if ((*f).IsBorder(j) && !(*f).IsS()) if ((*f).IsBorder(j))
{ {
(*f).SetS(); BEdges++;
flag=1; if(!(IsManifold(*f,j)))
g=f; {
break; (*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, "<p> Number of holes: %d </p> \n <p> Number of border edges: %d </p>", 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<MyMesh::FaceIterator> 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, "<p> Number of connected components: %d </p>", CountComp);
// ORIENTABLE E ORIENTED MESH
int flag=0;
bool Oriented=true;
if (!Manifold)
fprintf(index, "<p> Orientable Mesh: NO</p>");
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) if (flag==1)
break; break;
} }
numholes++; if (flag==0)
BEdges++; fprintf(index, "<p> Orientable Mesh: YES</p>");
if (j>2) break; else
hei.Set(&(*g),j,g->V(j)); fprintf(index, "<p> Orientable Mesh: NO</p>");
he=hei;
// hei=he;
// do
// hei.Nextb()
// while(hei!=he);
do
{
he.NextB();
he.f->SetS();
BEdges++;
}
while (he.f!=hei.f);
} }
fprintf(index, "<p> Number of holes: %d </p> \n <p> Number of border edges: %d </p>", numholes, BEdges); if (Oriented && Manifold)
fprintf(index, "<p> Oriented Mesh: YES</p>");
else
fprintf(index, "<p> Oriented Mesh: NO</p>");
fclose(index);
} }