regular grid to hash index position in space More...
#include <MC_grid_index_spatial_hashing.hpp>

Public Member Functions | |
| MC_grid_index_spatial_hashing () | |
| empty constructor | |
| MC_grid_index_spatial_hashing (const MC_int_vector &grid_size) | |
| build grid of a given size | |
| MC_int_vector | size () const |
| get the size of the grid | |
| bool | is_in_bound (const MC_int_vector &position) const |
| check if the current position is within bounds | |
| void | clear () |
| empty every case | |
| void | add_index (const MC_int_vector &X, const int index) |
| add the given index to a position of the grid | |
| void | delete_index (const MC_int_vector &X, const int index) |
| delete the given index to a position of the grid | |
| std::set< int > & | get (const MC_int_vector &X) |
| get the set of index of a given position | |
| const std::set< int > & | get (const MC_int_vector &X) const |
| get the set of index of a given position | |
| MC_int_vector_vector | get_voxel_within_sphere (const MC_v3d ¢er, const double &radius) const |
| get all the index within a given sphere | |
| void | add_sphere (const MC_v3d ¢er, const double &radius, const int &id) |
| std::set< int > | neighboors_index_in_radius (const MC_v3d ¢er, const double &radius) const |
Private Attributes | |
| MC_grid_3d< std::set< int > > | index_grid |
| the grid of index | |
regular grid to hash index position in space
Definition at line 13 of file MC_grid_index_spatial_hashing.hpp.
| mesh_conv::MC_grid_index_spatial_hashing::MC_grid_index_spatial_hashing | ( | ) |
| mesh_conv::MC_grid_index_spatial_hashing::MC_grid_index_spatial_hashing | ( | const MC_int_vector & | grid_size | ) |
build grid of a given size
Definition at line 7 of file MC_grid_index_spatial_hashing.cpp.
References index_grid.
00008 { 00009 index_grid=MC_grid_3d<std::set<int> >(grid_size); 00010 }
| void mesh_conv::MC_grid_index_spatial_hashing::add_index | ( | const MC_int_vector & | X, | |
| const int | index | |||
| ) |
add the given index to a position of the grid
Definition at line 16 of file MC_grid_index_spatial_hashing.cpp.
References mesh_conv::MC_grid_3d< VALUE >::get(), and index_grid.
Referenced by add_sphere().
00017 { 00018 index_grid.get(X).insert(index); 00019 }


| void mesh_conv::MC_grid_index_spatial_hashing::add_sphere | ( | const MC_v3d & | center, | |
| const double & | radius, | |||
| const int & | id | |||
| ) |
add a sphere in the hash map
Definition at line 33 of file MC_grid_index_spatial_hashing.cpp.
References add_index(), get_voxel_within_sphere(), and mesh_conv::MC_int_vector_vector::size().
00034 { 00035 MC_int_vector_vector voxel=get_voxel_within_sphere(center,radius); 00036 00037 for(unsigned int k=0,N=voxel.size();k<N;++k) 00038 add_index(voxel[k],id); 00039 }

| void mesh_conv::MC_grid_index_spatial_hashing::clear | ( | ) |
empty every case
Definition at line 87 of file MC_grid_index_spatial_hashing.cpp.
References mesh_conv::MC_grid_3d< VALUE >::fill(), and index_grid.
Referenced by mesh_conv::MC_particle_engine::evolve().
00088 { 00089 index_grid.fill(MC_int_vector().to_set()); 00090 }


| void mesh_conv::MC_grid_index_spatial_hashing::delete_index | ( | const MC_int_vector & | X, | |
| const int | index | |||
| ) |
delete the given index to a position of the grid
Definition at line 20 of file MC_grid_index_spatial_hashing.cpp.
References mesh_conv::MC_grid_3d< VALUE >::get(), and index_grid.
00021 { 00022 index_grid.get(X).erase(index); 00023 }

| const std::set< int > & mesh_conv::MC_grid_index_spatial_hashing::get | ( | const MC_int_vector & | X | ) | const |
get the set of index of a given position
Definition at line 28 of file MC_grid_index_spatial_hashing.cpp.
References mesh_conv::MC_grid_3d< VALUE >::get(), and index_grid.
00029 { 00030 return index_grid.get(X); 00031 }

