2005-09-20 12:15:27 +02:00
|
|
|
/****************************************************************************
|
2005-10-11 18:03:41 +02:00
|
|
|
* VCGLib o o *
|
|
|
|
* Visual and Computer Graphics Library o o *
|
|
|
|
* _ O _ *
|
|
|
|
* Copyright(C) 2004 \/)\/ *
|
|
|
|
* Visual Computing Lab /\/| *
|
|
|
|
* ISTI - Italian National Research Council | *
|
|
|
|
* \ *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
|
|
|
* for more details. *
|
|
|
|
* *
|
2005-09-20 12:15:27 +02:00
|
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
2005-09-29 16:48:15 +02:00
|
|
|
History
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
$Log: not supported by cvs2svn $
|
2005-10-11 18:03:41 +02:00
|
|
|
Revision 1.7 2005/09/30 15:48:46 rita_borgo
|
|
|
|
Fixed manifold Test
|
2005-09-30 17:48:46 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
Revision 1.6 2005/09/30 14:13:01 rita_borgo
|
|
|
|
Problem: Text not aligned
|
2005-09-30 16:13:01 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
Revision 1.5 2005/09/30 13:29:40 rita_borgo
|
|
|
|
Fixed Manifold Test
|
2005-09-30 15:29:40 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
Revision 1.4 2005/09/29 14:48:15 rita_borgo
|
|
|
|
Fixed code related to creation of the XML file
|
2005-09-29 16:48:15 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
Revision 1.3 2005/09/28 13:57:09 rita_borgo
|
|
|
|
Fixed some printout not alligned
|
2005-09-28 15:57:09 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
Revision 1.2 2005/09/28 10:46:04 rita_borgo
|
|
|
|
Added possibility of saving File in OFF format
|
|
|
|
|
|
|
|
Revision 1.1 2005/09/20 10:15:27 rita_borgo
|
|
|
|
Changed file name to uniform with other solution projects,
|
2005-09-29 16:48:15 +02:00
|
|
|
before was main.cpp
|
2005-09-28 12:46:04 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
Revision 1.8 2005/02/15 12:26:06 rita_borgo
|
|
|
|
Minor changes to self-intersection
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
Revision 1.7 2005/02/07 15:44:31 rita_borgo
|
|
|
|
Fixed Color and Volume
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
Revision 1.6 2005/02/01 17:37:53 rita_borgo
|
|
|
|
Fixed Volume and Color
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
Revision 1.5 2005/01/18 16:33:12 rita_borgo
|
|
|
|
Added OFF file Option
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
Revision 1.4 2005/01/17 18:19:00 rita_borgo
|
|
|
|
Added new routines.
|
|
|
|
Self-intersection first release
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
Revision 1.2 2005/01/03 16:13:09 rita_borgo
|
|
|
|
Added Standard comments
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
****************************************************************************/
|
|
|
|
#include <vector>
|
2005-09-30 17:48:46 +02:00
|
|
|
#include <string>
|
2005-09-20 12:15:27 +02:00
|
|
|
#include <stack>
|
2005-10-11 18:03:41 +02:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
#include<vcg/simplex/face/with/afav.h>
|
2005-10-11 18:03:41 +02:00
|
|
|
#include<vcg/simplex/face/pos.h>
|
2005-09-20 12:15:27 +02:00
|
|
|
#include<vcg/complex/trimesh/base.h>
|
2005-10-11 18:03:41 +02:00
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
#include<vcg/complex/trimesh/update/topology.h>
|
|
|
|
#include <vcg/complex/trimesh/update/edges.h>
|
|
|
|
#include <vcg/complex/trimesh/update/bounding.h>
|
|
|
|
#include <vcg/complex/trimesh/clean.h>
|
|
|
|
#include <vcg/space/intersection/triangle_triangle3.h>
|
2005-10-11 18:03:41 +02:00
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
#include <vcg/math/histogram.h>
|
|
|
|
#include <wrap/io_trimesh/import.h>
|
|
|
|
#include <wrap/io_trimesh/export_ply.h>
|
2005-09-28 12:46:04 +02:00
|
|
|
#include <wrap/io_trimesh/export_stl.h>
|
|
|
|
#include <wrap/io_trimesh/export_dxf.h>
|
2005-09-20 12:15:27 +02:00
|
|
|
#include "XMLTree.h"
|
2005-09-28 12:46:04 +02:00
|
|
|
#include <wrap/io_trimesh/export_off.h>
|
2005-09-30 17:48:46 +02:00
|
|
|
// loader
|
2005-09-20 12:15:27 +02:00
|
|
|
#include<wrap/io_trimesh/import_ply.h>
|
2005-10-11 18:03:41 +02:00
|
|
|
|
|
|
|
#include <vcg/space/index/grid_static_ptr.h>
|
2005-09-20 12:15:27 +02:00
|
|
|
#include "defs.h"
|
2005-10-11 18:03:41 +02:00
|
|
|
#include "trimeshtype.h"
|
2005-09-30 17:48:46 +02:00
|
|
|
string ans;
|
2005-10-11 18:03:41 +02:00
|
|
|
|
|
|
|
using namespace vcg;
|
|
|
|
using namespace tri;
|
|
|
|
using namespace face;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef CMesh::VertexPointer VertexPointer;
|
|
|
|
typedef CMesh::VertexIterator VertexIterator;
|
|
|
|
typedef Point3<CMesh::ScalarType> Point3x;
|
|
|
|
typedef vector<Point3x> Hole;
|
|
|
|
|
|
|
|
void OpenMesh(const char *filename, CMesh &m)
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
int err = tri::io::Importer<CMesh>::Open(m,filename);
|
2005-09-30 17:48:46 +02:00
|
|
|
if(err){
|
2005-10-11 18:03:41 +02:00
|
|
|
printf("Error in reading %s: '%s'\n",filename,tri::io::Importer<CMesh>::ErrorMsg(err));
|
2005-09-29 16:48:15 +02:00
|
|
|
exit(-1);
|
|
|
|
}
|
2005-10-11 18:03:41 +02:00
|
|
|
printf("\t read mesh `%s'\n", filename);
|
2005-09-30 17:48:46 +02:00
|
|
|
}
|
2005-09-30 16:13:01 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
typedef CMesh::VertexPointer VertexPointer;
|
|
|
|
typedef CMesh::VertexIterator VertexIterator;
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
|
|
|
|
typedef CMesh::FaceContainer FaceContainer;
|
|
|
|
|
|
|
|
typedef CMesh::ScalarType ScalarType;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void main(int argc,char ** argv)
|
|
|
|
{
|
|
|
|
CMesh m;
|
|
|
|
bool DEBUG=true;
|
|
|
|
XMLTree doc;
|
2005-09-30 17:48:46 +02:00
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
//load the mesh
|
|
|
|
//argv[1]=(char*)"c:\\checkup\\debug\\column1m.ply";
|
2005-10-11 18:03:41 +02:00
|
|
|
//argv[1] = "C:\\sf\\apps\\msvc\\trimeshinfo\\Release\\prism.off";
|
|
|
|
//argv[1] = "C:\\sf\\apps\\msvc\\trimeshinfo\\Release\\prova1.ply";
|
2005-09-29 16:48:15 +02:00
|
|
|
|
|
|
|
// print program info
|
|
|
|
printf("-------------------------------\n"
|
2005-10-11 18:03:41 +02:00
|
|
|
" TriMeshInfo V.1.01 \n"
|
|
|
|
" http://vcg.isti.cnr.it\n"
|
|
|
|
" release date: "__DATE__"\n"
|
2005-09-29 16:48:15 +02:00
|
|
|
"-------------------------------\n\n");
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
if(DEBUG)
|
2005-10-11 18:03:41 +02:00
|
|
|
// argv[1] = "C:\\sf\\apps\\msvc\\trimeshinfo\\Release\\tests\\kite_hole3.ply";
|
|
|
|
argv[1] = "C:\\sf\\apps\\msvc\\trimeshinfo\\modelli\\grog50k.ply";
|
2005-09-29 16:48:15 +02:00
|
|
|
|
|
|
|
else
|
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
// load input meshes.
|
|
|
|
if(argc <= 1)
|
2005-09-29 16:48:15 +02:00
|
|
|
{
|
|
|
|
printf(MSG_ERR_N_ARGS);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
OpenMesh(argv[1],m);
|
2005-09-30 17:48:46 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.initializeMain();
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
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);
|
2005-09-29 16:48:15 +02:00
|
|
|
|
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
char* s =new(char[25]);
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%d",m.vn);
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.addNode(s, VALUE_INTEGER,"Number of Vertices");
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%d",m.fn);
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.addNode(s, VALUE_INTEGER, "Number of Faces");
|
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
if(m.HasPerFaceColor()||m.HasPerVertexColor())
|
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
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");
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
|
2005-09-28 12:46:04 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
vcg::tri::UpdateTopology<CMesh>::FaceFace(m);
|
2005-09-30 17:48:46 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
// IS MANIFOLD
|
2005-09-30 17:48:46 +02:00
|
|
|
|
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
tri::Clean<CMesh>::Initialize(m);
|
2005-09-30 17:48:46 +02:00
|
|
|
|
2005-09-30 15:29:40 +02:00
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
bool Manifold = tri::Clean<CMesh>::IsComplexManifold(m);
|
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
if (!Manifold)
|
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
printf( "\t Manifold: NO\n");
|
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
|
|
|
|
s = "No";
|
|
|
|
doc.addNode(s, VALUE_BOOL,"Manifold");
|
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
|
|
|
|
printf( "\t Manifold: YES\n");
|
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
s = "Yes";
|
|
|
|
doc.addNode(s, VALUE_BOOL,"Manifold");
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
// COUNT EDGES
|
2005-10-11 18:03:41 +02:00
|
|
|
int count_e=0;
|
|
|
|
int boundary_e = 0;
|
|
|
|
tri::Clean<CMesh>::CountEdges(m, count_e, boundary_e);
|
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
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);
|
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
s = new(char[25]);
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%d",count_e);
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.addNode(s, VALUE_INTEGER,"Number of Edges");
|
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DEGENERATED FACES
|
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
int count_fd = tri::Clean<CMesh>::DegeneratedFaces(m);
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
printf("\t Number of degenerated faces: %d\n", count_fd);
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
/*------------XML file part ------------------*/
|
2005-09-29 16:48:15 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
sprintf(s,"%d",count_fd);
|
|
|
|
doc.addNode(s, VALUE_INTEGER,"Number of Degenerated Faces");
|
2005-09-29 16:48:15 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-29 16:48:15 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
// UNREFERENCED VERTEX
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
int count_uv = tri::Clean<CMesh>::DetectUnreferencedVertex(m);
|
|
|
|
printf("\t Number of unreferenced vertices: %d\n",count_uv);
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
/*------------XML file part ------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%d",count_uv);
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.addNode(s, VALUE_INTEGER,"Number of unreferenced vertices");
|
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
// HOLES COUNT
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
int numholes =0 ;
|
|
|
|
if(Manifold)
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
numholes = tri::Clean<CMesh>::CountHoles(m);
|
2005-09-30 17:48:46 +02:00
|
|
|
printf("\t Number of holes/boundaries: %d \n", numholes);
|
2005-09-29 16:48:15 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
/*------------XML file part ------------------*/
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%d",numholes);
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.addNode(s, VALUE_INTEGER,"Number of Holes");
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-28 15:57:09 +02:00
|
|
|
if(numholes>0)
|
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
printf("\t Edges per hole/boundary:\n\t (");
|
|
|
|
int BEdges = tri::Clean<CMesh>::BorderEdges(m, numholes);
|
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%d",BEdges);
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.addNode(s, VALUE_INTEGER,"Number of Border Edges");
|
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-28 15:57:09 +02:00
|
|
|
}
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
else
|
2005-10-11 18:03:41 +02:00
|
|
|
printf( "\t Number of holes: UNDEFINED, mesh is non-manifold \n");
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
// Mesh Volume
|
|
|
|
float vol = m.Volume();
|
|
|
|
int nuh = numholes;
|
|
|
|
if((m.Volume()!=0.)&&(Manifold)&&(numholes==0))
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
printf("\t Volume: %f \n", m.Volume());
|
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%f",m.Volume());
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.addNode(s, VALUE_FLOAT,"Volume");
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
2005-09-30 17:48:46 +02:00
|
|
|
else
|
2005-09-28 15:57:09 +02:00
|
|
|
{
|
|
|
|
printf("\t Volume: UNDEFINED, mesh is either non-manifold or has holes \n");
|
|
|
|
}
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
// CONNECTED COMPONENTS
|
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
|
|
|
|
int numcomponents = tri::Clean<CMesh>::ConnectedComponents(m);
|
|
|
|
printf("\t Number of connected components: %d\n", numcomponents);
|
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%d",numcomponents);
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.addNode(s, VALUE_INTEGER,"Number of Connected Components");
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-28 15:57:09 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
//GENUS --> 2( #components - genus ) = #vertices + #faces - #edge - #boundary_loops = eulernumber - #holes
|
|
|
|
//eulero = (mesh.vn-count_uv) - (count_e)+mesh.fn;
|
|
|
|
|
|
|
|
|
2005-09-28 15:57:09 +02:00
|
|
|
|
|
|
|
if(Manifold)
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
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");
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-28 15:57:09 +02:00
|
|
|
}
|
2005-09-30 17:48:46 +02:00
|
|
|
else//(!Manifold)
|
2005-10-11 18:03:41 +02:00
|
|
|
printf( "\t Genus: UNDEFINED, mesh is non-manifold \n");
|
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
// REGULARITY
|
2005-09-20 12:15:27 +02:00
|
|
|
bool Regular=true;
|
|
|
|
bool Semiregular=true;
|
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
tri::Clean<CMesh>::IsRegularMesh(m, Regular, Semiregular);
|
2005-09-20 12:15:27 +02:00
|
|
|
if (Regular)
|
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
printf("\t Type of Mesh: REGULAR\n");
|
2005-09-29 16:48:15 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
/*------------XML file part ------------------*/
|
2005-09-30 17:48:46 +02:00
|
|
|
s="REGULAR";
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.addNode(s, VALUE_STRING,"Type of Mesh");
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
2005-10-11 18:03:41 +02:00
|
|
|
else if (Semiregular)
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
printf("\t Type of Mesh: SEMIREGULAR\n");
|
2005-09-30 17:48:46 +02:00
|
|
|
s="SEMIREGULAR";
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.addNode(s, VALUE_STRING,"Type of Mesh");
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
2005-09-30 17:48:46 +02:00
|
|
|
else
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
printf("\t Type of Mesh: IRREGULAR\n");
|
2005-09-29 16:48:15 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
s="IRREGULAR";
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.addNode(s, VALUE_STRING,"Type of Mesh");
|
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
2005-10-11 18:03:41 +02:00
|
|
|
// ORIENTABLE E ORIENTED MESH
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
bool Orientable=true;
|
|
|
|
bool Oriented=true;
|
|
|
|
if (!Manifold)
|
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
|
|
|
|
printf( "\t Orientable Mesh: NO\n");
|
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
s="NO";
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.addNode(s, VALUE_STRING,"Orientable Mesh");
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
tri::Clean<CMesh>::IsOrientedMesh(m, Oriented, Orientable);
|
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
if (Orientable)
|
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
|
|
|
|
printf( "\t Orientable Mesh: YES\n");
|
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
s="YES";
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.addNode(s, VALUE_STRING,"Orientable Mesh");
|
|
|
|
|
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
|
|
|
|
printf( "\t Orientable Mesh: NO\n");
|
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
s="NO";
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.addNode(s, VALUE_STRING,"Orientable Mesh");
|
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
}
|
2005-10-11 18:03:41 +02:00
|
|
|
if (Oriented && Manifold)
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
|
|
|
|
printf( "\t Oriented Mesh: YES\n");
|
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
s="YES";
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.addNode(s, VALUE_STRING,"Oriented Mesh");
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-28 12:46:04 +02:00
|
|
|
}
|
2005-09-20 12:15:27 +02:00
|
|
|
else
|
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
|
|
|
|
printf( "\t Oriented Mesh: NO\n");
|
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
s="NO";
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.addNode(s, VALUE_STRING,"Oriented Mesh");
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-28 12:46:04 +02:00
|
|
|
}
|
2005-10-11 18:03:41 +02:00
|
|
|
int dv = tri::Clean<CMesh>::RemoveDuplicateVertex(m);
|
2005-09-20 12:15:27 +02:00
|
|
|
if(dv>0)
|
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
|
|
|
|
printf( "\t Number of duplicated vertices found: %d\n",dv);
|
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
|
|
|
|
char* s =new(char[25]);
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%d",dv);
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.addNode(s, VALUE_INTEGER,"Duplicated Vertices");
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
|
|
|
|
printf( "\t Duplicated vertices: NO\n");
|
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
s="NO";
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.addNode(s, VALUE_STRING,"Duplicated Vertices");
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
2005-10-11 18:03:41 +02:00
|
|
|
// SELF INTERSECTION
|
|
|
|
|
|
|
|
|
|
|
|
if (tri::Clean<CMesh>::SelfIntersections(m))
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
|
|
|
|
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");
|
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
2005-09-28 12:46:04 +02:00
|
|
|
|
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2005-09-28 12:46:04 +02:00
|
|
|
|
|
|
|
string fs;
|
2005-09-29 16:48:15 +02:00
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
cout<< "\t To save the file: [s/S]\n \t ";
|
2005-09-28 12:46:04 +02:00
|
|
|
cin>>ans;
|
|
|
|
|
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
if((ans == "S")||(ans == "s"))
|
2005-09-29 16:48:15 +02:00
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
cout<< "\t available formats: [ply, off, dxf, stl]"<<endl;
|
|
|
|
cout<< "\t enter format \n \t ";
|
2005-09-29 16:48:15 +02:00
|
|
|
cin>>ans;
|
2005-10-11 18:03:41 +02:00
|
|
|
cout<<"\t enter filename \n \t ";
|
2005-09-29 16:48:15 +02:00
|
|
|
cin>>fs;
|
2005-10-11 18:03:41 +02:00
|
|
|
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);
|
2005-09-29 16:48:15 +02:00
|
|
|
}
|
|
|
|
|
2005-10-11 18:03:41 +02:00
|
|
|
cout<<"\t create XML files? [y/Y|n/N] \n \t ";
|
2005-09-30 15:29:40 +02:00
|
|
|
cin>>ans;
|
|
|
|
if((ans=="Y")||(ans=="y"))
|
|
|
|
{
|
2005-10-11 18:03:41 +02:00
|
|
|
doc.finalizeMain();
|
2005-09-30 17:48:46 +02:00
|
|
|
doc.printXMLTree();
|
2005-09-30 15:29:40 +02:00
|
|
|
}
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
|