2005-09-20 12:15:27 +02:00
|
|
|
/****************************************************************************
|
2005-09-30 17:48:46 +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-09-30 17:48:46 +02:00
|
|
|
Revision 1.6 2005/09/30 14:13:01 rita_borgo
|
|
|
|
Problem: Text not aligned
|
|
|
|
|
|
|
|
Revision 1.5 2005/09/30 13:29:40 rita_borgo
|
2005-09-30 16:13:01 +02:00
|
|
|
Fixed Manifold Test
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
Revision 1.4 2005/09/29 14:48:15 rita_borgo
|
2005-09-30 15:29:40 +02:00
|
|
|
Fixed code related to creation of the XML file
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
Revision 1.3 2005/09/28 13:57:09 rita_borgo
|
2005-09-29 16:48:15 +02:00
|
|
|
Fixed some printout not alligned
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
Revision 1.2 2005/09/28 10:46:04 rita_borgo
|
2005-09-28 15:57:09 +02:00
|
|
|
Added possibility of saving File in OFF format
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
Revision 1.1 2005/09/20 10:15:27 rita_borgo
|
2005-09-28 12:46:04 +02:00
|
|
|
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-09-30 17:48:46 +02:00
|
|
|
Revision 1.8 2005/02/15 12:26:06 rita_borgo
|
2005-09-20 12:15:27 +02:00
|
|
|
Minor changes to self-intersection
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
Revision 1.7 2005/02/07 15:44:31 rita_borgo
|
2005-09-20 12:15:27 +02:00
|
|
|
Fixed Color and Volume
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
Revision 1.6 2005/02/01 17:37:53 rita_borgo
|
2005-09-20 12:15:27 +02:00
|
|
|
Fixed Volume and Color
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
Revision 1.5 2005/01/18 16:33:12 rita_borgo
|
2005-09-20 12:15:27 +02:00
|
|
|
Added OFF file Option
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
Revision 1.4 2005/01/17 18:19:00 rita_borgo
|
2005-09-20 12:15:27 +02:00
|
|
|
Added new routines.
|
|
|
|
Self-intersection first release
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
Revision 1.2 2005/01/03 16:13:09 rita_borgo
|
2005-09-20 12:15:27 +02:00
|
|
|
Added Standard comments
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
****************************************************************************/
|
|
|
|
#include <vector>
|
2005-09-30 17:48:46 +02:00
|
|
|
#include <string>
|
2005-09-20 12:15:27 +02:00
|
|
|
#include <stack>
|
|
|
|
using namespace std;
|
|
|
|
#include<vcg/simplex/vertex/vertex.h>
|
|
|
|
#include<vcg/simplex/face/with/afav.h>
|
|
|
|
#include<vcg/simplex/face/topology.h>
|
2005-09-30 17:48:46 +02:00
|
|
|
#include<vcg/simplex/face/pos.h> // mi sembra di averlo aggiunto!
|
2005-09-20 12:15:27 +02:00
|
|
|
#include<vcg/complex/trimesh/base.h>
|
|
|
|
#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>
|
|
|
|
#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>
|
|
|
|
#include "defs.h"
|
2005-09-30 17:48:46 +02:00
|
|
|
string ans;
|
2005-09-20 12:15:27 +02:00
|
|
|
using namespace vcg;
|
|
|
|
using namespace tri;
|
|
|
|
using namespace face;
|
2005-09-30 17:48:46 +02:00
|
|
|
int prova1;
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
class MyFace;
|
|
|
|
class MyEdge;
|
2005-09-30 17:48:46 +02:00
|
|
|
class MyVertex : public Vertex<float,MyEdge,MyFace>{};
|
2005-09-20 12:15:27 +02:00
|
|
|
class MyFace :public FaceAFAV<MyVertex,MyEdge,MyFace>{};
|
|
|
|
class MyMesh: public tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace > >{};
|
2005-09-30 17:48:46 +02:00
|
|
|
typedef MyMesh::VertexPointer VertexPointer;
|
|
|
|
typedef MyMesh::VertexIterator VertexIterator;
|
2005-09-28 15:57:09 +02:00
|
|
|
typedef Point3<MyMesh::ScalarType> Point3x;
|
|
|
|
typedef vector<Point3x> Hole;
|
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
void OpenMesh(const char *filename, MyMesh &m)
|
|
|
|
{
|
2005-09-29 16:48:15 +02:00
|
|
|
int err = tri::io::Importer<MyMesh>::Open(m,filename);
|
2005-09-30 17:48:46 +02:00
|
|
|
if(err){
|
2005-09-29 16:48:15 +02:00
|
|
|
printf("Error in reading %s: '%s'\n",filename,tri::io::Importer<MyMesh>::ErrorMsg(err));
|
|
|
|
exit(-1);
|
|
|
|
}
|
2005-09-30 17:48:46 +02:00
|
|
|
printf("read mesh `%s'\n", filename);
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
inline char* GetExtension(char* filename)
|
|
|
|
{
|
2005-09-29 16:48:15 +02:00
|
|
|
for(int i=strlen(filename)-1; i >= 0; i--)
|
|
|
|
if(filename[i] == '.')
|
|
|
|
break;
|
|
|
|
if(i > 0)
|
|
|
|
return &(filename[i+1]);
|
|
|
|
else
|
|
|
|
return NULL;
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
2005-09-30 17:48:46 +02:00
|
|
|
typedef MyMesh::VertexPointer VertexPointer;
|
|
|
|
typedef MyMesh::VertexIterator VertexIterator;
|
2005-09-20 12:15:27 +02:00
|
|
|
/* classe di confronto per l'algoritmo di individuazione vertici duplicati*/
|
|
|
|
template <class VertexIterator>
|
|
|
|
class DuplicateVert_Compare{
|
|
|
|
public:
|
|
|
|
inline bool operator() (VertexIterator a, VertexIterator b)
|
2005-09-29 16:48:15 +02:00
|
|
|
{
|
|
|
|
return *a < *b;
|
|
|
|
}
|
2005-09-20 12:15:27 +02:00
|
|
|
};
|
2005-09-30 17:48:46 +02:00
|
|
|
static int DuplicateVertex( MyMesh & m )// V1.0
|
|
|
|
{if(m.vert.size()==0 || m.vn==0)
|
|
|
|
return 0;
|
|
|
|
std::map<VertexPointer, VertexPointer> mp;
|
|
|
|
int i,j;
|
|
|
|
VertexIterator vi;
|
|
|
|
int deleted=0;
|
|
|
|
int k=0;
|
|
|
|
int num_vert = m.vert.size();
|
|
|
|
vector<VertexPointer> perm(num_vert);
|
|
|
|
for(vi=m.vert.begin(); vi!=m.vert.end(); ++vi, ++k)
|
|
|
|
perm[k] = &(*vi);
|
|
|
|
DuplicateVert_Compare<VertexPointer> c_obj;
|
|
|
|
std::sort(perm.begin(),perm.end(),c_obj);
|
|
|
|
j = 0;
|
|
|
|
i = j;
|
|
|
|
mp[perm[i]] = perm[j];
|
|
|
|
++i;
|
|
|
|
for(;i!=num_vert;)
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
if( (! (*perm[i]).IsD()) &&
|
|
|
|
(! (*perm[j]).IsD()) &&
|
|
|
|
(*perm[i]).P() == (*perm[j]).cP() )
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
if(deleted ==0)
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
cout<< "\t Found Duplicated Vertices"<< endl;
|
|
|
|
cout<< "\t do you want to remove them? [y/Y| n/N]\n";
|
|
|
|
cin>>ans;
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
2005-09-30 17:48:46 +02:00
|
|
|
if((ans == "s") ||(ans=="S"))
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
VertexPointer t = perm[i];
|
|
|
|
mp[perm[i]] = perm[j];
|
|
|
|
(*t).SetD();
|
|
|
|
m.vn--;
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
2005-09-30 17:48:46 +02:00
|
|
|
++i;
|
|
|
|
deleted++;// per evitare che su risposta no rifaccia la domanda ad ogni vertice che incontra;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
j = i;
|
|
|
|
++i;
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
}
|
2005-09-30 17:48:46 +02:00
|
|
|
ans.clear();
|
|
|
|
return deleted;
|
|
|
|
}
|
2005-09-30 16:13:01 +02:00
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
void main(int argc,char ** argv){
|
|
|
|
MyMesh m;
|
2005-09-30 17:48:46 +02:00
|
|
|
bool DEBUG=false;
|
|
|
|
|
2005-09-30 16:13:01 +02:00
|
|
|
int j;
|
|
|
|
j=0;
|
2005-09-30 17:48:46 +02:00
|
|
|
|
|
|
|
/*------------XML file part ------------------*/static char* XML_SCHEMA_NAME = "protegekb";
|
|
|
|
XMLTree doc;
|
2005-09-20 12:15:27 +02:00
|
|
|
MainNode* mn = new MainNode;
|
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-30 17:48:46 +02:00
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
//load the mesh
|
|
|
|
//argv[1]=(char*)"c:\\checkup\\debug\\column1m.ply";
|
|
|
|
//argv[1] = "C:\\sf\\apps\\msvc\\trimeshinfo\\Release\\prism.off";
|
2005-09-29 16:48:15 +02:00
|
|
|
//argv[1] = "C:\\sf\\apps\\msvc\\trimeshinfo\\Release\\prova1.ply";
|
|
|
|
|
|
|
|
// print program info
|
|
|
|
printf("-------------------------------\n"
|
2005-09-30 17:48:46 +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-09-30 17:48:46 +02:00
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
if(DEBUG)
|
2005-09-30 15:29:40 +02:00
|
|
|
argv[1] = "C:\\sf\\apps\\msvc\\trimeshinfo\\Release\\tests\\kite_hole3.ply";
|
2005-09-29 16:48:15 +02:00
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// load input meshes.
|
|
|
|
if(argc <= 1)
|
|
|
|
{
|
|
|
|
printf(MSG_ERR_N_ARGS);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}
|
2005-09-30 17:48:46 +02:00
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
OpenMesh(argv[1],m);
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
|
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-09-28 12:46:04 +02:00
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
/*------------XML file part ------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
doc.initializeMain(XML_SCHEMA_NAME);
|
|
|
|
char* s1 = "http://www.w3.org/2001/XMLSchema-instance";
|
|
|
|
char* s2 = new(char[50]);
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s2,"\"%s\"",s1);
|
2005-09-20 12:15:27 +02:00
|
|
|
doc.addHeaders(" xmlns:xsi=", s2);
|
|
|
|
s1 = "http://protege.stanford.edu/plugins/xmlbackend/protege_xml_backend.xsd";
|
|
|
|
s2 = new(char[100]);
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s2,"\"%s\"",s1);
|
2005-09-20 12:15:27 +02:00
|
|
|
doc.addHeaders(" xsi:noNamespaceSchemaLocation=", s2);
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
FILE * index;
|
2005-09-20 12:15:27 +02:00
|
|
|
index = fopen((string(argv[1])+string("2.html")).c_str(),"w");
|
|
|
|
fprintf(index,"<p>Mesh info: %s </p>\n\n\n", argv[1]);
|
2005-09-29 16:48:15 +02:00
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
fprintf(index,"<p>GENERAL INFO </p>\n\n");
|
|
|
|
fprintf(index,"<p>Number of vertices: %d </p>\n", m.vn);
|
|
|
|
fprintf(index,"<p>Number of faces: %d </p>\n", m.fn);
|
|
|
|
printf("Mesh info:\n");
|
2005-09-30 17:48:46 +02:00
|
|
|
printf(" M: '%s'\n\t Number of vertices: %d \n", argv[1], m.vn);
|
2005-09-20 12:15:27 +02:00
|
|
|
printf("\t Number of faces: %d \n", m.fn);
|
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
NodeGroup* ng = new NodeGroup;
|
|
|
|
|
|
|
|
char* s =new(char[25]);
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%d",m.vn);
|
2005-09-20 12:15:27 +02:00
|
|
|
ValueNode* vn = new ValueNode;
|
|
|
|
EntryNode* en = new EntryNode;
|
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "Integer";
|
|
|
|
OwnSlotNode* osn = new OwnSlotNode;
|
|
|
|
osn->setName("Number of Vertices");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
SlotNode* sn = new SlotNode;
|
|
|
|
sn->addOwnSlot(osn);
|
|
|
|
ng->addNode(osn);
|
2005-09-29 16:48:15 +02:00
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
s = new(char[25]);
|
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%d",m.fn);
|
2005-09-20 12:15:27 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "Integer";
|
|
|
|
|
|
|
|
osn->setName("Number of Faces");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
|
|
|
ng->addNode(osn);
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
if(m.HasPerFaceColor()||m.HasPerVertexColor())
|
|
|
|
{
|
|
|
|
Color4b Color=m.C();
|
|
|
|
fprintf(index, "<p>Object color(4b): %f %f %f </p>\n\n", Color[0], Color[1], Color[2]);
|
|
|
|
printf( "\t Object color(4b): %f %f %f \n", Color[0], Color[1], Color[2]);
|
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
/*------------XML file part ------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
s = new(char[25]);
|
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%f %f %f ",Color[0], Color[1], Color[2]);
|
2005-09-20 12:15:27 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "Float";
|
|
|
|
|
|
|
|
osn->setName("Colors");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
|
|
|
ng->addNode(osn);
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
vcg::tri::UpdateTopology<MyMesh>::FaceFace(m);
|
2005-09-28 12:46:04 +02:00
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
// IS MANIFOLD
|
2005-09-28 15:57:09 +02:00
|
|
|
MyMesh::FaceIterator fi;
|
|
|
|
MyMesh::FaceIterator gi;
|
2005-09-20 12:15:27 +02:00
|
|
|
vcg::face::Pos<MyMesh::FaceType> he;
|
|
|
|
vcg::face::Pos<MyMesh::FaceType> hei;
|
2005-09-30 17:48:46 +02:00
|
|
|
|
|
|
|
for(fi=m.face.begin();fi!=m.face.end();fi++)
|
|
|
|
{
|
|
|
|
(*fi).ClearB(0);
|
|
|
|
(*fi).ClearB(1);
|
|
|
|
(*fi).ClearB(2);
|
2005-09-28 15:57:09 +02:00
|
|
|
(*fi).ClearS();
|
2005-09-30 17:48:46 +02:00
|
|
|
}
|
2005-09-30 15:29:40 +02:00
|
|
|
int cf=0;
|
2005-09-30 16:13:01 +02:00
|
|
|
bool Manifold=true;
|
2005-09-30 17:48:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2005-09-28 15:57:09 +02:00
|
|
|
for(fi=m.face.begin();fi!=m.face.end();++fi)
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-30 15:29:40 +02:00
|
|
|
for (j=0;j<3;j++)
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-28 15:57:09 +02:00
|
|
|
if(!IsManifold(*fi,j))
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
|
|
|
Manifold = false;
|
2005-09-28 15:57:09 +02:00
|
|
|
fi= m.face.end();
|
|
|
|
--fi;
|
2005-09-20 12:15:27 +02:00
|
|
|
j=3;
|
|
|
|
}
|
2005-09-30 17:48:46 +02:00
|
|
|
}
|
|
|
|
if((BorderCount(*fi)>0))
|
|
|
|
{
|
|
|
|
Manifold = false;
|
|
|
|
fi= m.face.end();
|
|
|
|
--fi;
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
}
|
2005-09-30 15:29:40 +02:00
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
if (!Manifold)
|
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
fprintf(index, "<p> Manifold: NO </p>");
|
2005-09-29 16:48:15 +02:00
|
|
|
printf( "\t Manifold: NO\n");
|
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
s = new(char[25]);
|
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
|
|
|
s = "No";
|
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "Bool";
|
|
|
|
|
|
|
|
osn->setName("Manifold");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
|
|
|
ng->addNode(osn);
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
fprintf(index, "<p> Manifold: YES </p>");
|
2005-09-29 16:48:15 +02:00
|
|
|
printf( "\t Manifold: YES\n ");
|
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
s = new(char[25]);
|
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
|
|
|
s = "Yes";
|
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "Bool";
|
|
|
|
|
|
|
|
osn->setName("Manifold");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
|
|
|
ng->addNode(osn);
|
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
|
|
|
|
int count_e = 0;
|
2005-09-28 15:57:09 +02:00
|
|
|
int boundary_e = 0;
|
|
|
|
bool counted =false;
|
|
|
|
for(fi=m.face.begin();fi!=m.face.end();fi++)
|
2005-09-29 16:48:15 +02:00
|
|
|
{
|
|
|
|
(*fi).SetS();
|
2005-09-30 17:48:46 +02:00
|
|
|
count_e +=3; //assume that we have to increase the number of edges with three
|
2005-09-30 15:29:40 +02:00
|
|
|
for(j=0; j<3; j++)
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
if (fi->IsBorder(j)) //If this edge is a border edge
|
|
|
|
boundary_e++; // then increase the number of boundary edges
|
|
|
|
else if (IsManifold(*fi,j))//If this edge is manifold
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-29 16:48:15 +02:00
|
|
|
if((*fi).FFp(j)->IsS()) //If the face on the other side of the edge is already selected
|
2005-09-30 17:48:46 +02:00
|
|
|
count_e--; // we counted one edge twice
|
2005-09-29 16:48:15 +02:00
|
|
|
}
|
2005-09-30 17:48:46 +02:00
|
|
|
else//We have a non-manifold edge
|
2005-09-29 16:48:15 +02:00
|
|
|
{
|
|
|
|
hei.Set(&(*fi), j , fi->V(j));
|
|
|
|
he=hei;
|
|
|
|
he.NextF();
|
2005-09-30 17:48:46 +02:00
|
|
|
while (he.f!=hei.f)// so we have to iterate all faces that are connected to this edge
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
if (he.f->IsS())// if one of the other faces was already visited than this edge was counted already.
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-29 16:48:15 +02:00
|
|
|
counted=true;
|
|
|
|
break;
|
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-09-29 16:48:15 +02:00
|
|
|
he.NextF();
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
}
|
2005-09-29 16:48:15 +02:00
|
|
|
if (counted)
|
|
|
|
{
|
|
|
|
count_e--;
|
|
|
|
counted=false;
|
|
|
|
}
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
2005-09-29 16:48:15 +02:00
|
|
|
}
|
2005-09-30 17:48:46 +02:00
|
|
|
}
|
2005-09-29 16:48:15 +02:00
|
|
|
fprintf(index, "<p>Number of edges: %d </p>\n", count_e);
|
|
|
|
fprintf(index, "<p>Number of internal edges: %d </p>\n", count_e-boundary_e);
|
|
|
|
fprintf(index, "<p>Number of boundary edges: %i </p>\n", 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]);
|
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%d",count_e);
|
2005-09-29 16:48:15 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "Integer";
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
osn->setName("Number of Edges");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
|
|
|
ng->addNode(osn);
|
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DEGENERATED FACES
|
|
|
|
|
|
|
|
int count_fd = 0;
|
|
|
|
for(fi=m.face.begin(); fi!=m.face.end();++fi)
|
|
|
|
if((*fi).Area() == 0)
|
|
|
|
count_fd++;
|
|
|
|
fprintf(index, "<p>Number of degenerated faces: %d </p>\n", count_fd);
|
2005-09-29 16:48:15 +02:00
|
|
|
printf("\t Number of degenerated faces: %d \n", count_fd);
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
s = new(char[25]);
|
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%d",count_fd);
|
2005-09-29 16:48:15 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "Integer";
|
|
|
|
|
|
|
|
osn->setName("Number of Degenerated Faces");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
|
|
|
ng->addNode(osn);
|
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
// UNREFERENCED VERTEX
|
|
|
|
|
|
|
|
int count_uv = 0;
|
|
|
|
MyMesh::VertexIterator v;
|
2005-09-29 16:48:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
for(v=m.vert.begin();v!=m.vert.end();++v)
|
|
|
|
(*v).ClearV();
|
|
|
|
|
2005-09-28 15:57:09 +02:00
|
|
|
for(fi=m.face.begin();fi!=m.face.end();++fi)
|
2005-09-29 16:48:15 +02:00
|
|
|
for(j=0;j<3;++j)
|
|
|
|
(*fi).V(j)->SetV();
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
for(v=m.vert.begin();v!=m.vert.end();++v)
|
|
|
|
if( !(*v).IsV() )
|
|
|
|
++count_uv;
|
|
|
|
fprintf(index,"<p>Number of unreferenced vertices: %d</p>\n",count_uv);
|
2005-09-29 16:48:15 +02:00
|
|
|
printf("\t Number of unreferenced vertices: %d\n",count_uv);
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
s = new(char[25]);
|
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%d",count_uv);
|
2005-09-29 16:48:15 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "Integer";
|
|
|
|
|
|
|
|
osn->setName("Number of unreferenced vertices");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
2005-09-30 17:48:46 +02:00
|
|
|
ng->addNode(osn);
|
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-09-28 15:57:09 +02:00
|
|
|
int numholes=0;
|
|
|
|
int numholev=0;
|
2005-09-30 17:48:46 +02:00
|
|
|
int BEdges=0;
|
2005-09-28 15:57:09 +02:00
|
|
|
vector<vector<Point3x> > holes; //indices of vertices
|
|
|
|
|
|
|
|
for(fi=m.face.begin();fi!=m.face.end();++fi)
|
|
|
|
(*fi).ClearS();
|
|
|
|
gi=m.face.begin(); fi=gi;
|
2005-09-29 16:48:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
if (Manifold)
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
for(fi=m.face.begin();fi!=m.face.end();fi++)//for all faces do
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
for(j=0;j<3;j++)//for all edges
|
2005-09-29 16:48:15 +02:00
|
|
|
{
|
|
|
|
if(fi->V(j)->IsS()) continue;
|
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
if((*fi).IsBorder(j))//found an unvisited border edge
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
he.Set(&(*fi),j,fi->V(j)); //set the face-face iterator to the current face, edge and vertex
|
|
|
|
vector<Point3x> hole; //start of a new hole
|
|
|
|
hole.push_back(fi->P(j)); // including the first vertex
|
2005-09-29 16:48:15 +02:00
|
|
|
numholev++;
|
2005-09-30 17:48:46 +02:00
|
|
|
he.v->SetS(); //set the current vertex as selected
|
|
|
|
he.NextB(); //go to the next boundary edge
|
2005-09-28 15:57:09 +02:00
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
while(fi->V(j) != he.v)//will we do not encounter the first boundary edge.
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
Point3x newpoint = he.v->P(); //select its vertex.
|
|
|
|
if(he.v->IsS())//check if this vertex was selected already, because then we have an additional hole.
|
2005-09-29 16:48:15 +02:00
|
|
|
{
|
|
|
|
//cut and paste the additional hole.
|
2005-09-30 17:48:46 +02:00
|
|
|
vector<Point3x> hole2;
|
2005-09-29 16:48:15 +02:00
|
|
|
int index = find(hole.begin(),hole.end(),newpoint) - hole.begin();
|
|
|
|
for(int i=index; i<hole.size(); i++)
|
|
|
|
hole2.push_back(hole[i]);
|
|
|
|
|
|
|
|
hole.resize(index);
|
2005-09-30 17:48:46 +02:00
|
|
|
if(hole2.size()!=0) //annoying in degenerate cases
|
|
|
|
holes.push_back(hole2);
|
2005-09-29 16:48:15 +02:00
|
|
|
}
|
|
|
|
hole.push_back(newpoint);
|
2005-09-28 15:57:09 +02:00
|
|
|
numholev++;
|
2005-09-30 17:48:46 +02:00
|
|
|
he.v->SetS(); //set the current vertex as selected
|
|
|
|
he.NextB(); //go to the next boundary edge
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
2005-09-29 16:48:15 +02:00
|
|
|
holes.push_back(hole);
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
2005-09-29 16:48:15 +02:00
|
|
|
}
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
2005-09-28 15:57:09 +02:00
|
|
|
numholes = holes.size();
|
2005-09-30 17:48:46 +02:00
|
|
|
fprintf(index,"<p>Number of holes/boundaries: %d </p>\n", numholes);
|
|
|
|
printf("\t Number of holes/boundaries: %d \n", numholes);
|
2005-09-29 16:48:15 +02:00
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
s = new(char[25]);
|
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%d",numholes);
|
2005-09-20 12:15:27 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "Integer";
|
|
|
|
|
|
|
|
osn->setName("Number of Holes");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
2005-09-30 17:48:46 +02:00
|
|
|
ng->addNode(osn);
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
|
2005-09-28 15:57:09 +02:00
|
|
|
if(numholes>0)
|
|
|
|
{
|
|
|
|
int BEdges = 0;
|
|
|
|
printf("\t Edges per hole/boundary:\n\t (");
|
|
|
|
for(int i=0; i<numholes; i++)
|
|
|
|
{
|
|
|
|
if(i==numholes-1){ printf("%i)\n",holes[i].size()); BEdges++;}
|
|
|
|
else{ printf("%i, ",holes[i].size()); BEdges++;}
|
|
|
|
}
|
2005-09-29 16:48:15 +02:00
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
2005-09-28 15:57:09 +02:00
|
|
|
s = new(char[25]);
|
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%d",BEdges);
|
2005-09-28 15:57:09 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "Integer";
|
|
|
|
osn->setName("Number of Border Edges");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
2005-09-30 17:48:46 +02:00
|
|
|
ng->addNode(osn);
|
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-09-28 15:57:09 +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-09-20 12:15:27 +02:00
|
|
|
// Mesh Volume
|
|
|
|
float vol = m.Volume();
|
|
|
|
int nuh = numholes;
|
|
|
|
if((m.Volume()>0.)&&(Manifold)&&(numholes==0))
|
|
|
|
{
|
2005-09-29 16:48:15 +02:00
|
|
|
fprintf(index,"<p>Volume: %d </p>\n", m.Volume());
|
|
|
|
printf("\t Volume: %f \n", m.Volume());
|
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
s = new(char[25]);
|
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%f",m.Volume());
|
2005-09-20 12:15:27 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "Float";
|
|
|
|
|
|
|
|
osn->setName("Volume");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
2005-09-30 17:48:46 +02:00
|
|
|
ng->addNode(osn);
|
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-29 16:48:15 +02:00
|
|
|
fprintf(index,"Volume: UNDEFINED, mesh is either non-manifold or has holes \n");
|
2005-09-28 15:57:09 +02:00
|
|
|
}
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
// CONNECTED COMPONENTS
|
|
|
|
|
2005-09-28 15:57:09 +02:00
|
|
|
vector<int> nrfaces;
|
2005-09-30 17:48:46 +02:00
|
|
|
nrfaces.reserve(1);
|
2005-09-28 15:57:09 +02:00
|
|
|
for(fi=m.face.begin();fi!=m.face.end();++fi)
|
|
|
|
(*fi).ClearS();
|
|
|
|
gi=m.face.begin(); fi=gi;
|
|
|
|
int Compindex=0;
|
2005-09-30 17:48:46 +02:00
|
|
|
stack<MyMesh::FaceIterator> sf;
|
2005-09-20 12:15:27 +02:00
|
|
|
MyMesh::FaceType *l;
|
2005-09-28 15:57:09 +02:00
|
|
|
for(fi=m.face.begin();fi!=m.face.end();++fi)
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-28 15:57:09 +02:00
|
|
|
if (!(*fi).IsS())
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-28 15:57:09 +02:00
|
|
|
(*fi).SetS();
|
2005-09-30 17:48:46 +02:00
|
|
|
//(*fi).Q()=Compindex;
|
2005-09-28 15:57:09 +02:00
|
|
|
nrfaces.push_back(1);
|
|
|
|
sf.push(fi);
|
2005-09-20 12:15:27 +02:00
|
|
|
while (!sf.empty())
|
|
|
|
{
|
2005-09-28 15:57:09 +02:00
|
|
|
gi=sf.top();
|
|
|
|
he.Set(&(*gi),0,gi->V(0));
|
2005-09-20 12:15:27 +02:00
|
|
|
sf.pop();
|
|
|
|
for(j=0;j<3;++j)
|
2005-09-28 15:57:09 +02:00
|
|
|
{
|
2005-09-29 16:48:15 +02:00
|
|
|
if( !(*gi).IsBorder(j) )
|
|
|
|
{
|
|
|
|
l=he.f->FFp(j);
|
|
|
|
if( !(*l).IsS() )
|
|
|
|
{
|
|
|
|
(*l).SetS();
|
|
|
|
sf.push(l);
|
|
|
|
}
|
|
|
|
}
|
2005-09-28 15:57:09 +02:00
|
|
|
}
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
2005-09-29 16:48:15 +02:00
|
|
|
Compindex++;
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
}
|
2005-09-28 15:57:09 +02:00
|
|
|
int numcomponents = nrfaces.size();
|
2005-09-30 17:48:46 +02:00
|
|
|
fprintf(index, "<p> Number of connected components: %d </p>", numcomponents);
|
|
|
|
printf("\t Number of connected components: %d\n", numcomponents);
|
2005-09-29 16:48:15 +02:00
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
s = new(char[25]);
|
2005-09-29 16:48:15 +02:00
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%d",numcomponents);
|
2005-09-29 16:48:15 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "Integer";
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
osn->setName("Number of Connected Components");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
|
|
|
ng->addNode(osn);
|
|
|
|
/*--------------------------------------------*/
|
2005-09-28 15:57:09 +02:00
|
|
|
|
2005-09-30 17:48:46 +02:00
|
|
|
//GENUS --> 2( #components - genus ) = #vertices + #faces - #edge - #boundary_loops = eulernumber - #holes
|
2005-09-28 15:57:09 +02:00
|
|
|
//eulero = (mesh.vn-count_uv) - (count_e)+mesh.fn;
|
|
|
|
|
|
|
|
int eulernumber = (m.vn-count_uv) + m.fn - count_e;
|
|
|
|
if(Manifold)
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-28 15:57:09 +02:00
|
|
|
int genus = -( 0.5 * (eulernumber - numholes) - numcomponents );
|
2005-09-30 17:48:46 +02:00
|
|
|
fprintf(index, "<p> Genus: %d </p> \n ", genus);
|
2005-09-28 15:57:09 +02:00
|
|
|
printf( "\t Genus: %d \n", genus);
|
2005-09-29 16:48:15 +02:00
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
2005-09-28 15:57:09 +02:00
|
|
|
s = new(char[25]);
|
2005-09-20 12:15:27 +02:00
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%d",genus);
|
2005-09-20 12:15:27 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "Integer";
|
|
|
|
|
|
|
|
osn->setName("Genus");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
2005-09-30 17:48:46 +02:00
|
|
|
ng->addNode(osn);
|
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-09-28 15:57:09 +02:00
|
|
|
{
|
|
|
|
fprintf( index,"<p>Genus: UNDEFINED, mesh is non-manifold </p>\n");
|
2005-09-30 17:48:46 +02:00
|
|
|
printf( "\t Genus: UNDEFINED, mesh is non-manifold \n");
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
2005-09-29 16:48:15 +02:00
|
|
|
// REGULARITY
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
bool Regular=true;
|
|
|
|
bool Semiregular=true;
|
|
|
|
int inc=0;
|
|
|
|
for(v=m.vert.begin();v!=m.vert.end();++v)
|
|
|
|
(*v).ClearS();
|
2005-09-28 15:57:09 +02:00
|
|
|
for(fi=m.face.begin();fi!=m.face.end();++fi)
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
|
|
|
for (j=0; j<3; j++)
|
|
|
|
{
|
2005-09-28 15:57:09 +02:00
|
|
|
he.Set(&(*fi),j,fi->V(j));
|
|
|
|
if (!(*fi).IsBorder(j) && !(*fi).IsBorder((j+2)%3) && !fi->V(j)->IsS())
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
|
|
|
hei=he;
|
|
|
|
inc=1;
|
|
|
|
he.FlipE();
|
|
|
|
he.NextF();
|
|
|
|
while (he.f!=hei.f)
|
|
|
|
{
|
|
|
|
he.FlipE();
|
|
|
|
if (he.IsBorder())
|
|
|
|
{
|
|
|
|
inc=6;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
he.NextF();
|
|
|
|
inc++;
|
|
|
|
}
|
|
|
|
if (inc!=6)
|
|
|
|
Regular=false;
|
|
|
|
if (inc!=6 && inc!=5)
|
|
|
|
Semiregular=false;
|
2005-09-28 15:57:09 +02:00
|
|
|
fi->V(j)->SetS();
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
2005-09-28 15:57:09 +02:00
|
|
|
fi->V(j)->SetS();
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
if (Semiregular==false)
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Regular)
|
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
fprintf(index, "<p> Type of Mesh: REGULAR</p>");
|
|
|
|
printf("\t Type of Mesh: REGULAR\n");
|
2005-09-29 16:48:15 +02:00
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
s = new(char[25]);
|
2005-09-20 12:15:27 +02:00
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
s="REGULAR";
|
2005-09-20 12:15:27 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "String";
|
|
|
|
|
|
|
|
osn->setName("Type of Mesh");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
2005-09-29 16:48:15 +02:00
|
|
|
ng->addNode(osn);
|
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
else if (Semiregular)
|
|
|
|
{
|
2005-09-29 16:48:15 +02:00
|
|
|
fprintf(index, "<p> Type of Mesh: SEMIREGULAR</p>");
|
|
|
|
printf("\t Type of Mesh: SEMIREGULAR\n");
|
|
|
|
s = new(char[25]);
|
2005-09-20 12:15:27 +02:00
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
s="SEMIREGULAR";
|
2005-09-20 12:15:27 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "String";
|
|
|
|
|
|
|
|
osn->setName("Type of Mesh");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
2005-09-30 17:48:46 +02:00
|
|
|
ng->addNode(osn);
|
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-09-30 17:48:46 +02:00
|
|
|
fprintf(index, "<p> Type of Mesh: IRREGULAR</p>");
|
|
|
|
printf("\t Type of Mesh: IRREGULAR\n");
|
2005-09-29 16:48:15 +02:00
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
s = new(char[25]);
|
2005-09-20 12:15:27 +02:00
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
s="IRREGULAR";
|
2005-09-20 12:15:27 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "String";
|
|
|
|
|
|
|
|
osn->setName("Type of Mesh");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
2005-09-30 17:48:46 +02:00
|
|
|
ng->addNode(osn);
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
2005-09-29 16:48:15 +02:00
|
|
|
// ORIENTABLE E ORIENTED MESH
|
2005-09-20 12:15:27 +02:00
|
|
|
|
|
|
|
bool Orientable=true;
|
|
|
|
bool Oriented=true;
|
|
|
|
if (!Manifold)
|
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
fprintf(index, "<p> Orientable Mesh: NO</p>");
|
|
|
|
printf( "\t Orientable Mesh: NO\n");
|
2005-09-29 16:48:15 +02:00
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
s = new(char[25]);
|
2005-09-20 12:15:27 +02:00
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
s="NO";
|
2005-09-20 12:15:27 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "String";
|
|
|
|
|
|
|
|
osn->setName("Orientable Mesh");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
2005-09-30 17:48:46 +02:00
|
|
|
ng->addNode(osn);
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-09-28 15:57:09 +02:00
|
|
|
for(fi=m.face.begin();fi!=m.face.end();++fi)
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-28 15:57:09 +02:00
|
|
|
(*fi).ClearS();
|
|
|
|
(*fi).ClearUserBit(0);
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
2005-09-30 17:48:46 +02:00
|
|
|
gi=m.face.begin(); fi=gi;
|
2005-09-28 15:57:09 +02:00
|
|
|
for(fi=m.face.begin();fi!=m.face.end();++fi)
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-28 15:57:09 +02:00
|
|
|
if (!(*fi).IsS())
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-28 15:57:09 +02:00
|
|
|
(*fi).SetS();
|
|
|
|
sf.push(fi);
|
2005-09-29 16:48:15 +02:00
|
|
|
|
2005-09-20 12:15:27 +02:00
|
|
|
while (!sf.empty())
|
|
|
|
{
|
2005-09-28 15:57:09 +02:00
|
|
|
gi=sf.top();
|
2005-09-20 12:15:27 +02:00
|
|
|
sf.pop();
|
|
|
|
for(j=0;j<3;++j)
|
|
|
|
{
|
2005-09-28 15:57:09 +02:00
|
|
|
if( !(*gi).IsBorder(j) )
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-28 15:57:09 +02:00
|
|
|
he.Set(&(*gi),0,gi->V(0));
|
2005-09-20 12:15:27 +02:00
|
|
|
l=he.f->FFp(j);
|
2005-09-30 17:48:46 +02:00
|
|
|
he.Set(&(*gi),j,gi->V(j));
|
2005-09-20 12:15:27 +02:00
|
|
|
hei.Set(he.f->FFp(j),he.f->FFi(j), (he.f->FFp(j))->V(he.f->FFi(j)));
|
2005-09-28 15:57:09 +02:00
|
|
|
if( !(*gi).IsUserBit(0) )
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
if (he.v!=hei.v)// bene
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
|
|
|
if ((*l).IsS() && (*l).IsUserBit(0))
|
|
|
|
{
|
|
|
|
Orientable=false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (!(*l).IsS())
|
|
|
|
{
|
|
|
|
(*l).SetS();
|
|
|
|
sf.push(l);
|
|
|
|
}
|
2005-09-30 17:48:46 +02:00
|
|
|
}
|
2005-09-20 12:15:27 +02:00
|
|
|
else if (!(*l).IsS())
|
|
|
|
{
|
|
|
|
Oriented=false;
|
|
|
|
(*l).SetS();
|
|
|
|
(*l).SetUserBit(0);
|
|
|
|
sf.push(l);
|
|
|
|
}
|
|
|
|
else if ((*l).IsS() && !(*l).IsUserBit(0))
|
|
|
|
{
|
|
|
|
Orientable=false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-09-30 17:48:46 +02:00
|
|
|
else if (he.v==hei.v)// bene
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
|
|
|
if ((*l).IsS() && (*l).IsUserBit(0))
|
|
|
|
{
|
|
|
|
Orientable=false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (!(*l).IsS())
|
|
|
|
{
|
|
|
|
(*l).SetS();
|
|
|
|
sf.push(l);
|
|
|
|
}
|
2005-09-30 17:48:46 +02:00
|
|
|
}
|
2005-09-20 12:15:27 +02:00
|
|
|
else if (!(*l).IsS())
|
|
|
|
{
|
|
|
|
Oriented=false;
|
|
|
|
(*l).SetS();
|
|
|
|
(*l).SetUserBit(0);
|
|
|
|
sf.push(l);
|
|
|
|
}
|
|
|
|
else if ((*l).IsS() && !(*l).IsUserBit(0))
|
|
|
|
{
|
|
|
|
Orientable=false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!Orientable)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (Orientable)
|
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
fprintf(index, "<p> Orientable Mesh: YES</p>");
|
2005-09-29 16:48:15 +02:00
|
|
|
printf( "\t Orientable Mesh: YES\n");
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
s = new(char[25]);
|
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
s="YES";
|
2005-09-29 16:48:15 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "String";
|
|
|
|
|
|
|
|
osn->setName("Orientable Mesh");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
2005-09-30 17:48:46 +02:00
|
|
|
ng->addNode(osn);
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
fprintf(index, "<p> Orientable Mesh: NO</p>");
|
2005-09-29 16:48:15 +02:00
|
|
|
printf( "\t Orientable Mesh: NO\n");
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
s = new(char[25]);
|
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
|
|
|
s="NO";
|
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "String";
|
|
|
|
|
|
|
|
osn->setName("Orientable Mesh");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
2005-09-30 17:48:46 +02:00
|
|
|
ng->addNode(osn);
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Oriented && Manifold)
|
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
fprintf(index, "<p> Oriented Mesh: YES</p>");
|
|
|
|
printf( "\t Oriented Mesh: YES\n");
|
2005-09-29 16:48:15 +02:00
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
s = new(char[25]);
|
2005-09-20 12:15:27 +02:00
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
s="YES";
|
2005-09-20 12:15:27 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "String";
|
|
|
|
|
|
|
|
osn->setName("Oriented Mesh");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
2005-09-30 17:48:46 +02:00
|
|
|
ng->addNode(osn);
|
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-09-30 17:48:46 +02:00
|
|
|
fprintf(index, "<p> Oriented Mesh: NO</p>");
|
|
|
|
printf( "\t Oriented Mesh: NO\n");
|
2005-09-29 16:48:15 +02:00
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
s = new(char[25]);
|
2005-09-20 12:15:27 +02:00
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
s="NO";
|
2005-09-20 12:15:27 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "String";
|
|
|
|
|
|
|
|
osn->setName("Oriented Mesh");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
2005-09-30 17:48:46 +02:00
|
|
|
ng->addNode(osn);
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-28 12:46:04 +02:00
|
|
|
}
|
2005-09-20 12:15:27 +02:00
|
|
|
int dv = DuplicateVertex(m);
|
|
|
|
if(dv>0)
|
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
fprintf(index, "<p> Duplicated vertices: %d</p>", dv);
|
|
|
|
printf( "\t Number of duplicated vertices found: %d\n",dv);
|
2005-09-29 16:48:15 +02:00
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
2005-09-28 12:46:04 +02:00
|
|
|
s = new(char[25]);
|
2005-09-20 12:15:27 +02:00
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
sprintf(s,"%d",dv);
|
2005-09-20 12:15:27 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "Int";
|
|
|
|
|
|
|
|
osn->setName("Duplicated Vertices");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
2005-09-30 17:48:46 +02:00
|
|
|
ng->addNode(osn);
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
fprintf(index, "<p> Duplicated vertices: NO</p>");
|
2005-09-20 12:15:27 +02:00
|
|
|
printf( "\t Duplicated vertices: NO\n");
|
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
s = new(char[25]);
|
2005-09-20 12:15:27 +02:00
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
s="NO";
|
2005-09-20 12:15:27 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "String";
|
|
|
|
|
|
|
|
osn->setName("Duplicated Vertices");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
2005-09-30 17:48:46 +02:00
|
|
|
ng->addNode(osn);
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
// SELF INTERSECTION
|
|
|
|
if (m.fn<300000)
|
|
|
|
{
|
|
|
|
bool SelfInt=false;
|
2005-09-28 15:57:09 +02:00
|
|
|
for(fi=m.face.begin();fi!=m.face.end();++fi)
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-28 15:57:09 +02:00
|
|
|
for(gi=++fi , fi--;gi!=m.face.end();++gi)
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-28 15:57:09 +02:00
|
|
|
if ((*fi).FFp(0)!=&(*gi) && (*fi).FFp(1)!=&(*gi) && (*fi).FFp(2)!=&(*gi) &&
|
|
|
|
fi->V(0)!=gi->V(0) && fi->V(0)!=gi->V(1) && fi->V(0)!=gi->V(2) &&
|
|
|
|
fi->V(1)!=gi->V(0) && fi->V(1)!=gi->V(1) && fi->V(1)!=gi->V(2) &&
|
|
|
|
fi->V(2)!=gi->V(0) && fi->V(2)!=gi->V(1) && fi->V(2)!=gi->V(2))
|
2005-09-20 12:15:27 +02:00
|
|
|
{
|
2005-09-28 15:57:09 +02:00
|
|
|
if (NoDivTriTriIsect(fi->V(0)->P(), fi->V(1)->P(), fi->V(2)->P(),gi->V(0)->P(), gi->V(1)->P(), gi->V(2)->P()) )
|
2005-09-20 12:15:27 +02:00
|
|
|
SelfInt=true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (SelfInt)
|
2005-09-30 17:48:46 +02:00
|
|
|
break;
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
if (SelfInt)
|
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
fprintf(index, "<p> Self Intersection: YES</p>");
|
2005-09-20 12:15:27 +02:00
|
|
|
printf( "\t Self Intersection: YES\n");
|
2005-09-29 16:48:15 +02:00
|
|
|
|
|
|
|
/*------------XML file part ------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
s = new(char[25]);
|
2005-09-29 16:48:15 +02:00
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
s="YES";
|
2005-09-29 16:48:15 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "String";
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
osn->setName("Self Intersection");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
2005-09-30 17:48:46 +02:00
|
|
|
ng->addNode(osn);
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
fprintf(index, "<p> Self Intersection: NO</p>");
|
|
|
|
printf( "\t Self Intersection: NO\n");
|
2005-09-20 12:15:27 +02:00
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
s = new(char[25]);
|
|
|
|
vn = new ValueNode;
|
|
|
|
en = new EntryNode;
|
|
|
|
osn = new OwnSlotNode;
|
2005-09-30 17:48:46 +02:00
|
|
|
s="NO";
|
2005-09-29 16:48:15 +02:00
|
|
|
vn->setValue(s);
|
|
|
|
en->addValue(*vn);
|
|
|
|
en->type = "String";
|
|
|
|
|
|
|
|
osn->setName("Self Intersection");
|
|
|
|
osn->addEntry(*en);
|
|
|
|
sn->addOwnSlot(osn);
|
2005-09-30 17:48:46 +02:00
|
|
|
ng->addNode(osn);
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
}
|
2005-09-28 12:46:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string fs;
|
2005-09-29 16:48:15 +02:00
|
|
|
|
2005-09-30 15:29:40 +02:00
|
|
|
cout<< "\t To save the file: [s/S]\n\t";
|
2005-09-28 12:46:04 +02:00
|
|
|
cin>>ans;
|
|
|
|
|
|
|
|
|
2005-09-29 16:48:15 +02:00
|
|
|
if((ans == "S")||(ans == "s"))
|
|
|
|
{
|
2005-09-30 15:29:40 +02:00
|
|
|
cout<< "\t available formats: [ply, off, dxf, stl] "<<endl;
|
2005-09-29 16:48:15 +02:00
|
|
|
cout<< "\t enter format"<<endl;
|
|
|
|
cin>>ans;
|
|
|
|
cout<<"\t enter filename"<<endl;
|
|
|
|
cin>>fs;
|
|
|
|
const char* filesave = fs.c_str();
|
|
|
|
if(ans == "ply")
|
|
|
|
tri::io::ExporterPLY<MyMesh>::Save(m, filesave);
|
|
|
|
else if(ans == "stl")
|
|
|
|
tri::io::ExporterSTL<MyMesh>::Save(m,filesave);
|
|
|
|
else if(ans == "dxf")
|
|
|
|
tri::io::ExporterDXF<MyMesh>::Save(m,filesave);
|
|
|
|
|
|
|
|
else if(ans == "off")
|
|
|
|
tri::io::ExporterOFF<MyMesh>::Save(m,filesave);
|
|
|
|
}
|
|
|
|
|
2005-09-30 15:29:40 +02:00
|
|
|
cout<<"\t create XML files? [y/Y|n/N]"<<endl;
|
|
|
|
cin>>ans;
|
|
|
|
if((ans=="Y")||(ans=="y"))
|
|
|
|
{
|
2005-09-30 17:48:46 +02:00
|
|
|
/*------------XML file part ------------------*/
|
|
|
|
doc.addSlots(sn);
|
|
|
|
OwnSlotsNode* ossn = new OwnSlotsNode;
|
|
|
|
ossn->addOwnSlot(ng);
|
|
|
|
ClassNode* cn = new ClassNode;
|
|
|
|
cn->addOwnSlots(ossn);
|
|
|
|
doc.addClasses(cn);
|
|
|
|
|
|
|
|
InstanceNode* in = new InstanceNode;
|
|
|
|
in->addOwnSlots(ossn);
|
|
|
|
doc.addInstances(in);
|
|
|
|
doc.finalizeMain("/",XML_SCHEMA_NAME);
|
|
|
|
doc.printXMLTree();
|
2005-09-30 15:29:40 +02:00
|
|
|
}
|
2005-09-29 16:48:15 +02:00
|
|
|
/*--------------------------------------------*/
|
2005-09-30 15:29:40 +02:00
|
|
|
fclose(index);
|
2005-09-20 12:15:27 +02:00
|
|
|
}
|
|
|
|
|