Fix indentation

This commit is contained in:
Massimiliano Corsini 2005-12-12 10:48:16 +00:00
parent 77b69c8490
commit 0fc829e2b8
1 changed files with 196 additions and 140 deletions

View File

@ -24,6 +24,10 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.13 2005/11/17 00:42:03 cignoni
Changed include order
removed clean::initialize
Revision 1.12 2005/11/16 16:45:51 rita_borgo Revision 1.12 2005/11/16 16:45:51 rita_borgo
Minor changes Minor changes
@ -85,11 +89,11 @@ Added Standard comments
#include <vector> #include <vector>
#include <string> #include <string>
#include <stack> #include <stack>
using namespace std; using namespace std;
#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>
#include <vcg/complex/trimesh/update/bounding.h> #include <vcg/complex/trimesh/update/bounding.h>
#include <vcg/complex/trimesh/update/flag.h> #include <vcg/complex/trimesh/update/flag.h>
@ -100,12 +104,12 @@ using namespace std;
#include <wrap/io_trimesh/import.h> #include <wrap/io_trimesh/import.h>
#include <wrap/io_trimesh/export.h> #include <wrap/io_trimesh/export.h>
#include<vcg/simplex/vertexplus/base.h> #include <vcg/simplex/vertexplus/base.h>
#include<vcg/simplex/vertexplus/component.h> #include <vcg/simplex/vertexplus/component.h>
#include<vcg/simplex/faceplus/base.h> #include <vcg/simplex/faceplus/base.h>
#include<vcg/simplex/faceplus/component.h> #include <vcg/simplex/faceplus/component.h>
#include<vcg/simplex/face/pos.h> #include <vcg/simplex/face/pos.h>
#include "XMLTree.h" #include "XMLTree.h"
@ -130,8 +134,10 @@ typedef vector<Point3x> Hole;
void OpenMesh(const char *filename, CMesh &m) void OpenMesh(const char *filename, CMesh &m)
{ {
int err = tri::io::Importer<CMesh>::Open(m,filename); int err = tri::io::Importer<CMesh>::Open(m,filename);
if(err){ if(err)
printf("Error in reading %s: '%s'\n",filename,tri::io::Importer<CMesh>::ErrorMsg(err)); {
printf("Error in reading %s: '%s'\n",filename,
tri::io::Importer<CMesh>::ErrorMsg(err));
exit(-1); exit(-1);
} }
printf("\t read mesh `%s'\n", filename); printf("\t read mesh `%s'\n", filename);
@ -159,9 +165,9 @@ struct MeshInfo
void initMeshInfo(MeshInfo &mi) void initMeshInfo(MeshInfo &mi)
{ {
mi.vn = mi.fn = mi.count_e = mi.boundary_e = mi.count_fd = mi.count_uv = mi.numholes = mi.BEdges = mi.vn = mi.fn = mi.count_e = mi.boundary_e = mi.count_fd = mi.count_uv =
mi.numcomponents = mi.Genus = mi.dv = 0; mi.numholes = mi.BEdges = mi.numcomponents = mi.Genus = mi.dv = 0;
mi.Volume = 0.; mi.Volume = 0;
} }
void PrintAsciiInfo(MeshInfo &mi) void PrintAsciiInfo(MeshInfo &mi)
{ {
@ -169,35 +175,46 @@ void PrintAsciiInfo(MeshInfo &mi)
printf(" \t M: '%s'\n\t Number of vertices: %d \n", mi.FileName.c_str(), mi.vn); printf(" \t M: '%s'\n\t Number of vertices: %d \n", mi.FileName.c_str(), mi.vn);
printf("\t Number of faces: %d \n", mi.fn); printf("\t Number of faces: %d \n", mi.fn);
if (!mi.Manifold) printf( "\t Manifold: NO\n"); if (!mi.Manifold) printf("\t Manifold: NO\n");
else printf( "\t Manifold: YES\n"); else
printf("\t Manifold: YES\n");
printf("\t Number of edges: %d \n", mi.count_e); printf("\t Number of edges: %d \n", mi.count_e);
printf("\t Number of internal edges: %d \n", mi.count_e-mi.boundary_e); printf("\t Number of internal edges: %d \n", mi.count_e-mi.boundary_e);
printf("\t Number of boundary edges: %i \n", mi.boundary_e); printf("\t Number of boundary edges: %i \n", mi.boundary_e);
printf("\t Number of degenerated faces: %d\n", mi.count_fd); printf("\t Number of degenerated faces: %d\n", mi.count_fd);
printf("\t Number of unreferenced vertices: %d\n",mi.count_uv); printf("\t Number of unreferenced vertices: %d\n",mi.count_uv);
printf("\t Number of holes/boundaries: %d \n", mi.numholes); printf("\t Number of holes/boundaries: %d \n", mi.numholes);
if( mi.Volume) printf("\t Volume: %f \n", mi.Volume); if(mi.Volume) printf("\t Volume: %f \n", mi.Volume);
else printf("\t Volume: UNDEFINED, mesh is either non-manifold or has holes \n"); else
printf("\t Volume: UNDEFINED, mesh is either non-manifold or has holes \n");
printf("\t Number of connected components: %d\n", mi.numcomponents); printf("\t Number of connected components: %d\n", mi.numcomponents);
if (mi.Manifold) printf( "\t Genus: %d \n", mi.Genus); if (mi.Manifold)
else printf( "\t Genus (n/a)\n"); printf("\t Genus: %d \n", mi.Genus);
else
printf("\t Genus (n/a)\n");
if (mi.Regular) printf("\t Type of Mesh: REGULAR\n"); if (mi.Regular)
else if (mi.Semiregular) printf("\t Type of Mesh: SEMIREGULAR\n"); printf("\t Type of Mesh: REGULAR\n");
else printf("\t Type of Mesh: IRREGULAR\n"); else if (mi.Semiregular)
printf("\t Type of Mesh: SEMIREGULAR\n");
else
printf("\t Type of Mesh: IRREGULAR\n");
if (!mi.Manifold) { if (!mi.Manifold)
printf( "\t Orientable Mesh: NO\n"); {
printf( "\t Oriented Mesh: NO\n"); printf("\t Orientable Mesh: NO\n");
} else { printf("\t Oriented Mesh: NO\n");
printf( "\t Orientable Mesh: %s\n",mi.Orientable?"Yes":"No"); }
printf( "\t Oriented Mesh: %s\n",mi.Oriented?"Yes":"No"); else
{
printf("\t Orientable Mesh: %s\n",mi.Orientable?"Yes":"No");
printf("\t Oriented Mesh: %s\n",mi.Oriented?"Yes":"No");
} }
printf( "\t Number of duplicated vertices found: %d\n",mi.dv); printf("\t Number of duplicated vertices found: %d\n",mi.dv);
printf( "\t Self Intersection: %s\n",mi.SelfIntersect?"Yes":"No"); printf("\t Self Intersection: %s\n",mi.SelfIntersect?"Yes":"No");
} }
void PrintXMLInfo(MeshInfo &mi) void PrintXMLInfo(MeshInfo &mi)
@ -206,38 +223,56 @@ void PrintXMLInfo(MeshInfo &mi)
doc.initializeMain(); doc.initializeMain();
char s[256]; char s[256];
sprintf(s,"%d",mi.vn); doc.addNode(s, VALUE_INTEGER, "Number of Vertices"); sprintf(s,"%d",mi.vn);
sprintf(s,"%d",mi.fn); doc.addNode(s, VALUE_INTEGER, "Number of Faces"); doc.addNode(s, VALUE_INTEGER, "Number of Vertices");
sprintf(s,"%d",mi.fn);
doc.addNode(s, VALUE_INTEGER, "Number of Faces");
if(mi.Manifold) doc.addNode("No", VALUE_BOOL,"Manifold"); if(mi.Manifold)
else doc.addNode("Yes", VALUE_BOOL,"Manifold"); doc.addNode("No", VALUE_BOOL,"Manifold");
else
doc.addNode("Yes", VALUE_BOOL,"Manifold");
sprintf(s,"%d",mi.count_e); doc.addNode(s, VALUE_INTEGER,"Number of Edges"); sprintf(s,"%d",mi.count_e);
sprintf(s,"%d",mi.count_fd); doc.addNode(s, VALUE_INTEGER,"Number of Degenerated Faces"); doc.addNode(s, VALUE_INTEGER,"Number of Edges");
sprintf(s,"%d",mi.count_uv); doc.addNode(s, VALUE_INTEGER,"Number of unreferenced vertices"); sprintf(s,"%d",mi.count_fd);
sprintf(s,"%d",mi.numholes); doc.addNode(s, VALUE_INTEGER,"Number of Holes"); doc.addNode(s, VALUE_INTEGER,"Number of Degenerated Faces");
sprintf(s,"%d",mi.BEdges); doc.addNode(s, VALUE_INTEGER,"Number of Border Edges");
sprintf(s,"%f",mi.Volume); doc.addNode(s, VALUE_FLOAT,"Volume"); sprintf(s,"%d",mi.count_uv);
sprintf(s,"%d",mi.numcomponents); doc.addNode(s, VALUE_INTEGER,"Number of Connected Components"); doc.addNode(s, VALUE_INTEGER,"Number of unreferenced vertices");
sprintf(s,"%d",mi.numholes);
doc.addNode(s, VALUE_INTEGER,"Number of Holes");
sprintf(s,"%d",mi.BEdges);
doc.addNode(s, VALUE_INTEGER,"Number of Border Edges");
sprintf(s,"%f",mi.Volume);
doc.addNode(s, VALUE_FLOAT,"Volume");
sprintf(s,"%d",mi.numcomponents);
doc.addNode(s, VALUE_INTEGER,"Number of Connected Components");
sprintf(s,"%d",mi.Genus); doc.addNode(s, VALUE_INTEGER,"Genus"); sprintf(s,"%d",mi.Genus); doc.addNode(s, VALUE_INTEGER,"Genus");
if (mi.Regular) doc.addNode("REGULAR", VALUE_STRING,"Type of Mesh"); if (mi.Regular)
else if (mi.Semiregular) doc.addNode("SEMIREGULAR", VALUE_STRING,"Type of Mesh"); doc.addNode("REGULAR", VALUE_STRING,"Type of Mesh");
else doc.addNode("IRREGULAR", VALUE_STRING,"Type of Mesh"); else if (mi.Semiregular)
doc.addNode("SEMIREGULAR", VALUE_STRING,"Type of Mesh");
else
doc.addNode("IRREGULAR", VALUE_STRING,"Type of Mesh");
if (!mi.Manifold) { if (!mi.Manifold)
{
doc.addNode("NO", VALUE_STRING,"Orientable Mesh"); doc.addNode("NO", VALUE_STRING,"Orientable Mesh");
doc.addNode("NO", VALUE_STRING,"Oriented Mesh"); doc.addNode("NO", VALUE_STRING,"Oriented Mesh");
} else { }
else
{
doc.addNode(mi.Orientable?"Yes":"No", VALUE_STRING,"Orientable Mesh"); doc.addNode(mi.Orientable?"Yes":"No", VALUE_STRING,"Orientable Mesh");
doc.addNode( mi.Oriented?"Yes":"No", VALUE_STRING,"Oriented Mesh"); doc.addNode( mi.Oriented?"Yes":"No", VALUE_STRING,"Oriented Mesh");
} }
sprintf(s,"%d",mi.dv); doc.addNode(s, VALUE_INTEGER,"Duplicated Vertices"); sprintf(s,"%d",mi.dv); doc.addNode(s, VALUE_INTEGER,"Duplicated Vertices");
doc.addNode( mi.SelfIntersect?"Yes":"No", VALUE_STRING,"Self Intersection"); doc.addNode( mi.SelfIntersect?"Yes":"No", VALUE_STRING,"Self Intersection");
doc.finalizeMain(); doc.finalizeMain();
doc.printXMLTree(); doc.printXMLTree();
} }
int main(int argc,char ** argv) int main(int argc,char ** argv)
@ -259,38 +294,60 @@ int main(int argc,char ** argv)
// load input meshes. // load input meshes.
if(argc <= 1) { if (argc <= 1)
{
printf(MSG_ERR_N_ARGS); printf(MSG_ERR_N_ARGS);
exit(-1); exit(-1);
} }
mi.FileName=argv[1]; mi.FileName=argv[1];
for(int i=3; i < argc;) for(int i=3; i < argc; i++)
{ {
if(argv[i][0]=='-') if(argv[i][0]=='-')
{
switch(argv[i][1]) switch(argv[i][1])
{ {
case 'o' : SaveFlag=true; SaveName=argv[i][2]; break; case 'o' :
case 'x' : if(argv[i][2]=='y') { XmlFlag = true; printf("Enable XML Printing\n"); } SaveFlag=true; SaveName=argv[i][2];
else { XmlFlag = false; printf("Disable XML Printing\n"); } break; break;
case 'a' : if(argv[i][2]=='y') { AsciiFlag = true; printf("Enable Ascii Printing\n"); } case 'x' :
else { AsciiFlag = false; printf("Disable Ascii Printing\n"); } break; if(argv[i][2]=='y')
default : printf(MSG_ERR_INVALID_OPTION, argv[i]); {
XmlFlag = true;
printf("Enable XML Printing\n");
}
else
{
XmlFlag = false;
printf("Disable XML Printing\n");
}
break;
case 'a' :
if(argv[i][2]=='y')
{
AsciiFlag = true;
printf("Enable Ascii Printing\n");
}
else
{
AsciiFlag = false;
printf("Disable Ascii Printing\n");
}
break;
default:
printf(MSG_ERR_INVALID_OPTION, argv[i]);
exit(0); exit(0);
} }
i++; i++;
} }
OpenMesh(mi.FileName.c_str(),m); OpenMesh(mi.FileName.c_str(),m);
mi.vn=m.vn; mi.fn=m.fn; mi.vn=m.vn;
mi.fn=m.fn;
// DEGENERATED FACES // DEGENERATED FACES
mi.count_fd = tri::Clean<CMesh>::DegeneratedFaces(m); mi.count_fd = tri::Clean<CMesh>::DegeneratedFaces(m);
vcg::tri::UpdateTopology<CMesh>::FaceFace(m); vcg::tri::UpdateTopology<CMesh>::FaceFace(m);
// UNREFERENCED VERTEX // UNREFERENCED VERTEX
@ -304,8 +361,6 @@ int main(int argc,char ** argv)
// COUNT EDGES // COUNT EDGES
tri::Clean<CMesh>::CountEdges(m, mi.count_e, mi.boundary_e); tri::Clean<CMesh>::CountEdges(m, mi.count_e, mi.boundary_e);
// HOLES COUNT // HOLES COUNT
if(mi.Manifold) if(mi.Manifold)
{ {
@ -319,7 +374,8 @@ int main(int argc,char ** argv)
// CONNECTED COMPONENTS // CONNECTED COMPONENTS
mi.numcomponents = tri::Clean<CMesh>::ConnectedComponents(m); mi.numcomponents = tri::Clean<CMesh>::ConnectedComponents(m);
if(mi.Manifold) mi.Genus=tri::Clean<CMesh>::MeshGenus(m,mi.count_uv, mi.numholes, mi.numcomponents, mi.count_e); if(mi.Manifold)
mi.Genus = tri::Clean<CMesh>::MeshGenus(m,mi.count_uv, mi.numholes, mi.numcomponents, mi.count_e);
// REGULARITY // REGULARITY
tri::Clean<CMesh>::IsRegularMesh(m, mi.Regular, mi.Semiregular); tri::Clean<CMesh>::IsRegularMesh(m, mi.Regular, mi.Semiregular);