Added possibility of saving File in OFF format
This commit is contained in:
parent
239c1a5260
commit
541c26e601
|
@ -24,6 +24,10 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.1 2005/09/20 10:15:27 rita_borgo
|
||||||
|
Changed file name to uniform with other solution projects,
|
||||||
|
before was main.cpp
|
||||||
|
|
||||||
Revision 1.8 2005/02/15 12:26:06 rita_borgo
|
Revision 1.8 2005/02/15 12:26:06 rita_borgo
|
||||||
Minor changes to self-intersection
|
Minor changes to self-intersection
|
||||||
|
|
||||||
|
@ -66,8 +70,11 @@ using namespace std;
|
||||||
#include <vcg/math/histogram.h>
|
#include <vcg/math/histogram.h>
|
||||||
#include <wrap/io_trimesh/import.h>
|
#include <wrap/io_trimesh/import.h>
|
||||||
#include <wrap/io_trimesh/export_ply.h>
|
#include <wrap/io_trimesh/export_ply.h>
|
||||||
|
#include <wrap/io_trimesh/export_stl.h>
|
||||||
|
#include <wrap/io_trimesh/export_dxf.h>
|
||||||
|
|
||||||
#include "XMLTree.h"
|
#include "XMLTree.h"
|
||||||
|
#include <wrap/io_trimesh/export_off.h>
|
||||||
|
|
||||||
|
|
||||||
// loader
|
// loader
|
||||||
|
@ -85,6 +92,8 @@ class MyVertex:public Vertex<float,MyEdge,MyFace>{};
|
||||||
class MyFace :public FaceAFAV<MyVertex,MyEdge,MyFace>{};
|
class MyFace :public FaceAFAV<MyVertex,MyEdge,MyFace>{};
|
||||||
class MyMesh: public tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace > >{};
|
class MyMesh: public tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace > >{};
|
||||||
|
|
||||||
|
string ans;
|
||||||
|
|
||||||
void OpenMesh(const char *filename, MyMesh &m)
|
void OpenMesh(const char *filename, MyMesh &m)
|
||||||
{
|
{
|
||||||
int err = tri::io::Importer<MyMesh>::Open(m,filename);
|
int err = tri::io::Importer<MyMesh>::Open(m,filename);
|
||||||
|
@ -123,6 +132,7 @@ public:
|
||||||
|
|
||||||
static int DuplicateVertex( MyMesh & m ) // V1.0
|
static int DuplicateVertex( MyMesh & m ) // V1.0
|
||||||
{
|
{
|
||||||
|
|
||||||
if(m.vert.size()==0 || m.vn==0)
|
if(m.vert.size()==0 || m.vn==0)
|
||||||
return 0;
|
return 0;
|
||||||
std::map<VertexPointer, VertexPointer> mp;
|
std::map<VertexPointer, VertexPointer> mp;
|
||||||
|
@ -147,12 +157,22 @@ static int DuplicateVertex( MyMesh & m ) // V1.0
|
||||||
if( (! (*perm[i]).IsD()) &&
|
if( (! (*perm[i]).IsD()) &&
|
||||||
(! (*perm[j]).IsD()) &&
|
(! (*perm[j]).IsD()) &&
|
||||||
(*perm[i]).P() == (*perm[j]).cP() )
|
(*perm[i]).P() == (*perm[j]).cP() )
|
||||||
|
{
|
||||||
|
if(deleted ==0)
|
||||||
|
{
|
||||||
|
cout<< "\t Found Duplicated Vertices"<< endl;
|
||||||
|
cout<< "\t do you want to remove them? [y/Y| n/N]\n";
|
||||||
|
cin>>ans;
|
||||||
|
}
|
||||||
|
if((ans == "s") ||(ans=="S"))
|
||||||
{
|
{
|
||||||
VertexPointer t = perm[i];
|
VertexPointer t = perm[i];
|
||||||
mp[perm[i]] = perm[j];
|
mp[perm[i]] = perm[j];
|
||||||
++i;
|
|
||||||
(*t).SetD();
|
(*t).SetD();
|
||||||
deleted++;
|
m.vn--;
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
deleted++;// per evitare che su risposta no rifaccia la domanda ad ogni vertice che incontra;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -160,14 +180,16 @@ static int DuplicateVertex( MyMesh & m ) // V1.0
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ans.clear();
|
||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
void main(int argc,char ** argv){
|
void main(int argc,char ** argv){
|
||||||
|
|
||||||
char *fmt;
|
|
||||||
MyMesh m;
|
MyMesh m;
|
||||||
bool DEBUG = true;
|
bool DEBUG = true;
|
||||||
|
|
||||||
|
|
||||||
/*------------XML file part ------------------*/
|
/*------------XML file part ------------------*/
|
||||||
|
|
||||||
static char* XML_SCHEMA_NAME = "protegekb";
|
static char* XML_SCHEMA_NAME = "protegekb";
|
||||||
|
@ -190,7 +212,7 @@ void main(int argc,char ** argv){
|
||||||
|
|
||||||
|
|
||||||
if(DEBUG)
|
if(DEBUG)
|
||||||
argv[1] = "C:\\sf\\apps\\msvc\\trimeshinfo\\Release\\cube1.stl";
|
argv[1] = "C:\\sf\\apps\\msvc\\trimeshinfo\\cube.ply";
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -206,6 +228,8 @@ void main(int argc,char ** argv){
|
||||||
OpenMesh(argv[1],m);
|
OpenMesh(argv[1],m);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
doc.initializeMain(XML_SCHEMA_NAME);
|
doc.initializeMain(XML_SCHEMA_NAME);
|
||||||
char* s1 = "http://www.w3.org/2001/XMLSchema-instance";
|
char* s1 = "http://www.w3.org/2001/XMLSchema-instance";
|
||||||
char* s2 = new(char[50]);
|
char* s2 = new(char[50]);
|
||||||
|
@ -260,6 +284,7 @@ void main(int argc,char ** argv){
|
||||||
ng->addNode(osn);
|
ng->addNode(osn);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(m.HasPerFaceColor()||m.HasPerVertexColor())
|
if(m.HasPerFaceColor()||m.HasPerVertexColor())
|
||||||
{
|
{
|
||||||
Color4b Color=m.C();
|
Color4b Color=m.C();
|
||||||
|
@ -411,7 +436,6 @@ void main(int argc,char ** argv){
|
||||||
ng->addNode(osn);
|
ng->addNode(osn);
|
||||||
|
|
||||||
|
|
||||||
// DA QUI IN POI!!!
|
|
||||||
|
|
||||||
// DEGENERATED FACES
|
// DEGENERATED FACES
|
||||||
|
|
||||||
|
@ -931,7 +955,8 @@ void main(int argc,char ** argv){
|
||||||
osn->setName("Oriented Mesh");
|
osn->setName("Oriented Mesh");
|
||||||
osn->addEntry(*en);
|
osn->addEntry(*en);
|
||||||
sn->addOwnSlot(osn);
|
sn->addOwnSlot(osn);
|
||||||
ng->addNode(osn); }
|
ng->addNode(osn);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(index, "<p> Oriented Mesh: NO</p>");
|
fprintf(index, "<p> Oriented Mesh: NO</p>");
|
||||||
|
@ -948,12 +973,13 @@ void main(int argc,char ** argv){
|
||||||
osn->setName("Oriented Mesh");
|
osn->setName("Oriented Mesh");
|
||||||
osn->addEntry(*en);
|
osn->addEntry(*en);
|
||||||
sn->addOwnSlot(osn);
|
sn->addOwnSlot(osn);
|
||||||
ng->addNode(osn); }
|
ng->addNode(osn);
|
||||||
|
}
|
||||||
int dv = DuplicateVertex(m);
|
int dv = DuplicateVertex(m);
|
||||||
if(dv>0)
|
if(dv>0)
|
||||||
{
|
{
|
||||||
fprintf(index, "<p> Duplicated vertices: %d</p>", dv);
|
fprintf(index, "<p> Duplicated vertices: %d</p>", dv);
|
||||||
printf( "\t Duplicated vertices: %d\n",dv);
|
printf( "\t Number of duplicated vertices found: %d\n",dv);
|
||||||
s = new(char[25]);
|
s = new(char[25]);
|
||||||
vn = new ValueNode;
|
vn = new ValueNode;
|
||||||
en = new EntryNode;
|
en = new EntryNode;
|
||||||
|
@ -988,7 +1014,6 @@ void main(int argc,char ** argv){
|
||||||
ng->addNode(osn);
|
ng->addNode(osn);
|
||||||
}
|
}
|
||||||
// SELF INTERSECTION
|
// SELF INTERSECTION
|
||||||
|
|
||||||
if (m.fn<300000)
|
if (m.fn<300000)
|
||||||
{
|
{
|
||||||
bool SelfInt=false;
|
bool SelfInt=false;
|
||||||
|
@ -1045,6 +1070,33 @@ void main(int argc,char ** argv){
|
||||||
ng->addNode(osn);
|
ng->addNode(osn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string fs;
|
||||||
|
|
||||||
|
cout<< "\t To save the file: [s/S]"<< endl;
|
||||||
|
cin>>ans;
|
||||||
|
|
||||||
|
|
||||||
|
if((ans == "S")||(ans == "s"))
|
||||||
|
cout<< "\t available formats: [ply, off, stl] "<<endl;
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
doc.addSlots(sn);
|
doc.addSlots(sn);
|
||||||
OwnSlotsNode* ossn = new OwnSlotsNode;
|
OwnSlotsNode* ossn = new OwnSlotsNode;
|
||||||
ossn->addOwnSlot(ng);
|
ossn->addOwnSlot(ng);
|
||||||
|
|
Loading…
Reference in New Issue