Particle engine based on spheres. More...
#include <MC_particle_engine.hpp>

Public Member Functions | |
| MC_particle_engine () | |
| void | add (const MC_sphere_physic &new_particle) |
| add a particle | |
| const std::map< unsigned int, MC_sphere_physic > & | particle_system () const |
| get the particle system | |
| MC_grid_index_spatial_hashing & | grid_spatial_hash () |
| get the spatial hash grid | |
| const MC_grid_index_spatial_hashing & | grid_spatial_hash () const |
| get the spatial hash grid | |
| void | evolve (const bool &is_collision_detection=true, const bool &is_potential=false) |
| evolve time for every particles | |
Private Attributes | |
| std::map< unsigned int, MC_sphere_physic > | particles |
| the vector of particles | |
| double | time_step |
| the current time step | |
| MC_grid_index_spatial_hashing | spatial_hash |
| the spatial hash table for intersection speed-up | |
| MC_grid_index_spatial_hashing | spatial_hash_proximity |
| the spatial hash table for proximity speed-up | |
| unsigned int | dim_spatial_hash |
| dimension of the hash table | |
| unsigned int | dim_spatial_hash_proximity |
| dimension of the proximity hash table | |
Static Private Attributes | |
| static unsigned int | id_max = 0 |
| follow the particle id max | |
Particle engine based on spheres.
Definition at line 16 of file MC_particle_engine.hpp.
| mesh_conv::MC_particle_engine::MC_particle_engine | ( | ) |
brief init an empty particle engine
Definition at line 9 of file MC_particle_engine.cpp.
References dim_spatial_hash, dim_spatial_hash_proximity, spatial_hash, and spatial_hash_proximity.
00010 :particles(),time_step(1e-2),dim_spatial_hash(10),dim_spatial_hash_proximity(10) 00011 { 00012 spatial_hash=MC_grid_index_spatial_hashing(MC_int_vector(dim_spatial_hash,dim_spatial_hash,dim_spatial_hash)); 00013 spatial_hash_proximity=MC_grid_index_spatial_hashing(MC_int_vector(dim_spatial_hash_proximity,dim_spatial_hash_proximity,dim_spatial_hash_proximity)); 00014 }
| void mesh_conv::MC_particle_engine::add | ( | const MC_sphere_physic & | new_particle | ) |
| void mesh_conv::MC_particle_engine::evolve | ( | const bool & | is_collision_detection = true, |
|
| const bool & | is_potential = false | |||
| ) |
evolve time for every particles
Definition at line 21 of file MC_particle_engine.cpp.
References mesh_conv::MC_grid_index_spatial_hashing::clear(), mesh_conv::MC_sphere_physic::constraint_in_unit_cube(), mesh_conv::MC_sphere_physic::evolve(), mesh_conv::MC_sphere_physic::force(), particles, mesh_conv::MC_v3d::set_zero(), spatial_hash, spatial_hash_proximity, and time_step.
Referenced by engine_run().
00022 { 00023 MC_v3d gravity=MC_v3d(0,0,-9.81); 00024 00025 //empty the spatial hash 00026 if(is_collision_detection==true) 00027 spatial_hash.clear(); 00028 if(is_potential==true) 00029 spatial_hash_proximity.clear(); 00030 00031 00032 00033 for(std::map<unsigned int,MC_sphere_physic>::iterator it=particles.begin(),it_end=particles.end();it!=it_end;++it) 00034 { 00035 MC_sphere_physic& current_particle=it->second; 00036 current_particle.force().set_zero(); 00037 00038 00039 // ******************************* // 00040 // TO DO: ajouter les indice dans la structure acceleratrice 00041 // spatial_hash.add_sphere(le_centre_en_voxel,la_dimension_en_voxel,it->first); 00042 // ******************************* // 00043 } 00044 00045 for(std::map<unsigned int,MC_sphere_physic>::iterator it=particles.begin(),it_end=particles.end();it!=it_end;++it) 00046 { 00047 MC_sphere_physic& current_particle=it->second; 00048 current_particle.force() = gravity; 00049 std::set<int> neighboor_index; 00050 std::set<int> neighboor_index_proximity; 00051 if(is_collision_detection==true) 00052 { 00053 // ******************************* // 00054 // TO DO: detecter les voisins 00055 // neighboor_index=spatial_hash.neighboors_index_in_radius(le_centre_en_voxel,le_rayon_en_voxel); 00056 // ******************************* // 00057 } 00058 if(is_potential==true) 00059 { 00060 // ******************************* // 00061 // TO DO: detecter les voisins 00062 // neighboor_index_proximity=spatial_hash_proximity.neighboors_index_in_radius(le_centre_en_voxel,le_rayon_en_voxel); 00063 // ******************************* // 00064 } 00065 00066 //compute potential force 00067 if(is_potential==true) 00068 { 00069 00070 // ******************************* // 00071 // TO DO: potential force 00072 // ******************************* // 00073 00074 } 00075 00076 00077 //evolve through time 00078 current_particle.evolve(time_step); 00079 00080 00081 00082 00083 //collision response 00084 if(is_collision_detection==true) 00085 { 00086 // ******************************* // 00087 // TO DO: Collision between pair of particles 00088 00089 // pour les paires de particules 00090 // MC_sphere_physic::constraint_no_collision_sphere(¤t_particle,&(autre_particule))); 00091 00092 // ******************************* // 00093 } 00094 00095 //cube constraint 00096 current_particle.constraint_in_unit_cube(); 00097 00098 } 00099 00100 }


| const MC_grid_index_spatial_hashing& mesh_conv::MC_particle_engine::grid_spatial_hash | ( | ) | const |
get the spatial hash grid
| MC_grid_index_spatial_hashing& mesh_conv::MC_particle_engine::grid_spatial_hash | ( | ) |
get the spatial hash grid
| const std::map< unsigned int, MC_sphere_physic > & mesh_conv::MC_particle_engine::particle_system | ( | ) | const |
get the particle system
Definition at line 102 of file MC_particle_engine.cpp.
References particles.
Referenced by draw_fps(), draw_scene(), export_scene(), and update_potential().
00103 { 00104 return particles; 00105 }

unsigned int mesh_conv::MC_particle_engine::dim_spatial_hash [private] |
dimension of the hash table
Definition at line 80 of file MC_particle_engine.hpp.
Referenced by MC_particle_engine().
unsigned int mesh_conv::MC_particle_engine::dim_spatial_hash_proximity [private] |
dimension of the proximity hash table
Definition at line 82 of file MC_particle_engine.hpp.
Referenced by MC_particle_engine().
unsigned int mesh_conv::MC_particle_engine::id_max = 0 [static, private] |
follow the particle id max
Definition at line 77 of file MC_particle_engine.hpp.
Referenced by add().
std::map<unsigned int,MC_sphere_physic> mesh_conv::MC_particle_engine::particles [private] |
the vector of particles
Definition at line 66 of file MC_particle_engine.hpp.
Referenced by add(), evolve(), and particle_system().
the spatial hash table for intersection speed-up
Definition at line 72 of file MC_particle_engine.hpp.
Referenced by evolve(), and MC_particle_engine().
the spatial hash table for proximity speed-up
Definition at line 74 of file MC_particle_engine.hpp.
Referenced by evolve(), and MC_particle_engine().
double mesh_conv::MC_particle_engine::time_step [private] |
1.6.1