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>
@ -36,36 +37,36 @@ class MyFace : public vcg::Face< MyUsedTypes,
// the main mesh class // the main mesh class
class MyMesh : public vcg::tri::TriMesh<std::vector<MyVertex>, std::vector<MyFace> > {}; class MyMesh : public vcg::tri::TriMesh<std::vector<MyVertex>, std::vector<MyFace> > {};
class OcfVertex; class OcfVertex;
class OcfEdge; class OcfEdge;
class OcfFace; class OcfFace;
// Declaration of the semantic of the used types // Declaration of the semantic of the used types
class OcfUsedTypes: public vcg::UsedTypes < vcg::Use<OcfVertex>::AsVertexType, class OcfUsedTypes: public vcg::UsedTypes < vcg::Use<OcfVertex>::AsVertexType,
vcg::Use<OcfEdge >::AsEdgeType, vcg::Use<OcfEdge >::AsEdgeType,
vcg::Use<OcfFace >::AsFaceType >{}; vcg::Use<OcfFace >::AsFaceType >{};
// The Main Vertex Class // The Main Vertex Class
// Most of the attributes are optional and must be enabled before use. // 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. // 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> 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 // The Main Edge Class
// Currently it does not contains anything. // Currently it does not contains anything.
class OcfEdge : public vcg::Edge<OcfUsedTypes> class OcfEdge : public vcg::Edge<OcfUsedTypes>
{ {
}; };
// Each face needs 32 byte, on 32bit arch. and 48 byte on 64bit arch. // 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 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<OcfVertex>, vcg::face::vector_ocf<OcfFace> > class OcfMesh : public vcg::tri::TriMesh< vcg::vertex::vector_ocf<OcfVertex>, vcg::face::vector_ocf<OcfFace> >
{ {
}; };
void Usage() void Usage()
@ -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; {
if(argc<3) MeshType mr;
Usage(); MeshType ml;
timeb start; int startOpen=clock();
timeb end; int err=vcg::tri::io::Importer<MeshType>::Open(mr,filename1);
ftime(&start); if(err)
int err=vcg::tri::io::Importer<MyMesh>::Open(mesh,argv[1]); {
if(err) std::cerr << "Unable to open mesh " << filename1 << " : " << vcg::tri::io::Importer<MyMesh>::ErrorMsg(err) << std::endl;
{ exit(-1);
std::cerr << "Unable to open mesh " << argv[1] << " : " << vcg::tri::io::Importer<MyMesh>::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";
ftime(&end);
int loadtime = (end.time * 1000 + end.millitm) - (start.time * 1000 + start.millitm); int startCopy = clock();
std::cout << "mesh loaded in " << loadtime << " msecs. Verts: " << mesh.vn << " Faces: " << mesh.fn << "\n"; vcg::tri::Append<MeshType,MeshType>::Mesh(ml,mr,false,true);
int endCopy = clock();
std::string tmp(argv[2]); std::cout << "mesh copied in " << float(endCopy-startCopy)/CLOCKS_PER_SEC << " msecs." << std::endl;
if (tmp == "-n")
{ assert(ml.vn==mr.vn);
MyMesh mm; assert(ml.en==mr.en);
ftime(&start); assert(ml.fn==mr.fn);
vcg::tri::Append<MyMesh,MyMesh>::MeshCopy(mm,mesh);
ftime(&end); int startSave = clock();
int cptime = (end.time * 1000 + end.millitm) - (start.time * 1000 + start.millitm); vcg::tri::io::ExporterPLY<MeshType>::Save(ml,filename2);
std::cout << "mesh copied in " << cptime << " msecs." << std::endl; int endSave = clock();
std::cout << "mesh saved in " << float(endSave-startSave)/CLOCKS_PER_SEC << " msecs." << std::endl;
if (argc == 4) return true;
vcg::tri::io::ExporterPLY<MyMesh>::Save(mm,argv[3]); }
return 0;
} int main(int argc ,char**argv)
{
//if (tmp == "-o") UnitTest_Append<MyMesh>(argv[1],"out.ply");
//{ UnitTest_Append<OcfMesh>(argv[1],"out.ply");
// OcfMesh ocfm; return 0;
// 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;
} }

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