Added possibility to use Octree as search structure:
This commit is contained in:
parent
5799203aaf
commit
f786e138ee
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$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
|
Revision 1.20 2006/04/20 08:30:24 cignoni
|
||||||
small GCC compiling issues
|
small GCC compiling issues
|
||||||
|
|
||||||
|
@ -135,6 +138,7 @@ void Usage()
|
||||||
" -L Remove duplicated and unreferenced vertices before processing\n"\
|
" -L Remove duplicated and unreferenced vertices before processing\n"\
|
||||||
" -h write files with histograms of error distribution\n"\
|
" -h write files with histograms of error distribution\n"\
|
||||||
" -G Use a static Uniform Grid as Search Structure (default)\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"\
|
" -A Use an AxisAligned Bounding Box Tree as Search Structure\n"\
|
||||||
" -H Use an Hashed Uniform Grid as Search Structure\n"\
|
" -H Use an Hashed Uniform Grid as Search Structure\n"\
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -220,16 +224,17 @@ int main(int argc, char**argv)
|
||||||
case 'c': flags |= SamplingFlags::SAVE_ERROR; break;
|
case 'c': flags |= SamplingFlags::SAVE_ERROR; break;
|
||||||
case 'L': CleaningFlag=true; break;
|
case 'L': CleaningFlag=true; break;
|
||||||
case 'C': ColorMin=float(atof(argv[i+1])); ColorMax=float(atof(argv[i+2])); i+=2; 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 '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]);
|
default : printf(MSG_ERR_INVALID_OPTION, argv[i]);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
i++;
|
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;
|
flags |= SamplingFlags::USE_STATIC_GRID;
|
||||||
|
|
||||||
// load input meshes.
|
// load input meshes.
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$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
|
Revision 1.21 2006/01/22 10:05:43 cignoni
|
||||||
Corrected use of Area with the unambiguous DoubleArea
|
Corrected use of Area with the unambiguous DoubleArea
|
||||||
|
|
||||||
|
@ -100,6 +103,7 @@ instantiate GridStaticPtr on the simplexClass template.
|
||||||
#include <vcg/complex/trimesh/update/color.h>
|
#include <vcg/complex/trimesh/update/color.h>
|
||||||
#include <vcg/space/index/grid_static_ptr.h>
|
#include <vcg/space/index/grid_static_ptr.h>
|
||||||
#include <vcg/space/index/aabb_binary_tree/aabb_binary_tree.h>
|
#include <vcg/space/index/aabb_binary_tree/aabb_binary_tree.h>
|
||||||
|
#include <vcg/space/index/octree.h>
|
||||||
#include <vcg/space/index/spatial_hashing.h>
|
#include <vcg/space/index/spatial_hashing.h>
|
||||||
namespace vcg
|
namespace vcg
|
||||||
{
|
{
|
||||||
|
@ -118,7 +122,8 @@ struct SamplingFlags{
|
||||||
INCLUDE_UNREFERENCED_VERTICES = 0x0200,
|
INCLUDE_UNREFERENCED_VERTICES = 0x0200,
|
||||||
USE_STATIC_GRID = 0x0400,
|
USE_STATIC_GRID = 0x0400,
|
||||||
USE_HASH_GRID = 0x0800,
|
USE_HASH_GRID = 0x0800,
|
||||||
USE_AABB_TREE = 0x1000
|
USE_AABB_TREE = 0x1000,
|
||||||
|
USE_OCTREE = 0x2000
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
// -----------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------
|
||||||
|
@ -128,19 +133,19 @@ class Sampling
|
||||||
public:
|
public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef typename MetroMesh::CoordType CoordType;
|
typedef typename MetroMesh::CoordType CoordType;
|
||||||
typedef typename MetroMesh::ScalarType ScalarType;
|
typedef typename MetroMesh::ScalarType ScalarType;
|
||||||
typedef typename MetroMesh::VertexType VertexType;
|
typedef typename MetroMesh::VertexType VertexType;
|
||||||
typedef typename MetroMesh::VertexPointer VertexPointer;
|
typedef typename MetroMesh::VertexPointer VertexPointer;
|
||||||
typedef typename MetroMesh::VertexIterator VertexIterator;
|
typedef typename MetroMesh::VertexIterator VertexIterator;
|
||||||
typedef typename MetroMesh::FaceIterator FaceIterator;
|
typedef typename MetroMesh::FaceIterator FaceIterator;
|
||||||
typedef typename MetroMesh::FaceType FaceType;
|
typedef typename MetroMesh::FaceType FaceType;
|
||||||
|
typedef typename MetroMesh::FaceContainer FaceContainer;
|
||||||
typedef typename MetroMesh::FaceContainer FaceContainer;
|
|
||||||
typedef GridStaticPtr<FaceType, typename MetroMesh::ScalarType > MetroMeshGrid;
|
typedef GridStaticPtr <FaceType, typename MetroMesh::ScalarType > MetroMeshGrid;
|
||||||
typedef SpatialHashTable<FaceType, typename MetroMesh::ScalarType > MetroMeshHash;
|
typedef SpatialHashTable <FaceType, typename MetroMesh::ScalarType > MetroMeshHash;
|
||||||
typedef AABBBinaryTreeIndex<FaceType, typename MetroMesh::ScalarType, vcg::EmptyClass> MetroMeshAABB;
|
typedef AABBBinaryTreeIndex <FaceType, typename MetroMesh::ScalarType, vcg::EmptyClass> MetroMeshAABB;
|
||||||
|
typedef Octree <FaceType, typename MetroMesh::ScalarType > MetroMeshOctree;
|
||||||
|
|
||||||
typedef Point3<typename MetroMesh::ScalarType> Point3x;
|
typedef Point3<typename MetroMesh::ScalarType> Point3x;
|
||||||
|
|
||||||
|
@ -153,16 +158,17 @@ private:
|
||||||
MetroMeshGrid gS2;
|
MetroMeshGrid gS2;
|
||||||
MetroMeshHash hS2;
|
MetroMeshHash hS2;
|
||||||
MetroMeshAABB tS2;
|
MetroMeshAABB tS2;
|
||||||
|
MetroMeshOctree oS2;
|
||||||
|
|
||||||
|
|
||||||
unsigned int n_samples_per_face ;
|
unsigned int n_samples_per_face ;
|
||||||
float n_samples_edge_to_face_ratio ;
|
float n_samples_edge_to_face_ratio ;
|
||||||
float bbox_factor ;
|
float bbox_factor ;
|
||||||
float inflate_percentage ;
|
float inflate_percentage ;
|
||||||
unsigned int min_size ;
|
unsigned int min_size ;
|
||||||
int n_hist_bins ;
|
int n_hist_bins ;
|
||||||
int print_every_n_elements ;
|
int print_every_n_elements ;
|
||||||
int referredBit;
|
int referredBit ;
|
||||||
// parameters
|
// parameters
|
||||||
double dist_upper_bound;
|
double dist_upper_bound;
|
||||||
double n_samples_per_area_unit;
|
double n_samples_per_area_unit;
|
||||||
|
@ -301,6 +307,8 @@ float Sampling<MetroMesh>::AddSample(const Point3x &p )
|
||||||
f=trimesh::GetClosestFace<MetroMesh,MetroMeshHash>(S2, hS2, p, dist_upper_bound, dist, normf, bestq, ip);
|
f=trimesh::GetClosestFace<MetroMesh,MetroMeshHash>(S2, hS2, p, dist_upper_bound, dist, normf, bestq, ip);
|
||||||
if(Flags & SamplingFlags::USE_STATIC_GRID)
|
if(Flags & SamplingFlags::USE_STATIC_GRID)
|
||||||
f=trimesh::GetClosestFace<MetroMesh,MetroMeshGrid>(S2, gS2, p, dist_upper_bound, dist, normf, bestq, ip);
|
f=trimesh::GetClosestFace<MetroMesh,MetroMeshGrid>(S2, gS2, p, dist_upper_bound, dist, normf, bestq, ip);
|
||||||
|
if (Flags & SamplingFlags::USE_OCTREE)
|
||||||
|
f=trimesh::GetClosestFace<MetroMesh,MetroMeshOctree>(S2, oS2, p, dist_upper_bound, dist, normf, bestq, ip);
|
||||||
|
|
||||||
// update distance measures
|
// update distance measures
|
||||||
if(dist == dist_upper_bound)
|
if(dist == dist_upper_bound)
|
||||||
|
@ -619,6 +627,8 @@ void Sampling<MetroMesh>::Hausdorff()
|
||||||
tS2.Set(S2.face.begin(),S2.face.end());
|
tS2.Set(S2.face.begin(),S2.face.end());
|
||||||
if(Flags & SamplingFlags::USE_STATIC_GRID)
|
if(Flags & SamplingFlags::USE_STATIC_GRID)
|
||||||
gS2.Set(S2.face.begin(),S2.face.end());
|
gS2.Set(S2.face.begin(),S2.face.end());
|
||||||
|
if (Flags & SamplingFlags::USE_OCTREE)
|
||||||
|
oS2.Set(S2.face.begin(),S2.face.end());
|
||||||
|
|
||||||
// set bounding box
|
// set bounding box
|
||||||
bbox = S2.bbox;
|
bbox = S2.bbox;
|
||||||
|
|
Loading…
Reference in New Issue