From 3d46da2cb53a6286f77db0f039d689694086b15f Mon Sep 17 00:00:00 2001 From: granzuglia Date: Mon, 2 Apr 2012 14:47:04 +0000 Subject: [PATCH] unit test function for meshcopy. It uses ftime to get time. --- apps/trimeshcopy/trimeshcopy.cpp | 84 ++++++++++++++++++++++++++++++++ apps/trimeshcopy/trimeshcopy.pro | 12 +++++ 2 files changed, 96 insertions(+) create mode 100644 apps/trimeshcopy/trimeshcopy.cpp create mode 100644 apps/trimeshcopy/trimeshcopy.pro diff --git a/apps/trimeshcopy/trimeshcopy.cpp b/apps/trimeshcopy/trimeshcopy.cpp new file mode 100644 index 00000000..0aa2bd29 --- /dev/null +++ b/apps/trimeshcopy/trimeshcopy.cpp @@ -0,0 +1,84 @@ +#include + +// stuff to define the mesh +#include +#include +#include +#include +// io +#include +#include + +#include + +#include +#include + + +class MyVertex; +class MyEdge; +class MyFace; + +struct MyUsedTypes: public vcg::UsedTypes::AsVertexType,vcg::Use::AsEdgeType,vcg::Use::AsFaceType>{}; + +class MyVertex : public vcg::Vertex< MyUsedTypes,vcg::vertex::VFAdj,vcg::vertex::Coord3f,vcg::vertex::Normal3f,vcg::vertex::Mark,vcg::vertex::BitFlags > +{ +}; + +class MyEdge : public vcg::Edge< MyUsedTypes> {}; + +class MyFace : public vcg::Face< MyUsedTypes, + vcg::face::VFAdj, + vcg::face::VertexRef, + vcg::face::BitFlags > {}; + +// the main mesh class +class MyMesh : public vcg::tri::TriMesh, std::vector > {}; + +void Usage() +{ + printf( + "---------------------------------\n" + " TriMeshCopy V.1.0 \n" + " http://vcg.isti.cnr.it\n" + " http://vcg.sourceforge.net\n" + " release date: "__DATE__"\n" + "---------------------------------\n\n" + "TriMeshCopy 1.0 \n"__DATE__"\n" + "Copyright 2003-2012 Visual Computing Lab I.S.T.I. C.N.R.\n" + "\nUsage: "\ + "trimeshcopy fileIn [fileOut]\n"\ + "trimeshcopy test vcg::MeshCopy efficiency.\nIt imports a fileIn file into a user defined mesh and test how long vcg::MeshCopy needs to copy the imported mesh in a second one.The copy time is expressed in milliseconds.\nA fileOut file can be passed to the tool in order to check if the mesh was successfully copied.\nThe file will be exported in PLY file format.\n" + ); + exit(-1); +} + +int main(int argc ,char**argv) +{ + MyMesh mesh; + if(argc<2) + Usage(); + + timeb start; + timeb end; + ftime(&start); + int err=vcg::tri::io::Importer::Open(mesh,argv[1]); + if(err) + { + std::cerr << "Unable to open mesh " << argv[1] << " : " << vcg::tri::io::Importer::ErrorMsg(err) << std::endl; + exit(-1); + } + ftime(&end); + int loadtime = (end.time * 1000 + end.millitm) - (start.time * 1000 + start.millitm); + std::cout << "mesh loaded in " << loadtime << " msecs. Verts: " << mesh.vn << " Faces: " << mesh.fn << "\n"; + MyMesh mm; + ftime(&start); + vcg::tri::Append::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 == 3) + vcg::tri::io::ExporterPLY::Save(mm,argv[2]); + return 0; +} diff --git a/apps/trimeshcopy/trimeshcopy.pro b/apps/trimeshcopy/trimeshcopy.pro new file mode 100644 index 00000000..26ec8ef1 --- /dev/null +++ b/apps/trimeshcopy/trimeshcopy.pro @@ -0,0 +1,12 @@ + +TARGET = trimeshcopy +DEPENDPATH += ../.. +INCLUDEPATH += . ../.. +CONFIG += console stl debug_and_release +TEMPLATE = app +HEADERS += +SOURCES += trimeshcopy.cpp ../../wrap/ply/plylib.cpp + + +# Mac specific Config required to avoid to make application bundles +CONFIG -= app_bundle