From f786e138ee99a4b68dd3213b7f79b9df664cf1eb Mon Sep 17 00:00:00 2001 From: cnr-isti-vclab Date: Wed, 25 Oct 2006 12:40:19 +0000 Subject: [PATCH] Added possibility to use Octree as search structure: --- apps/metro/metro.cpp | 11 ++++++++--- apps/metro/sampling.h | 46 ++++++++++++++++++++++++++----------------- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/apps/metro/metro.cpp b/apps/metro/metro.cpp index 85206f80..eefdf85e 100644 --- a/apps/metro/metro.cpp +++ b/apps/metro/metro.cpp @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.21 2006/05/03 21:22:39 cignoni +added missing Include + Revision 1.20 2006/04/20 08:30:24 cignoni small GCC compiling issues @@ -135,6 +138,7 @@ void Usage() " -L Remove duplicated and unreferenced vertices before processing\n"\ " -h write files with histograms of error distribution\n"\ " -G Use a static Uniform Grid as Search Structure (default)\n"\ + " -O Use an octree as a Search Structure\n"\ " -A Use an AxisAligned Bounding Box Tree as Search Structure\n"\ " -H Use an Hashed Uniform Grid as Search Structure\n"\ "\n" @@ -220,16 +224,17 @@ int main(int argc, char**argv) case 'c': flags |= SamplingFlags::SAVE_ERROR; break; case 'L': CleaningFlag=true; break; case 'C': ColorMin=float(atof(argv[i+1])); ColorMax=float(atof(argv[i+2])); i+=2; break; - case 'A': flags |= SamplingFlags::USE_AABB_TREE; printf("Using AABB Tree as search structure\n"); break; + case 'A': flags |= SamplingFlags::USE_AABB_TREE; printf("Using AABB Tree as search structure\n"); break; case 'G': flags |= SamplingFlags::USE_STATIC_GRID; printf("Using static uniform grid as search structure\n"); break; - case 'H': flags |= SamplingFlags::USE_HASH_GRID; printf("Using hashed uniform grid as search structure\n"); break; + case 'H': flags |= SamplingFlags::USE_HASH_GRID; printf("Using hashed uniform grid as search structure\n"); break; + case 'O': flags |= SamplingFlags::USE_OCTREE; printf("Using octree as search structure\n"); break; default : printf(MSG_ERR_INVALID_OPTION, argv[i]); exit(0); } i++; } - if(!(flags & SamplingFlags::USE_HASH_GRID) && !(flags & SamplingFlags::USE_AABB_TREE) ) + if(!(flags & SamplingFlags::USE_HASH_GRID) && !(flags & SamplingFlags::USE_AABB_TREE) && !(flags & SamplingFlags::USE_OCTREE)) flags |= SamplingFlags::USE_STATIC_GRID; // load input meshes. diff --git a/apps/metro/sampling.h b/apps/metro/sampling.h index 3632eee7..9cea0089 100644 --- a/apps/metro/sampling.h +++ b/apps/metro/sampling.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.22 2006/04/20 08:30:24 cignoni +small GCC compiling issues + Revision 1.21 2006/01/22 10:05:43 cignoni Corrected use of Area with the unambiguous DoubleArea @@ -100,6 +103,7 @@ instantiate GridStaticPtr on the simplexClass template. #include #include #include +#include #include namespace vcg { @@ -118,7 +122,8 @@ struct SamplingFlags{ INCLUDE_UNREFERENCED_VERTICES = 0x0200, USE_STATIC_GRID = 0x0400, USE_HASH_GRID = 0x0800, - USE_AABB_TREE = 0x1000 + USE_AABB_TREE = 0x1000, + USE_OCTREE = 0x2000 }; }; // ----------------------------------------------------------------------------------------------- @@ -128,19 +133,19 @@ class Sampling public: private: - typedef typename MetroMesh::CoordType CoordType; - typedef typename MetroMesh::ScalarType ScalarType; - typedef typename MetroMesh::VertexType VertexType; - typedef typename MetroMesh::VertexPointer VertexPointer; - typedef typename MetroMesh::VertexIterator VertexIterator; - typedef typename MetroMesh::FaceIterator FaceIterator; - typedef typename MetroMesh::FaceType FaceType; - - typedef typename MetroMesh::FaceContainer FaceContainer; - typedef GridStaticPtr MetroMeshGrid; - typedef SpatialHashTable MetroMeshHash; - typedef AABBBinaryTreeIndex MetroMeshAABB; - + typedef typename MetroMesh::CoordType CoordType; + typedef typename MetroMesh::ScalarType ScalarType; + typedef typename MetroMesh::VertexType VertexType; + typedef typename MetroMesh::VertexPointer VertexPointer; + typedef typename MetroMesh::VertexIterator VertexIterator; + typedef typename MetroMesh::FaceIterator FaceIterator; + typedef typename MetroMesh::FaceType FaceType; + typedef typename MetroMesh::FaceContainer FaceContainer; + + typedef GridStaticPtr MetroMeshGrid; + typedef SpatialHashTable MetroMeshHash; + typedef AABBBinaryTreeIndex MetroMeshAABB; + typedef Octree MetroMeshOctree; typedef Point3 Point3x; @@ -153,16 +158,17 @@ private: MetroMeshGrid gS2; MetroMeshHash hS2; MetroMeshAABB tS2; + MetroMeshOctree oS2; - unsigned int n_samples_per_face ; + unsigned int n_samples_per_face ; float n_samples_edge_to_face_ratio ; float bbox_factor ; float inflate_percentage ; - unsigned int min_size ; - int n_hist_bins ; + unsigned int min_size ; + int n_hist_bins ; int print_every_n_elements ; - int referredBit; + int referredBit ; // parameters double dist_upper_bound; double n_samples_per_area_unit; @@ -301,6 +307,8 @@ float Sampling::AddSample(const Point3x &p ) f=trimesh::GetClosestFace(S2, hS2, p, dist_upper_bound, dist, normf, bestq, ip); if(Flags & SamplingFlags::USE_STATIC_GRID) f=trimesh::GetClosestFace(S2, gS2, p, dist_upper_bound, dist, normf, bestq, ip); + if (Flags & SamplingFlags::USE_OCTREE) + f=trimesh::GetClosestFace(S2, oS2, p, dist_upper_bound, dist, normf, bestq, ip); // update distance measures if(dist == dist_upper_bound) @@ -619,6 +627,8 @@ void Sampling::Hausdorff() tS2.Set(S2.face.begin(),S2.face.end()); if(Flags & SamplingFlags::USE_STATIC_GRID) gS2.Set(S2.face.begin(),S2.face.end()); + if (Flags & SamplingFlags::USE_OCTREE) + oS2.Set(S2.face.begin(),S2.face.end()); // set bounding box bbox = S2.bbox;