Changed the include order and the order in which cleaning filters are applied.

This commit is contained in:
Paolo Cignoni 2007-03-08 22:49:35 +00:00
parent 16ca848580
commit f79adff0da
1 changed files with 39 additions and 31 deletions

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.40 2006/05/16 21:55:28 cignoni
Updated to the new remove zero area syntax
Revision 1.39 2006/03/29 09:27:07 cignoni Revision 1.39 2006/03/29 09:27:07 cignoni
Added managemnt of non critical errors Added managemnt of non critical errors
@ -176,6 +179,12 @@ Added Standard comments
using namespace std; using namespace std;
// VCG headers // VCG headers
#include <vcg/simplex/vertexplus/base.h>
#include <vcg/simplex/vertexplus/component.h>
#include <vcg/simplex/faceplus/base.h>
#include <vcg/simplex/faceplus/component.h>
#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>
@ -188,11 +197,6 @@ 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/component.h>
#include <vcg/simplex/faceplus/base.h>
#include <vcg/simplex/faceplus/component.h>
#include <vcg/simplex/face/pos.h> #include <vcg/simplex/face/pos.h>
#include <vcg/complex/trimesh/inertia.h> #include <vcg/complex/trimesh/inertia.h>
@ -231,7 +235,8 @@ struct MeshInfo
bool hasFColor; bool hasFColor;
bool hasTexture; bool hasTexture;
int vn,fn; int vn,fn;
bool Manifold; bool VManifold;
bool FManifold;
int count_e,boundary_e,count_fd,count_uv,numholes; int count_e,boundary_e,count_fd,count_uv,numholes;
int BEdges; int BEdges;
float Volume; float Volume;
@ -319,7 +324,8 @@ void initMeshInfo(MeshInfo &mi)
mi.hasFNormal = false; mi.hasFNormal = false;
mi.hasVNormal = false; mi.hasVNormal = false;
mi.hasTexture = false; mi.hasTexture = false;
mi.Manifold = false; mi.VManifold = false;
mi.FManifold = false;
mi.count_e = 0; mi.count_e = 0;
mi.boundary_e = 0; mi.boundary_e = 0;
mi.count_fd = 0; mi.count_fd = 0;
@ -378,7 +384,7 @@ void PrintMeshInfo(MeshInfo &mi)
else else
printf(" Has Texture information: NO\n"); printf(" Has Texture information: NO\n");
if ((mi.Manifold)&&(mi.Oriented)&&(!mi.numholes)) if ((mi.VManifold && mi.FManifold )&&(mi.Oriented)&&(!mi.numholes))
printf(" Volume: %f \n", mi.Volume); printf(" Volume: %f \n", mi.Volume);
else else
printf(" Volume: UNDEFINED (a closed oriented manifold is required)\n"); printf(" Volume: UNDEFINED (a closed oriented manifold is required)\n");
@ -386,7 +392,7 @@ void PrintMeshInfo(MeshInfo &mi)
printf(" Number of connected components: %d\n", mi.numcomponents); printf(" Number of connected components: %d\n", mi.numcomponents);
// Orientation // Orientation
if (!mi.Manifold) if (!mi.VManifold && mi.FManifold)
{ {
printf(" Orientable Mesh: NO\n"); printf(" Orientable Mesh: NO\n");
printf(" Oriented Mesh: NO\n"); printf(" Oriented Mesh: NO\n");
@ -405,13 +411,13 @@ void PrintMeshInfo(MeshInfo &mi)
} }
// Manifold // Manifold
if (!mi.Manifold) if (mi.VManifold && mi.FManifold )
printf(" Manifold: NO\n");
else
printf(" Manifold: YES\n"); printf(" Manifold: YES\n");
else
printf(" Manifold: NO\n");
// Genus // Genus
if (mi.Manifold) if (mi.VManifold && mi.FManifold)
printf(" Genus: %d \n", mi.Genus); printf(" Genus: %d \n", mi.Genus);
else else
printf(" Genus: N/A \n"); printf(" Genus: N/A \n");
@ -442,7 +448,7 @@ void SaveXMLInfo(MeshInfo &mi)
sprintf(s,"%d",mi.fn); sprintf(s,"%d",mi.fn);
doc.addNode(s, VALUE_INTEGER, "Number of Faces"); doc.addNode(s, VALUE_INTEGER, "Number of Faces");
if(mi.Manifold) if(mi.VManifold && mi.FManifold)
doc.addNode("false", VALUE_BOOL,"Manifold"); doc.addNode("false", VALUE_BOOL,"Manifold");
else else
doc.addNode("true", VALUE_BOOL,"Manifold"); doc.addNode("true", VALUE_BOOL,"Manifold");
@ -498,7 +504,7 @@ void SaveXMLInfo(MeshInfo &mi)
else else
doc.addNode("IRREGULAR", VALUE_STRING,"Type of Mesh"); doc.addNode("IRREGULAR", VALUE_STRING,"Type of Mesh");
if (!mi.Manifold) if (!mi.VManifold && mi.FManifold)
{ {
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");
@ -535,7 +541,7 @@ void SaveMeshInfoHtmlTable(fstream &fout, MeshInfo &mi)
fout << " <td>" << mi.fn << "</td>" << std::endl; fout << " <td>" << mi.fn << "</td>" << std::endl;
fout << " <td>" << mi.count_e << "</td>" << std::endl; fout << " <td>" << mi.count_e << "</td>" << std::endl;
if (mi.Manifold) if (mi.VManifold && mi.FManifold)
fout << " <td>" << mi.numholes << "</td>" << std::endl; fout << " <td>" << mi.numholes << "</td>" << std::endl;
else else
fout << " <td>N/A</td>" << std::endl; fout << " <td>N/A</td>" << std::endl;
@ -551,7 +557,7 @@ void SaveMeshInfoHtmlTable(fstream &fout, MeshInfo &mi)
else else
fout << " <td>None</td>" << std::endl; fout << " <td>None</td>" << std::endl;
if (mi.Manifold) if(mi.VManifold && mi.FManifold)
fout << " <td>Yes</td>" << std::endl; fout << " <td>Yes</td>" << std::endl;
else else
fout << " <td>No</td>" << std::endl; fout << " <td>No</td>" << std::endl;
@ -563,7 +569,7 @@ void SaveMeshInfoHtmlTable(fstream &fout, MeshInfo &mi)
else if (!mi.Orientable) else if (!mi.Orientable)
fout << " <td>No / No</td>" << std::endl; fout << " <td>No / No</td>" << std::endl;
if (mi.Manifold) if (mi.VManifold && mi.FManifold)
fout << " <td>" << mi.Genus << "</td>" << std::endl; fout << " <td>" << mi.Genus << "</td>" << std::endl;
else else
fout << " <td>N/A</td>" << std::endl; fout << " <td>N/A</td>" << std::endl;
@ -758,27 +764,29 @@ int main(int argc, char ** argv)
// Number of faces // Number of faces
mi.fn = m.fn; mi.fn = m.fn;
// DUPLICATED VERTICES
mi.dv = tri::Clean<CMesh>::RemoveDuplicateVertex(m);
// DEGENERATED FACES => (faces with area zero) // DEGENERATED FACES => (faces with area zero)
mi.count_fd = tri::Clean<CMesh>::RemoveFaceOutOfRangeArea<false>(m,0); mi.count_fd = tri::Clean<CMesh>::RemoveDegenerateFace(m);
mi.count_fd += tri::Clean<CMesh>::RemoveFaceOutOfRangeArea<false>(m,0);
// UNREFERENCED VERTEX // UNREFERENCED VERTEX
mi.count_uv = tri::Clean<CMesh>::RemoveUnreferencedVertex(m); mi.count_uv = tri::Clean<CMesh>::RemoveUnreferencedVertex(m);
// DUPLICATED VERTICES
mi.dv = tri::Clean<CMesh>::RemoveDuplicateVertex(m);
// Update topology (face-to-face) // Update topology (face-to-face)
tri::UpdateTopology<CMesh>::FaceFace(m); tri::UpdateTopology<CMesh>::FaceFace(m);
tri::UpdateTopology<CMesh>::VertexFace(m); tri::UpdateTopology<CMesh>::VertexFace(m);
// IS MANIFOLD? // IS MANIFOLD?
mi.Manifold = tri::Clean<CMesh>::IsTwoManifoldFace(m) && tri::Clean<CMesh>::IsTwoManifoldVertex(m); mi.VManifold = tri::Clean<CMesh>::IsTwoManifoldVertex(m);
mi.FManifold = tri::Clean<CMesh>::IsTwoManifoldFace(m);
// 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.VManifold && mi.FManifold)
{ {
mi.numholes = tri::Clean<CMesh>::CountHoles(m); mi.numholes = tri::Clean<CMesh>::CountHoles(m);
mi.BEdges = tri::Clean<CMesh>::BorderEdges(m, mi.numholes); mi.BEdges = tri::Clean<CMesh>::BorderEdges(m, mi.numholes);
@ -788,7 +796,7 @@ int main(int argc, char ** argv)
mi.numcomponents = tri::Clean<CMesh>::ConnectedComponents(m); mi.numcomponents = tri::Clean<CMesh>::ConnectedComponents(m);
// ORIENTATION // ORIENTATION
if (mi.Manifold) if (mi.VManifold && mi.FManifold)
tri::Clean<CMesh>::IsOrientedMesh(m, mi.Oriented, mi.Orientable); tri::Clean<CMesh>::IsOrientedMesh(m, mi.Oriented, mi.Orientable);
else else
{ {
@ -800,7 +808,7 @@ int main(int argc, char ** argv)
tri::UpdateTopology<CMesh>::VertexFace(m); tri::UpdateTopology<CMesh>::VertexFace(m);
// VOLUME (require a closed oriented manifold) // VOLUME (require a closed oriented manifold)
if ((mi.Manifold)&&(mi.Oriented)&&(!mi.numholes)) if ((mi.VManifold && mi.FManifold)&&(mi.Oriented)&&(!mi.numholes))
{ {
tri::Inertia<CMesh> mm; tri::Inertia<CMesh> mm;
mm.Compute(m); mm.Compute(m);
@ -812,12 +820,12 @@ int main(int argc, char ** argv)
} }
// GENUS // GENUS
if(mi.Manifold) if(mi.VManifold && mi.FManifold)
mi.Genus = tri::Clean<CMesh>::MeshGenus(m, mi.numholes, mi.Genus = tri::Clean<CMesh>::MeshGenus(m, mi.numholes,
mi.numcomponents, mi.count_e); mi.numcomponents, mi.count_e);
// REGULARITY // REGULARITY
if (mi.Manifold) if (mi.VManifold && mi.FManifold)
tri::Clean<CMesh>::IsRegularMesh(m, mi.Regular, mi.Semiregular); tri::Clean<CMesh>::IsRegularMesh(m, mi.Regular, mi.Semiregular);
else else
{ {