simple reorganization of the testing code
This commit is contained in:
parent
db57bd4e19
commit
4356ed9833
|
@ -1,10 +1,11 @@
|
|||
#include <vcg/complex/append.h>
|
||||
|
||||
// stuff to define the mesh
|
||||
#include <vcg/simplex/vertex/base.h>
|
||||
#include <vcg/simplex/vertex/component_ocf.h>
|
||||
#include <vcg/simplex/face/base.h>
|
||||
#include <vcg/simplex/edge/base.h>
|
||||
#include <vcg/complex/complex.h>
|
||||
#include <vcg/complex/append.h>
|
||||
// io
|
||||
#include <wrap/io_trimesh/import.h>
|
||||
#include <wrap/io_trimesh/export_ply.h>
|
||||
|
@ -36,36 +37,36 @@ class MyFace : public vcg::Face< MyUsedTypes,
|
|||
// the main mesh class
|
||||
class MyMesh : public vcg::tri::TriMesh<std::vector<MyVertex>, std::vector<MyFace> > {};
|
||||
|
||||
class OcfVertex;
|
||||
class OcfEdge;
|
||||
class OcfFace;
|
||||
|
||||
// Declaration of the semantic of the used types
|
||||
class OcfUsedTypes: public vcg::UsedTypes < vcg::Use<OcfVertex>::AsVertexType,
|
||||
vcg::Use<OcfEdge >::AsEdgeType,
|
||||
vcg::Use<OcfFace >::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<OcfUsedTypes>
|
||||
{
|
||||
};
|
||||
|
||||
// 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<OcfVertex>, vcg::face::vector_ocf<OcfFace> >
|
||||
{
|
||||
class OcfVertex;
|
||||
class OcfEdge;
|
||||
class OcfFace;
|
||||
|
||||
// Declaration of the semantic of the used types
|
||||
class OcfUsedTypes: public vcg::UsedTypes < vcg::Use<OcfVertex>::AsVertexType,
|
||||
vcg::Use<OcfEdge >::AsEdgeType,
|
||||
vcg::Use<OcfFace >::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<OcfUsedTypes>
|
||||
{
|
||||
};
|
||||
|
||||
// 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<OcfVertex>, vcg::face::vector_ocf<OcfFace> >
|
||||
{
|
||||
};
|
||||
|
||||
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<MyMesh>::Open(mesh,argv[1]);
|
||||
if(err)
|
||||
{
|
||||
std::cerr << "Unable to open mesh " << argv[1] << " : " << vcg::tri::io::Importer<MyMesh>::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<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;
|
||||
template <class MeshType>
|
||||
bool UnitTest_Append(const char *filename1, const char *filename2)
|
||||
{
|
||||
MeshType mr;
|
||||
MeshType ml;
|
||||
|
||||
int startOpen=clock();
|
||||
int err=vcg::tri::io::Importer<MeshType>::Open(mr,filename1);
|
||||
if(err)
|
||||
{
|
||||
std::cerr << "Unable to open mesh " << filename1 << " : " << 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";
|
||||
|
||||
int startCopy = clock();
|
||||
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)
|
||||
{
|
||||
UnitTest_Append<MyMesh>(argv[1],"out.ply");
|
||||
UnitTest_Append<OcfMesh>(argv[1],"out.ply");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue