diff --git a/apps/sample/sample.pro b/apps/sample/sample.pro index 42da3bca..f1cde434 100644 --- a/apps/sample/sample.pro +++ b/apps/sample/sample.pro @@ -7,6 +7,7 @@ SUBDIRS = trimesh_base \ trimesh_topology\ trimesh_smooth \ trimesh_refine \ + trimesh_clustering \ trimesh_isosurface \ trimesh_join \ trimesh_optional \ diff --git a/apps/sample/trimesh_clustering/trimesh_clustering.cpp b/apps/sample/trimesh_clustering/trimesh_clustering.cpp new file mode 100644 index 00000000..81ac1ad3 --- /dev/null +++ b/apps/sample/trimesh_clustering/trimesh_clustering.cpp @@ -0,0 +1,96 @@ + +// mesh definition +//#include +//#include +//#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +// input output +#include +#include + +// std +#include +#include + +using namespace vcg; +using namespace std; + +class MyEdge; // dummy prototype never used +class MyFace; +class MyVertex; + +class MyVertex : public VertexSimp2< MyVertex, MyEdge, MyFace, vert::Coord3f, vert::Normal3f, vert::BitFlags >{}; +class MyFace : public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef, face::BitFlags > {}; +class MyMesh : public vcg::tri::TriMesh< vector, vector > {}; + +int main(int argc, char **argv) +{ + if(argc<3) + { + printf( + "\n trimesh_clustering ("__DATE__")\n" + " Visual Computing Group I.S.T.I. C.N.R.\n" + "Usage: PlyRefine filein.ply fileout.ply [opt] \n" + "options: \n" + "-k cellnum approx number of cluster that should be defined; (default 10e5)\n" + "-s size in absolute units the size of the clustering cell\n" + ); + exit(0); + } + + int i=3; int CellNum=100000; float CellSize=0; + + while(i::Open(m,argv[1])!=0) + { + printf("Error reading file %s\n",argv[1]); + exit(0); + } + vcg::tri::UpdateBounding::Box(m); + vcg::tri::UpdateNormals::PerVertexNormalized(m); + printf("Input mesh vn:%i fn:%i\n",m.vn,m.fn); + vcg::tri::Clustering > Grid; + Grid.Init(m.bbox,CellNum,CellSize); + + printf("Clustering to %i cells\n",Grid.Grid.siz[0]*Grid.Grid.siz[1]*Grid.Grid.siz[2] ); + printf("Grid of %i x %i x %i cells\n",Grid.Grid.siz[0],Grid.Grid.siz[1],Grid.Grid.siz[2]); + printf("with cells size of %.2f x %.2f x %.2f units\n",Grid.Grid.voxel[0],Grid.Grid.voxel[1],Grid.Grid.voxel[2]); + + int t0=clock(); + Grid.Add(m); + int t1=clock(); + Grid.Extract(m); + int t2=clock(); + printf("Output mesh vn:%i fn:%i\n",m.vn,m.fn); + printf("Simplified in :%i msec (%i+%i)\n",t2-t0,t1-t0,t2-t1); + + vcg::tri::io::PlyInfo pi; + vcg::tri::io::ExporterPLY::Save(m,argv[2],pi.mask); + return 0; + } diff --git a/apps/sample/trimesh_clustering/trimesh_clustering.pro b/apps/sample/trimesh_clustering/trimesh_clustering.pro new file mode 100644 index 00000000..e6768589 --- /dev/null +++ b/apps/sample/trimesh_clustering/trimesh_clustering.pro @@ -0,0 +1,13 @@ +###################################################################### +# Automatically generated by qmake (2.00a) ven 24. giu 14:14:20 2005 +###################################################################### +# To solve issue related to slash vs. backslash under cygwin try: +# env MINGW_IN_SHELL=1 qmake -spec win32-g++ + +TARGET = trimesh_clustering +LIBPATH += +DEPENDPATH += . +INCLUDEPATH += . ../../.. +CONFIG += console stl +TEMPLATE = app +SOURCES += trimesh_clustering.cpp ../../../wrap/ply/plylib.cpp \ No newline at end of file