diff --git a/apps/sample/trimesh_copy/trimeshcopy.cpp b/apps/sample/trimesh_copy/trimeshcopy.cpp index 9863e020..b6dc8ff8 100644 --- a/apps/sample/trimesh_copy/trimeshcopy.cpp +++ b/apps/sample/trimesh_copy/trimeshcopy.cpp @@ -1,10 +1,11 @@ -#include // stuff to define the mesh #include +#include #include #include #include +#include // io #include #include @@ -36,36 +37,36 @@ class MyFace : public vcg::Face< MyUsedTypes, // the main mesh class class MyMesh : public vcg::tri::TriMesh, std::vector > {}; -class OcfVertex; -class OcfEdge; -class OcfFace; - -// Declaration of the semantic of the used types -class OcfUsedTypes: public vcg::UsedTypes < vcg::Use::AsVertexType, - vcg::Use::AsEdgeType, - vcg::Use::AsFaceType >{}; - - -// The Main Vertex Class -// Most of the attributes are optional and must be enabled before use. -// Each vertex needs 40 byte, on 32bit arch. and 44 byte on 64bit arch. - -class OcfVertex : public vcg::Vertex< OcfUsedTypes,vcg::vertex::InfoOcf,vcg::vertex::Coord3f,vcg::vertex::BitFlags,vcg::vertex::Normal3fOcf,vcg::vertex::VFAdjOcf,vcg::vertex::MarkOcf> -{ -}; - - -// The Main Edge Class -// Currently it does not contains anything. -class OcfEdge : public vcg::Edge -{ -}; - -// Each face needs 32 byte, on 32bit arch. and 48 byte on 64bit arch. -class OcfFace : public vcg::Face< OcfUsedTypes,vcg::face::InfoOcf,vcg::face::VertexRef,vcg::face::BitFlags,vcg::face::VFAdjOcf> {}; - -class OcfMesh : public vcg::tri::TriMesh< vcg::vertex::vector_ocf, vcg::face::vector_ocf > -{ +class OcfVertex; +class OcfEdge; +class OcfFace; + +// Declaration of the semantic of the used types +class OcfUsedTypes: public vcg::UsedTypes < vcg::Use::AsVertexType, + vcg::Use::AsEdgeType, + vcg::Use::AsFaceType >{}; + + +// The Main Vertex Class +// Most of the attributes are optional and must be enabled before use. +// Each vertex needs 40 byte, on 32bit arch. and 44 byte on 64bit arch. + +class OcfVertex : public vcg::Vertex< OcfUsedTypes,vcg::vertex::InfoOcf,vcg::vertex::Coord3f,vcg::vertex::BitFlags,vcg::vertex::Normal3fOcf,vcg::vertex::VFAdjOcf,vcg::vertex::MarkOcf> +{ +}; + + +// The Main Edge Class +// Currently it does not contains anything. +class OcfEdge : public vcg::Edge +{ +}; + +// Each face needs 32 byte, on 32bit arch. and 48 byte on 64bit arch. +class OcfFace : public vcg::Face< OcfUsedTypes,vcg::face::InfoOcf,vcg::face::VertexRef,vcg::face::BitFlags,vcg::face::VFAdjOcf> {}; + +class OcfMesh : public vcg::tri::TriMesh< vcg::vertex::vector_ocf, vcg::face::vector_ocf > +{ }; void Usage() @@ -86,55 +87,41 @@ void Usage() exit(-1); } -int main(int argc ,char**argv) -{ - MyMesh mesh; - if(argc<3) - 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"; - - std::string tmp(argv[2]); - if (tmp == "-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 == 4) - vcg::tri::io::ExporterPLY::Save(mm,argv[3]); - return 0; - } - - //if (tmp == "-o") - //{ - // OcfMesh ocfm; - // ftime(&start); - // vcg::tri::Append::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::Save(ocfm,argv[3]); - - // return 0; - //} - - Usage(); - return 0; +template +bool UnitTest_Append(const char *filename1, const char *filename2) +{ + MeshType mr; + MeshType ml; + + int startOpen=clock(); + int err=vcg::tri::io::Importer::Open(mr,filename1); + if(err) + { + std::cerr << "Unable to open mesh " << filename1 << " : " << vcg::tri::io::Importer::ErrorMsg(err) << std::endl; + exit(-1); + } + int endOpen = clock(); + std::cout << "mesh loaded in " << float(endOpen-startOpen)/CLOCKS_PER_SEC << " msecs. Verts: " << mr.vn << " Faces: " << mr.fn << "\n"; + + int startCopy = clock(); + vcg::tri::Append::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::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) +{ + UnitTest_Append(argv[1],"out.ply"); + UnitTest_Append(argv[1],"out.ply"); + return 0; } diff --git a/apps/sample/trimesh_copy/trimeshcopy.pro b/apps/sample/trimesh_copy/trimeshcopy.pro index 26ec8ef1..9ba48680 100644 --- a/apps/sample/trimesh_copy/trimeshcopy.pro +++ b/apps/sample/trimesh_copy/trimeshcopy.pro @@ -1,12 +1,12 @@ TARGET = trimeshcopy -DEPENDPATH += ../.. -INCLUDEPATH += . ../.. -CONFIG += console stl debug_and_release +DEPENDPATH += ../../.. +INCLUDEPATH += . ../../.. +CONFIG += console stl TEMPLATE = app 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 CONFIG -= app_bundle