MC_particle_engine.cpp

Go to the documentation of this file.
00001 
00002 #include <MC_particle_engine.hpp>
00003 
00004 namespace mesh_conv
00005 {
00006 
00007     unsigned int MC_particle_engine::id_max=0;
00008 
00009     MC_particle_engine::MC_particle_engine()
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     }
00015 
00016     void MC_particle_engine::add(const MC_sphere_physic& new_particle)
00017     {
00018         particles.insert(std::make_pair(id_max++,new_particle));
00019     }
00020 
00021     void MC_particle_engine::evolve(const bool& is_collision_detection,const bool& is_potential)
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(&current_particle,&(autre_particule)));
00091 
00092                 // ******************************* //
00093             }
00094 
00095             //cube constraint
00096             current_particle.constraint_in_unit_cube();
00097 
00098         }
00099 
00100     }
00101 
00102     const std::map<unsigned int,MC_sphere_physic>& MC_particle_engine::particle_system() const
00103     {
00104         return particles;
00105     }
00106 
00107 }

Generated on Sun Apr 18 20:24:47 2010 by  doxygen 1.6.1