From 14dc0c2a0fbb6e5af753bb86c41c00b6d55563ac Mon Sep 17 00:00:00 2001 From: cignoni Date: Fri, 1 Dec 2006 21:25:23 +0000 Subject: [PATCH] Cleaned up and added option on the size of the holes to be closed --- apps/sample/trimesh_hole/trimesh_hole.cpp | 37 +++++++++-------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/apps/sample/trimesh_hole/trimesh_hole.cpp b/apps/sample/trimesh_hole/trimesh_hole.cpp index 15820854..0f828cb4 100644 --- a/apps/sample/trimesh_hole/trimesh_hole.cpp +++ b/apps/sample/trimesh_hole/trimesh_hole.cpp @@ -36,18 +36,18 @@ class MyMesh : public tri::TriMesh< vector, vector >{}; bool callback(int percent, const char *str) { - cout << "str: " << str << " " << percent << "%\n"; + cout << "str: " << str << " " << percent << "%\r"; return true; } int main(int argc,char ** argv){ - if(argc<4) + if(argc<5) { printf( "\n HoleFilling ("__DATE__")\n" "Visual Computing Group I.S.T.I. C.N.R.\n" - "Usage: trimesh_hole #algorithm filein.ply fileout.ply \n" + "Usage: trimesh_hole #algorithm #size filein.ply fileout.ply \n" "#algorithm: \n" " 1) Trivial Ear \n" " 2) Leipa Ear \n" @@ -58,6 +58,7 @@ int main(int argc,char ** argv){ } int algorithm = atoi(argv[1]); + int holeSize = atoi(argv[2]); if(algorithm < 0 && algorithm > 4) { printf("Error in algorithm's selection\n",algorithm); @@ -66,7 +67,7 @@ int main(int argc,char ** argv){ MyMesh m; - if(tri::io::ImporterPLY::Open(m,argv[2])!=0) + if(tri::io::ImporterPLY::Open(m,argv[3])!=0) { printf("Error reading file %s\n",argv[2]); exit(0); @@ -77,29 +78,19 @@ int main(int argc,char ** argv){ tri::UpdateTopology::FaceFace(m); tri::UpdateNormals::PerVertex(m); tri::UpdateFlags::FaceBorderFromFF(m); + assert(tri::Clean::IsFFAdjacencyConsistent(m)); -vcg::tri::Hole holeFiller; - + tri::Hole holeFiller; switch(algorithm) { - case 1: - - holeFiller.EarCuttingFill >(m,50,false); - break; - case 2: - assert(tri::Clean::IsFFAdjacencyConsistent(m)); - holeFiller.EarCuttingFill >(m,10,false,callback); - assert(tri::Clean::IsFFAdjacencyConsistent(m)); - break; - case 3: - holeFiller.EarCuttingIntersectionFill >(m,500,false); - break; - case 4: - holeFiller.MinimumWeightFill(m, false); - break; + case 1: tri::Hole::EarCuttingFill >(m,holeSize,false); break; + case 2: tri::Hole::EarCuttingFill >(m,holeSize,false,callback); break; + case 3: tri::Hole::EarCuttingIntersectionFill >(m,holeSize,false); break; + case 4: tri::Hole::MinimumWeightFill(m, false); break; } - - tri::io::ExporterPLY::Save(m,argv[3],false); + printf("\nCompleted. Saving....\n"); + assert(tri::Clean::IsFFAdjacencyConsistent(m)); + tri::io::ExporterPLY::Save(m,argv[4],false); return 0; }