Heavily restructured the code of Trimeshinfo.
Now divided the collecting part from the reporting one (xml and ascii)
This commit is contained in:
parent
fe97d7b970
commit
a5d8bd82ac
|
@ -115,16 +115,19 @@
|
|||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath="..\..\trimeshinfo\main.cpp">
|
||||
RelativePath="..\..\..\wrap\ply\plylib.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\wrap\ply\plylib.cpp">
|
||||
RelativePath="..\..\trimeshinfo\trimeshinfo.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
||||
<File
|
||||
RelativePath="..\..\..\vcg\complex\trimesh\clean.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\defs.h">
|
||||
</File>
|
||||
|
|
|
@ -1,48 +1,18 @@
|
|||
// -----------------------------------------------------------------------------------------------
|
||||
#ifndef _DEFS_H
|
||||
#define _DEFS_H
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
|
||||
// command line parameters
|
||||
#define CMD_LINE_ARG_HIST 'H'
|
||||
#define CMD_LINE_ARG_VERTEX_SAMPLE 'V'
|
||||
#define CMD_LINE_ARG_EDGE_SAMPLE 'E'
|
||||
#define CMD_LINE_ARG_FACE_SAMPLE 'F'
|
||||
#define CMD_LINE_ARG_SAMPLE_TYPE 'S'
|
||||
#define CMD_LINE_ARG_MONTECARLO_SAMPLING 'M'
|
||||
#define CMD_LINE_ARG_SUBDIVISION_SAMPLING 'S'
|
||||
#define CMD_LINE_ARG_SIMILAR_TRIANGLES_SAMPLING 'T'
|
||||
#define CMD_LINE_ARG_N_SAMPLES 'N'
|
||||
#define CMD_LINE_ARG_SAMPLES_PER_AREA_UNIT 'A'
|
||||
#define CMD_LINE_ARG_SAVE_DISPLACEMENT 'O'
|
||||
#define CMD_LINE_ARG_SAVE_ERROR_AS_COLOUR 'C'
|
||||
|
||||
|
||||
// error messages
|
||||
#define MSG_ERR_N_ARGS "\nUsage: "\
|
||||
"trimeshinfo filename \n"
|
||||
#define MSG_ERR_N_ARGS \
|
||||
"\nUsage: "\
|
||||
"trimeshinfo filename [opt]\n"\
|
||||
"where opt can be:\n"\
|
||||
" -x[y|n] Enable or not XML info dumping (default no)\n"\
|
||||
" -a[y|n] Enable or not ascii info dumping (default yes)\n"\
|
||||
" -o<filename.ext> Save the input mesh in the specified format\n"
|
||||
|
||||
#define MSG_ERR_MESH_LOAD "error loading the input meshes.\n"
|
||||
#define MSG_ERR_INVALID_OPTION "unable to parse option '%s'\n"
|
||||
#define MSG_ERR_FILE_OPEN "unable to open the output file.'n"
|
||||
#define MSG_ERR_UNKNOWN_FORMAT "unknown file format '%s'.\n"
|
||||
|
||||
// global constants
|
||||
#define NO_SAMPLES_PER_FACE 10
|
||||
#define N_SAMPLES_EDGE_TO_FACE_RATIO 0.1
|
||||
#define BBOX_FACTOR 0.1
|
||||
#define INFLATE_PERCENTAGE 0.02
|
||||
#define MIN_SIZE 125 /* 125 = 5^3 */
|
||||
#define N_HIST_BINS 256
|
||||
#define PRINT_EVERY_N_ELEMENTS 1000
|
||||
#define FILE_EXT_SMF "smf"
|
||||
#define FILE_EXT_PLY "ply"
|
||||
|
||||
// strings
|
||||
#define STR_HIST_FILENAME_DEFAULT "hist.txt"
|
||||
#define STR_NEW_MESH_FILENAME_DEFAULT "error.ply"
|
||||
#define STR_NEW_MESH_FILENAME_DEFAULT_2 "error_colour.ply"
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
#endif
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* VCGLib o o *
|
||||
* Visual and Computer Graphics Library o o *
|
||||
* _ O _ *
|
||||
* Copyright(C) 2004 \/)\/ *
|
||||
* Copyright(C) 2005 \/)\/ *
|
||||
* Visual Computing Lab /\/| *
|
||||
* ISTI - Italian National Research Council | *
|
||||
* \ *
|
||||
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.9 2005/11/04 15:37:57 rita_borgo
|
||||
Removed Debug option
|
||||
|
||||
Revision 1.8 2005/10/11 16:03:40 rita_borgo
|
||||
Moved all the main functions inside clean.h
|
||||
|
||||
|
@ -68,15 +71,12 @@ Self-intersection first release
|
|||
Revision 1.2 2005/01/03 16:13:09 rita_borgo
|
||||
Added Standard comments
|
||||
|
||||
|
||||
|
||||
****************************************************************************/
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <stack>
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include<vcg/simplex/face/with/afav.h>
|
||||
#include<vcg/simplex/face/pos.h>
|
||||
#include<vcg/complex/trimesh/base.h>
|
||||
|
@ -89,27 +89,30 @@ using namespace std;
|
|||
|
||||
#include <vcg/math/histogram.h>
|
||||
#include <wrap/io_trimesh/import.h>
|
||||
#include <wrap/io_trimesh/export_ply.h>
|
||||
#include <wrap/io_trimesh/export_stl.h>
|
||||
#include <wrap/io_trimesh/export_dxf.h>
|
||||
#include <wrap/io_trimesh/export.h>
|
||||
|
||||
#include<vcg/simplex/vertexplus/base.h>
|
||||
#include<vcg/simplex/faceplus/base.h>
|
||||
#include<vcg/simplex/vertexplus/component.h>
|
||||
#include<vcg/simplex/faceplus/component.h>
|
||||
|
||||
#include "XMLTree.h"
|
||||
#include <wrap/io_trimesh/export_off.h>
|
||||
// loader
|
||||
#include<wrap/io_trimesh/import_ply.h>
|
||||
|
||||
#include <vcg/space/index/grid_static_ptr.h>
|
||||
#include "defs.h"
|
||||
#include "trimeshtype.h"
|
||||
string ans;
|
||||
//#include "trimeshtype.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace vcg;
|
||||
using namespace tri;
|
||||
using namespace face;
|
||||
|
||||
|
||||
|
||||
//using namespace tri;
|
||||
//using namespace face;
|
||||
|
||||
|
||||
class CFace;
|
||||
class CEdge;
|
||||
class CVertex : public VertexSimp2< CVertex, CEdge, CFace, vert::Coord3f, vert::Flag, vert::Normal3f >{};
|
||||
class CFace : public FaceSimp2< CVertex, CEdge, CFace, face::FFAdj, face::VertexRef, face::Flag > {};
|
||||
class CMesh : public vcg::tri::TriMesh< vector<CVertex>, vector<CFace> > {};
|
||||
|
||||
typedef CMesh::VertexPointer VertexPointer;
|
||||
typedef CMesh::VertexIterator VertexIterator;
|
||||
|
@ -128,425 +131,189 @@ void OpenMesh(const char *filename, CMesh &m)
|
|||
|
||||
typedef CMesh::VertexPointer VertexPointer;
|
||||
typedef CMesh::VertexIterator VertexIterator;
|
||||
|
||||
|
||||
typedef CMesh::FaceContainer FaceContainer;
|
||||
|
||||
typedef CMesh::ScalarType ScalarType;
|
||||
|
||||
struct MeshInfo
|
||||
{
|
||||
string FileName;
|
||||
int vn,fn;
|
||||
bool Manifold;
|
||||
int count_e,boundary_e,count_fd,count_uv,numholes;
|
||||
int BEdges;
|
||||
float Volume;
|
||||
int numcomponents,Genus;
|
||||
bool Regular,Semiregular;
|
||||
bool Orientable,Oriented;
|
||||
int dv;
|
||||
bool SelfIntersect;
|
||||
};
|
||||
|
||||
void PrintAsciiInfo(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);
|
||||
|
||||
void main(int argc,char ** argv)
|
||||
if (!mi.Manifold) printf( "\t Manifold: NO\n");
|
||||
else printf( "\t Manifold: YES\n");
|
||||
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 boundary edges: %i \n", mi.boundary_e);
|
||||
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);
|
||||
else printf("\t Volume: UNDEFINED, mesh is either non-manifold or has holes \n");
|
||||
printf("\t Number of connected components: %d\n", mi.numcomponents);
|
||||
if (mi.Manifold) printf( "\t Genus: %d \n", mi.Genus);
|
||||
else printf( "\t Genus (n/a)\n");
|
||||
|
||||
if (mi.Regular) printf("\t Type of Mesh: REGULAR\n");
|
||||
else if (mi.Semiregular) printf("\t Type of Mesh: SEMIREGULAR\n");
|
||||
else printf("\t Type of Mesh: IRREGULAR\n");
|
||||
|
||||
if (!mi.Manifold) {
|
||||
printf( "\t Orientable Mesh: NO\n");
|
||||
printf( "\t Oriented Mesh: NO\n");
|
||||
} 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 Self Intersection: %s\n",mi.SelfIntersect?"Yes":"No");
|
||||
|
||||
}
|
||||
|
||||
void PrintXMLInfo(MeshInfo &mi)
|
||||
{
|
||||
XMLTree doc;
|
||||
doc.initializeMain();
|
||||
|
||||
char s[256];
|
||||
sprintf(s,"%d",mi.vn); 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");
|
||||
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_fd); doc.addNode(s, VALUE_INTEGER,"Number of Degenerated Faces");
|
||||
sprintf(s,"%d",mi.count_uv); 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");
|
||||
|
||||
if (mi.Regular) doc.addNode("REGULAR", 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) {
|
||||
doc.addNode("NO", VALUE_STRING,"Orientable Mesh");
|
||||
doc.addNode("NO", VALUE_STRING,"Oriented Mesh");
|
||||
} else {
|
||||
doc.addNode(mi.Orientable?"Yes":"No", VALUE_STRING,"Orientable Mesh");
|
||||
doc.addNode( mi.Oriented?"Yes":"No", VALUE_STRING,"Oriented Mesh");
|
||||
}
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
int main(int argc,char ** argv)
|
||||
{
|
||||
CMesh m;
|
||||
XMLTree doc;
|
||||
bool SaveFlag=false;
|
||||
bool AsciiFlag=true;
|
||||
bool XmlFlag=false;
|
||||
|
||||
string SaveName;
|
||||
|
||||
|
||||
//load the mesh
|
||||
//argv[1]=(char*)"c:\\checkup\\debug\\column1m.ply";
|
||||
//argv[1] = "C:\\sf\\apps\\msvc\\trimeshinfo\\Release\\prism.off";
|
||||
//argv[1] = "C:\\sf\\apps\\msvc\\trimeshinfo\\Release\\prova1.ply";
|
||||
|
||||
// print program info
|
||||
MeshInfo mi;
|
||||
printf("-------------------------------\n"
|
||||
" TriMeshInfo V.1.01 \n"
|
||||
" TriMeshInfo V.1.2 \n"
|
||||
" http://vcg.isti.cnr.it\n"
|
||||
" release date: "__DATE__"\n"
|
||||
"-------------------------------\n\n");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// load input meshes.
|
||||
if(argc <= 1)
|
||||
{
|
||||
if(argc <= 1) {
|
||||
printf(MSG_ERR_N_ARGS);
|
||||
exit(-1);
|
||||
}
|
||||
mi.FileName=argv[1];
|
||||
|
||||
|
||||
|
||||
|
||||
OpenMesh(argv[1],m);
|
||||
|
||||
doc.initializeMain();
|
||||
|
||||
printf("\t Mesh info:\n");
|
||||
printf(" \t M: '%s'\n\t Number of vertices: %d \n", argv[1], m.vn);
|
||||
printf("\t Number of faces: %d \n", m.fn);
|
||||
|
||||
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
char* s =new(char[25]);
|
||||
sprintf(s,"%d",m.vn);
|
||||
doc.addNode(s, VALUE_INTEGER,"Number of Vertices");
|
||||
sprintf(s,"%d",m.fn);
|
||||
doc.addNode(s, VALUE_INTEGER, "Number of Faces");
|
||||
|
||||
/*--------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
if(m.HasPerFaceColor()||m.HasPerVertexColor())
|
||||
for(int i=3; i < argc;)
|
||||
{
|
||||
Color4b Color=m.C();
|
||||
printf( "\t Object color(4b): %f %f %f \n", Color[0], Color[1], Color[2]);
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
|
||||
sprintf(s,"%f %f %f ",Color[0], Color[1], Color[2]);
|
||||
doc.addNode(s, VALUE_FLOAT,"Colors");
|
||||
/*--------------------------------------------*/
|
||||
if(argv[i][0]=='-')
|
||||
switch(argv[i][1])
|
||||
{
|
||||
case 'o' : SaveFlag=true; SaveName=argv[i][2]; break;
|
||||
case 'x' : if(argv[i][2]=='y') { 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);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
OpenMesh(mi.FileName.c_str(),m);
|
||||
mi.vn=m.vn; mi.fn=m.fn;
|
||||
|
||||
vcg::tri::UpdateTopology<CMesh>::FaceFace(m);
|
||||
|
||||
// IS MANIFOLD
|
||||
|
||||
|
||||
tri::Clean<CMesh>::Initialize(m);
|
||||
|
||||
|
||||
|
||||
bool Manifold = tri::Clean<CMesh>::IsComplexManifold(m);
|
||||
|
||||
if (!Manifold)
|
||||
{
|
||||
printf( "\t Manifold: NO\n");
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
|
||||
s = "No";
|
||||
doc.addNode(s, VALUE_BOOL,"Manifold");
|
||||
|
||||
/*--------------------------------------------*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
printf( "\t Manifold: YES\n");
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
s = "Yes";
|
||||
doc.addNode(s, VALUE_BOOL,"Manifold");
|
||||
/*--------------------------------------------*/
|
||||
}
|
||||
|
||||
mi.Manifold = tri::Clean<CMesh>::IsComplexManifold(m);
|
||||
|
||||
// COUNT EDGES
|
||||
int count_e=0;
|
||||
int boundary_e = 0;
|
||||
tri::Clean<CMesh>::CountEdges(m, count_e, boundary_e);
|
||||
|
||||
printf("\t Number of edges: %d \n", count_e);
|
||||
printf("\t Number of internal edges: %d \n", count_e-boundary_e);
|
||||
printf("\t Number of boundary edges: %i \n", boundary_e);
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
s = new(char[25]);
|
||||
sprintf(s,"%d",count_e);
|
||||
doc.addNode(s, VALUE_INTEGER,"Number of Edges");
|
||||
|
||||
/*--------------------------------------------*/
|
||||
|
||||
|
||||
tri::Clean<CMesh>::CountEdges(m, mi.count_e, mi.boundary_e);
|
||||
|
||||
// DEGENERATED FACES
|
||||
|
||||
int count_fd = tri::Clean<CMesh>::DegeneratedFaces(m);
|
||||
|
||||
printf("\t Number of degenerated faces: %d\n", count_fd);
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
|
||||
sprintf(s,"%d",count_fd);
|
||||
doc.addNode(s, VALUE_INTEGER,"Number of Degenerated Faces");
|
||||
|
||||
/*--------------------------------------------*/
|
||||
mi.count_fd = tri::Clean<CMesh>::DegeneratedFaces(m);
|
||||
|
||||
// UNREFERENCED VERTEX
|
||||
|
||||
int count_uv = tri::Clean<CMesh>::DetectUnreferencedVertex(m);
|
||||
printf("\t Number of unreferenced vertices: %d\n",count_uv);
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
|
||||
sprintf(s,"%d",count_uv);
|
||||
doc.addNode(s, VALUE_INTEGER,"Number of unreferenced vertices");
|
||||
|
||||
/*--------------------------------------------*/
|
||||
|
||||
mi.count_uv = tri::Clean<CMesh>::DetectUnreferencedVertex(m);
|
||||
|
||||
// HOLES COUNT
|
||||
|
||||
int numholes =0 ;
|
||||
if(Manifold)
|
||||
if(mi.Manifold)
|
||||
{
|
||||
numholes = tri::Clean<CMesh>::CountHoles(m);
|
||||
printf("\t Number of holes/boundaries: %d \n", numholes);
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
sprintf(s,"%d",numholes);
|
||||
doc.addNode(s, VALUE_INTEGER,"Number of Holes");
|
||||
/*--------------------------------------------*/
|
||||
if(numholes>0)
|
||||
{
|
||||
printf("\t Edges per hole/boundary:\n\t (");
|
||||
int BEdges = tri::Clean<CMesh>::BorderEdges(m, numholes);
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
|
||||
sprintf(s,"%d",BEdges);
|
||||
doc.addNode(s, VALUE_INTEGER,"Number of Border Edges");
|
||||
|
||||
/*--------------------------------------------*/
|
||||
mi.numholes = tri::Clean<CMesh>::CountHoles(m);
|
||||
mi.BEdges = tri::Clean<CMesh>::BorderEdges(m, mi.numholes);
|
||||
}
|
||||
}
|
||||
else
|
||||
printf( "\t Number of holes: UNDEFINED, mesh is non-manifold \n");
|
||||
|
||||
|
||||
// Mesh Volume
|
||||
float vol = m.Volume();
|
||||
int nuh = numholes;
|
||||
if((m.Volume()!=0.)&&(Manifold)&&(numholes==0))
|
||||
{
|
||||
|
||||
printf("\t Volume: %f \n", m.Volume());
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
|
||||
sprintf(s,"%f",m.Volume());
|
||||
doc.addNode(s, VALUE_FLOAT,"Volume");
|
||||
/*--------------------------------------------*/
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\t Volume: UNDEFINED, mesh is either non-manifold or has holes \n");
|
||||
}
|
||||
|
||||
if(mi.numholes==0) mi.Volume = m.Volume();
|
||||
|
||||
// CONNECTED COMPONENTS
|
||||
mi.numcomponents = tri::Clean<CMesh>::ConnectedComponents(m);
|
||||
|
||||
|
||||
int numcomponents = tri::Clean<CMesh>::ConnectedComponents(m);
|
||||
printf("\t Number of connected components: %d\n", numcomponents);
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
|
||||
sprintf(s,"%d",numcomponents);
|
||||
doc.addNode(s, VALUE_INTEGER,"Number of Connected Components");
|
||||
/*--------------------------------------------*/
|
||||
|
||||
//GENUS --> 2( #components - genus ) = #vertices + #faces - #edge - #boundary_loops = eulernumber - #holes
|
||||
//eulero = (mesh.vn-count_uv) - (count_e)+mesh.fn;
|
||||
|
||||
|
||||
|
||||
if(Manifold)
|
||||
{
|
||||
printf( "\t Genus: %d \n", tri::Clean<CMesh>::MeshGenus(m,count_uv, numholes, numcomponents, count_e));
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
|
||||
sprintf(s,"%d",tri::Clean<CMesh>::MeshGenus(m,count_uv, numholes, numcomponents, count_e));
|
||||
doc.addNode(s, VALUE_INTEGER,"Genus");
|
||||
/*--------------------------------------------*/
|
||||
}
|
||||
else//(!Manifold)
|
||||
printf( "\t Genus: UNDEFINED, mesh is non-manifold \n");
|
||||
if(mi.Manifold) mi.Genus=tri::Clean<CMesh>::MeshGenus(m,mi.count_uv, mi.numholes, mi.numcomponents, mi.count_e);
|
||||
|
||||
// REGULARITY
|
||||
bool Regular=true;
|
||||
bool Semiregular=true;
|
||||
tri::Clean<CMesh>::IsRegularMesh(m, mi.Regular, mi.Semiregular);
|
||||
|
||||
tri::Clean<CMesh>::IsRegularMesh(m, Regular, Semiregular);
|
||||
if (Regular)
|
||||
{
|
||||
|
||||
printf("\t Type of Mesh: REGULAR\n");
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
s="REGULAR";
|
||||
doc.addNode(s, VALUE_STRING,"Type of Mesh");
|
||||
/*--------------------------------------------*/
|
||||
}
|
||||
else if (Semiregular)
|
||||
{
|
||||
|
||||
printf("\t Type of Mesh: SEMIREGULAR\n");
|
||||
s="SEMIREGULAR";
|
||||
doc.addNode(s, VALUE_STRING,"Type of Mesh");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
printf("\t Type of Mesh: IRREGULAR\n");
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
|
||||
s="IRREGULAR";
|
||||
doc.addNode(s, VALUE_STRING,"Type of Mesh");
|
||||
|
||||
/*--------------------------------------------*/
|
||||
}
|
||||
// ORIENTABLE E ORIENTED MESH
|
||||
if (mi.Manifold) tri::Clean<CMesh>::IsOrientedMesh(m, mi.Oriented, mi.Orientable);
|
||||
|
||||
bool Orientable=true;
|
||||
bool Oriented=true;
|
||||
if (!Manifold)
|
||||
{
|
||||
mi.dv = tri::Clean<CMesh>::RemoveDuplicateVertex(m);
|
||||
|
||||
printf( "\t Orientable Mesh: NO\n");
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
|
||||
s="NO";
|
||||
doc.addNode(s, VALUE_STRING,"Orientable Mesh");
|
||||
/*--------------------------------------------*/
|
||||
}
|
||||
else
|
||||
{
|
||||
tri::Clean<CMesh>::IsOrientedMesh(m, Oriented, Orientable);
|
||||
|
||||
if (Orientable)
|
||||
{
|
||||
|
||||
printf( "\t Orientable Mesh: YES\n");
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
|
||||
s="YES";
|
||||
doc.addNode(s, VALUE_STRING,"Orientable Mesh");
|
||||
|
||||
/*--------------------------------------------*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
printf( "\t Orientable Mesh: NO\n");
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
|
||||
s="NO";
|
||||
doc.addNode(s, VALUE_STRING,"Orientable Mesh");
|
||||
/*--------------------------------------------*/
|
||||
}
|
||||
}
|
||||
if (Oriented && Manifold)
|
||||
{
|
||||
|
||||
printf( "\t Oriented Mesh: YES\n");
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
|
||||
s="YES";
|
||||
doc.addNode(s, VALUE_STRING,"Oriented Mesh");
|
||||
/*--------------------------------------------*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
printf( "\t Oriented Mesh: NO\n");
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
|
||||
s="NO";
|
||||
doc.addNode(s, VALUE_STRING,"Oriented Mesh");
|
||||
/*--------------------------------------------*/
|
||||
}
|
||||
int dv = tri::Clean<CMesh>::RemoveDuplicateVertex(m);
|
||||
if(dv>0)
|
||||
{
|
||||
|
||||
printf( "\t Number of duplicated vertices found: %d\n",dv);
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
|
||||
char* s =new(char[25]);
|
||||
sprintf(s,"%d",dv);
|
||||
doc.addNode(s, VALUE_INTEGER,"Duplicated Vertices");
|
||||
/*--------------------------------------------*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
printf( "\t Duplicated vertices: NO\n");
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
|
||||
s="NO";
|
||||
doc.addNode(s, VALUE_STRING,"Duplicated Vertices");
|
||||
/*--------------------------------------------*/
|
||||
}
|
||||
// SELF INTERSECTION
|
||||
mi.SelfIntersect = tri::Clean<CMesh>::SelfIntersections(m);
|
||||
|
||||
if(SaveFlag) tri::io::Exporter<CMesh>::Save(m,SaveName.c_str());
|
||||
|
||||
printf("\t Model Bounding Box Diagonal: %f\n", m.bbox.Diag());
|
||||
if (tri::Clean<CMesh>::SelfIntersections(m))
|
||||
{
|
||||
|
||||
printf( "\t Self Intersection: YES\n");
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
|
||||
s="YES";
|
||||
doc.addNode(s, VALUE_STRING,"Self Intersection");
|
||||
|
||||
/*--------------------------------------------*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
printf( "\t Self Intersection: NO\n");
|
||||
|
||||
/*------------XML file part ------------------*/
|
||||
|
||||
s="NO";
|
||||
doc.addNode(s, VALUE_STRING,"Self Intersection");
|
||||
/*--------------------------------------------*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
string fs;
|
||||
|
||||
cout<< "\t To save the file: [s/S]\n \t ";
|
||||
cin>>ans;
|
||||
|
||||
|
||||
if((ans == "S")||(ans == "s"))
|
||||
{
|
||||
cout<< "\t available formats: [ply, off, dxf, stl]"<<endl;
|
||||
cout<< "\t enter format \n \t ";
|
||||
cin>>ans;
|
||||
cout<<"\t enter filename \n \t ";
|
||||
cin>>fs;
|
||||
const char* filesave = fs.c_str();
|
||||
if(ans == "ply")
|
||||
tri::io::ExporterPLY<CMesh>::Save(m, filesave);
|
||||
else if(ans == "stl")
|
||||
tri::io::ExporterSTL<CMesh>::Save(m,filesave);
|
||||
else if(ans == "dxf")
|
||||
tri::io::ExporterDXF<CMesh>::Save(m,filesave);
|
||||
|
||||
else if(ans == "off")
|
||||
tri::io::ExporterOFF<CMesh>::Save(m,filesave);
|
||||
}
|
||||
|
||||
cout<<"\t create XML files? [y/Y|n/N] \n \t ";
|
||||
cin>>ans;
|
||||
if((ans=="Y")||(ans=="y"))
|
||||
{
|
||||
doc.finalizeMain();
|
||||
doc.printXMLTree();
|
||||
}
|
||||
if(AsciiFlag) PrintAsciiInfo(mi);
|
||||
if(XmlFlag) PrintXMLInfo(mi);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue