Minor changes

This commit is contained in:
Massimiliano Corsini 2005-12-12 11:29:21 +00:00
parent 0aa18be24e
commit ef49736885
1 changed files with 68 additions and 38 deletions

View File

@ -24,6 +24,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.14 2005/12/12 10:48:16 corsini
Fix indentation
Revision 1.13 2005/11/17 00:42:03 cignoni
Changed include order
removed clean::initialize
@ -165,17 +168,17 @@ struct MeshInfo
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.numcomponents = mi.Genus = mi.dv = 0;
mi.Volume = 0;
memset(&mi, 0, sizeof(mi));
}
void PrintAsciiInfo(MeshInfo &mi)
void PrintMeshInfo(MeshInfo &mi)
{
printf("\t Mesh info:\n");
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);
if (!mi.Manifold) printf("\t Manifold: NO\n");
if (!mi.Manifold)
printf("\t Manifold: NO\n");
else
printf("\t Manifold: YES\n");
@ -185,7 +188,8 @@ void PrintAsciiInfo(MeshInfo &mi)
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 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");
@ -217,7 +221,7 @@ void PrintAsciiInfo(MeshInfo &mi)
printf("\t Self Intersection: %s\n",mi.SelfIntersect?"Yes":"No");
}
void PrintXMLInfo(MeshInfo &mi)
void SaveXMLInfo(MeshInfo &mi)
{
XMLTree doc;
doc.initializeMain();
@ -248,7 +252,8 @@ void PrintXMLInfo(MeshInfo &mi)
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");
@ -268,19 +273,26 @@ void PrintXMLInfo(MeshInfo &mi)
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.finalizeMain();
doc.printXMLTree();
}
void SaveHtmlInfo(MeshInfo &mi)
{
//...TODO...
}
int main(int argc, char ** argv)
{
CMesh m;
bool SaveFlag=false;
bool AsciiFlag=true;
bool saveFlag = false;
bool verboseFlag = true;
bool XmlFlag= false;
bool HtmlFlag = false;
string SaveName;
@ -307,38 +319,43 @@ int main(int argc,char ** argv)
{
switch(argv[i][1])
{
case 'o' :
SaveFlag=true; SaveName=argv[i][2];
case 's' :
saveFlag = true;
SaveName = argv[i][2];
break;
case 'x' :
if(argv[i][2]=='y')
{
XmlFlag = true;
printf("Enable XML Printing\n");
printf("Enable XML output\n");
}
else
{
XmlFlag = false;
printf("Disable XML Printing\n");
printf("Disable XML output\n");
}
break;
case 'a' :
case 'v' :
if(argv[i][2]=='y')
{
AsciiFlag = true;
verboseFlag = true;
printf("Enable Ascii Printing\n");
}
else
{
AsciiFlag = false;
verboseFlag = false;
printf("Disable Ascii Printing\n");
}
break;
default:
printf(MSG_ERR_INVALID_OPTION, argv[i]);
exit(0);
break;
}
}
i++;
}
OpenMesh(mi.FileName.c_str(),m);
@ -346,7 +363,7 @@ int main(int argc,char ** argv)
mi.fn=m.fn;
// DEGENERATED FACES
mi.count_fd = tri::Clean<CMesh>::DegeneratedFaces(m);
//mi.count_fd = tri::Clean<CMesh>::DegeneratedFaces(m);
vcg::tri::UpdateTopology<CMesh>::FaceFace(m);
@ -375,23 +392,36 @@ int main(int argc,char ** argv)
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);
mi.Genus = tri::Clean<CMesh>::MeshGenus(m,mi.count_uv, mi.numholes,
mi.numcomponents, mi.count_e);
// REGULARITY
tri::Clean<CMesh>::IsRegularMesh(m, mi.Regular, mi.Semiregular);
// ORIENTABLE E ORIENTED MESH
if (mi.Manifold) tri::Clean<CMesh>::IsOrientedMesh(m, mi.Oriented, mi.Orientable);
if (mi.Manifold)
tri::Clean<CMesh>::IsOrientedMesh(m, mi.Oriented, mi.Orientable);
mi.dv = tri::Clean<CMesh>::RemoveDuplicateVertex(m);
// SELF INTERSECTION
mi.SelfIntersect = tri::Clean<CMesh>::SelfIntersections(m);
if(SaveFlag) tri::io::Exporter<CMesh>::Save(m,SaveName.c_str());
if (saveFlag)
tri::io::Exporter<CMesh>::Save(m, SaveName.c_str());
// Print mesh information
if(verboseFlag)
PrintMeshInfo(mi);
// Save mesh information in XML format
if(XmlFlag)
SaveXMLInfo(mi);
// Save mesh information in HTML format
if (HtmlFlag)
SaveHtmlInfo(mi);
if(AsciiFlag) PrintAsciiInfo(mi);
if(XmlFlag) PrintXMLInfo(mi);
return 0;
}