| std::set< int > & mesh_conv::MC_grid_index_spatial_hashing::get | ( | const MC_int_vector & | X | ) |
get the set of index of a given position
Definition at line 24 of file MC_grid_index_spatial_hashing.cpp.
References mesh_conv::MC_grid_3d< VALUE >::get(), and index_grid.
00025 { 00026 return index_grid.get(X); 00027 }

| MC_int_vector_vector mesh_conv::MC_grid_index_spatial_hashing::get_voxel_within_sphere | ( | const MC_v3d & | center, | |
| const double & | radius | |||
| ) | const |
get all the index within a given sphere
Definition at line 54 of file MC_grid_index_spatial_hashing.cpp.
References mesh_conv::MC_int_vector_vector::add(), and is_in_bound().
Referenced by add_sphere(), and neighboors_index_in_radius().
00055 { 00056 MC_int_vector_vector v_voxel; 00057 00058 MC_int_vector X0=MC_int_vector( 00059 static_cast<int>(center[0]), 00060 static_cast<int>(center[1]), 00061 static_cast<int>(center[2]) 00062 ); 00063 00064 00065 int radius_int=static_cast<int>(radius+1.0); 00066 00067 for(int k_x=-radius_int;k_x<=radius_int;++k_x) 00068 { 00069 for(int k_y=-radius_int;k_y<=radius_int;++k_y) 00070 { 00071 for(int k_z=-radius_int;k_z<=radius_int;++k_z) 00072 { 00073 if( (k_x*k_x+k_y*k_y+k_z*k_z)<=radius_int*radius_int ) 00074 { 00075 MC_int_vector y=X0+MC_int_vector(k_x,k_y,k_z); 00076 if(is_in_bound(y)) 00077 v_voxel.add(y); 00078 } 00079 } 00080 } 00081 } 00082 00083 return v_voxel; 00084 00085 }


| bool mesh_conv::MC_grid_index_spatial_hashing::is_in_bound | ( | const MC_int_vector & | position | ) | const |
check if the current position is within bounds
Definition at line 92 of file MC_grid_index_spatial_hashing.cpp.
References size().
Referenced by get_voxel_within_sphere().
00093 { 00094 const MC_int_vector& dim=size(); 00095 if(position[0]>=0 && position[0]<dim[0]) 00096 if(position[1]>=0 && position[1]<dim[1]) 00097 if(position[2]>=0 && position[2]<dim[2]) 00098 return true; 00099 return false; 00100 }


| std::set< int > mesh_conv::MC_grid_index_spatial_hashing::neighboors_index_in_radius | ( | const MC_v3d & | center, | |
| const double & | radius | |||
| ) | const |
get the index which are without the circumference
Definition at line 40 of file MC_grid_index_spatial_hashing.cpp.
References get_voxel_within_sphere(), and mesh_conv::MC_int_vector_vector::size().
00041 { 00042 MC_int_vector_vector voxel=get_voxel_within_sphere(center,radius); 00043 00044 std::set<int> index_neighbors; 00045 for(unsigned int k=0,N=voxel.size();k<N;++k) 00046 { 00047 std::set<int> current_index=get(MC_int_vector(voxel[k])); 00048 for(std::set<int>::const_iterator it=current_index.begin(),it_end=current_index.end();it!=it_end;++it) 00049 index_neighbors.insert(*it); 00050 } 00051 return index_neighbors; 00052 }

| MC_int_vector mesh_conv::MC_grid_index_spatial_hashing::size | ( | ) | const |
get the size of the grid
Definition at line 11 of file MC_grid_index_spatial_hashing.cpp.
References index_grid, and mesh_conv::MC_grid_3d< VALUE >::size().
Referenced by is_in_bound().
00012 { 00013 return index_grid.size(); 00014 }


MC_grid_3d<std::set<int> > mesh_conv::MC_grid_index_spatial_hashing::index_grid [private] |
the grid of index
Definition at line 84 of file MC_grid_index_spatial_hashing.hpp.
Referenced by add_index(), clear(), delete_index(), get(), MC_grid_index_spatial_hashing(), and size().
1.6.1