From 0a45bfe268020afd092438fb8595e5b9bc96f24e Mon Sep 17 00:00:00 2001 From: cignoni Date: Sun, 2 Oct 2005 23:11:50 +0000 Subject: [PATCH] Changed the core for distance computation. Current version uses the lib flexible search structures. Now the comparison can be done exploiting a static uniform grid, a hashed grid or a hierarchy of AA box. --- apps/metro/sampling.h | 54 +++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/apps/metro/sampling.h b/apps/metro/sampling.h index 52d668d7..c6d4443d 100644 --- a/apps/metro/sampling.h +++ b/apps/metro/sampling.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.18 2005/09/16 11:55:18 cignoni +Partial adding of AABB trees, still not working... + Revision 1.17 2005/08/26 10:42:47 cignoni Added scalar type specification in the typedef of MetroMeshGrid @@ -84,9 +87,8 @@ instantiate GridStaticPtr on the simplexClass template. #include #include #include -#include -#include -#include +#include +#include namespace vcg { @@ -102,7 +104,9 @@ struct SamplingFlags{ NO_SAMPLING = 0x0070, SAVE_ERROR = 0x0100, INCLUDE_UNREFERENCED_VERTICES = 0x0200, - USE_AABB_TREE = 0x0400 + USE_STATIC_GRID = 0x0400, + USE_HASH_GRID = 0x0800, + USE_AABB_TREE = 0x1000 }; }; // ----------------------------------------------------------------------------------------------- @@ -121,11 +125,11 @@ private: typedef typename MetroMesh::FaceType FaceType; typedef typename MetroMesh::FaceContainer FaceContainer; - typedef GridStaticPtr MetroMeshGrid; - typedef AABBBinaryTreeUtils AABBUtils; - typedef typename AABBUtils::EmptyClass AABBEmptyClass; + typedef GridStaticPtr MetroMeshGrid; + typedef SpatialHashTable MetroMeshHash; + typedef AABBBinaryTreeIndex MetroMeshAABB; + - typedef AABBBinaryTreeSearch MetroMeshAABB; typedef Point3 Point3x; @@ -135,7 +139,8 @@ private: MetroMesh &S1; MetroMesh &S2; MetroMeshGrid gS2; - MetroMeshAABB aaS2; + MetroMeshHash hS2; + MetroMeshAABB tS2; unsigned int n_samples_per_face ; @@ -278,8 +283,13 @@ float Sampling::AddSample(const Point3x &p ) dist = dist_upper_bound; // compute distance between p_i and the mesh S2 - trimesh::Closest(S2, p, gS2, dist, normf, bestq, f, ip); - + if(Flags & SamplingFlags::USE_AABB_TREE) + f=trimesh::GetClosest(S2, tS2, p, dist_upper_bound, dist, normf, bestq, ip); + if(Flags & SamplingFlags::USE_HASH_GRID) + f=trimesh::GetClosest(S2, hS2, p, dist_upper_bound, dist, normf, bestq, ip); + if(Flags & SamplingFlags::USE_STATIC_GRID) + f=trimesh::GetClosest(S2, gS2, p, dist_upper_bound, dist, normf, bestq, ip); + // update distance measures if(dist == dist_upper_bound) return -1.0; @@ -591,23 +601,13 @@ void Sampling::Hausdorff() // set grid meshes. + if(Flags & SamplingFlags::USE_HASH_GRID) + hS2.Set::iterator>(S2.face.begin(),S2.face.end()); if(Flags & SamplingFlags::USE_AABB_TREE) - { - typename AABBUtils::ObjIteratorPtrFunct tt0; - typename AABBUtils::FaceBoxFunct tt1; - typename AABBUtils::FaceBarycenterFunct tt2; - - aaS2.Set(S2.face.begin(),S2.face.end(), - tt0, - tt1, - tt2); - } - else - { - gS2.SetBBox(S2.bbox); - if(S2.face.size() < min_size) gS2.Set(S2.face, min_size); - else gS2.Set(S2.face); - } + tS2.Set::iterator>(S2.face.begin(),S2.face.end()); + if(Flags & SamplingFlags::USE_STATIC_GRID) + gS2.Set::iterator>(S2.face.begin(),S2.face.end()); + // set bounding box bbox = S2.bbox; dist_upper_bound = /*bbox_factor * */bbox.Diag();