simple reorganization of the testing code

This commit is contained in:
Paolo Cignoni 2012-07-04 13:52:32 +00:00
parent db57bd4e19
commit 4356ed9833
2 changed files with 74 additions and 87 deletions

View File

@ -1,10 +1,11 @@
#include <vcg/complex/append.h>
// stuff to define the mesh // stuff to define the mesh
#include <vcg/simplex/vertex/base.h> #include <vcg/simplex/vertex/base.h>
#include <vcg/simplex/vertex/component_ocf.h>
#include <vcg/simplex/face/base.h> #include <vcg/simplex/face/base.h>
#include <vcg/simplex/edge/base.h> #include <vcg/simplex/edge/base.h>
#include <vcg/complex/complex.h> #include <vcg/complex/complex.h>
#include <vcg/complex/append.h>
// io // io
#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>
@ -86,55 +87,41 @@ void Usage()
exit(-1); exit(-1);
} }
int main(int argc ,char**argv) template <class MeshType>
bool UnitTest_Append(const char *filename1, const char *filename2)
{ {
MyMesh mesh; MeshType mr;
if(argc<3) MeshType ml;
Usage();
timeb start; int startOpen=clock();
timeb end; int err=vcg::tri::io::Importer<MeshType>::Open(mr,filename1);
ftime(&start);
int err=vcg::tri::io::Importer<MyMesh>::Open(mesh,argv[1]);
if(err) if(err)
{ {
std::cerr << "Unable to open mesh " << argv[1] << " : " << vcg::tri::io::Importer<MyMesh>::ErrorMsg(err) << std::endl; std::cerr << "Unable to open mesh " << filename1 << " : " << vcg::tri::io::Importer<MyMesh>::ErrorMsg(err) << std::endl;
exit(-1); exit(-1);
} }
ftime(&end); int endOpen = clock();
int loadtime = (end.time * 1000 + end.millitm) - (start.time * 1000 + start.millitm); std::cout << "mesh loaded in " << float(endOpen-startOpen)/CLOCKS_PER_SEC << " msecs. Verts: " << mr.vn << " Faces: " << mr.fn << "\n";
std::cout << "mesh loaded in " << loadtime << " msecs. Verts: " << mesh.vn << " Faces: " << mesh.fn << "\n";
std::string tmp(argv[2]); int startCopy = clock();
if (tmp == "-n") vcg::tri::Append<MeshType,MeshType>::Mesh(ml,mr,false,true);
int endCopy = clock();
std::cout << "mesh copied in " << float(endCopy-startCopy)/CLOCKS_PER_SEC << " msecs." << std::endl;
assert(ml.vn==mr.vn);
assert(ml.en==mr.en);
assert(ml.fn==mr.fn);
int startSave = clock();
vcg::tri::io::ExporterPLY<MeshType>::Save(ml,filename2);
int endSave = clock();
std::cout << "mesh saved in " << float(endSave-startSave)/CLOCKS_PER_SEC << " msecs." << std::endl;
return true;
}
int main(int argc ,char**argv)
{ {
MyMesh mm; UnitTest_Append<MyMesh>(argv[1],"out.ply");
ftime(&start); UnitTest_Append<OcfMesh>(argv[1],"out.ply");
vcg::tri::Append<MyMesh,MyMesh>::MeshCopy(mm,mesh);
ftime(&end);
int cptime = (end.time * 1000 + end.millitm) - (start.time * 1000 + start.millitm);
std::cout << "mesh copied in " << cptime << " msecs." << std::endl;
if (argc == 4)
vcg::tri::io::ExporterPLY<MyMesh>::Save(mm,argv[3]);
return 0;
}
//if (tmp == "-o")
//{
// OcfMesh ocfm;
// ftime(&start);
// vcg::tri::Append<OcfMesh,MyMesh>::MeshCopy(ocfm,mesh);
// ftime(&end);
// cptime = (end.time * 1000 + end.millitm) - (start.time * 1000 + start.millitm);
// std::cout << "mesh copied in " << cptime << " msecs." << std::endl;
// if (argc == 4)
// vcg::tri::io::ExporterPLY<OcfMesh>::Save(ocfm,argv[3]);
// return 0;
//}
Usage();
return 0; return 0;
} }

View File

@ -1,12 +1,12 @@
TARGET = trimeshcopy TARGET = trimeshcopy
DEPENDPATH += ../.. DEPENDPATH += ../../..
INCLUDEPATH += . ../.. INCLUDEPATH += . ../../..
CONFIG += console stl debug_and_release CONFIG += console stl
TEMPLATE = app TEMPLATE = app
HEADERS += HEADERS +=
SOURCES += trimeshcopy.cpp ../../wrap/ply/plylib.cpp SOURCES += trimeshcopy.cpp ../../../wrap/ply/plylib.cpp
#DEFINES += N_DEBUG
# Mac specific Config required to avoid to make application bundles # Mac specific Config required to avoid to make application bundles
CONFIG -= app_bundle CONFIG -= app_bundle