00001 #ifndef OPENTISSUE_DYNAMICS_SPH_EMITTERS_SPH_POINT_H 00002 #define OPENTISSUE_DYNAMICS_SPH_EMITTERS_SPH_POINT_H 00003 // 00004 // OpenTissue Template Library 00005 // - A generic toolbox for physics-based modeling and simulation. 00006 // Copyright (C) 2008 Department of Computer Science, University of Copenhagen. 00007 // 00008 // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php 00009 // 00010 #include <OpenTissue/configuration.h> 00011 00012 #include <OpenTissue/dynamics/sph/sph_emitter.h> 00013 00014 namespace OpenTissue 00015 { 00016 namespace sph 00017 { 00018 00022 template< typename Types > 00023 class PointEmitter : public Emitter<Types> 00024 { 00025 public: 00026 typedef Emitter<Types> base_type; 00027 typedef typename Types::real_type real_type; 00028 typedef typename Types::vector vector; 00029 typedef typename Types::particle particle; 00030 typedef typename Types::particle_ptr_container particle_ptr_container; 00031 00032 public: 00033 00034 PointEmitter( vector const & point, vector const & velocity = 0) 00035 : base_type() 00036 , m_p(point) 00037 , m_v(velocity) 00038 {} 00039 00040 ~PointEmitter() 00041 {} 00042 00043 public: 00044 00045 const vector& center() const { return m_p; } 00046 00047 private: 00048 00052 bool init() 00053 { 00054 typename particle_ptr_container::iterator end = base_type::m_pars.end(); 00055 for (typename particle_ptr_container::iterator par = base_type::m_pars.begin(); par != end; ++par) { 00056 particle* p = *par; 00057 p->velocity() = m_v; 00058 // p->position() = m_p; 00059 vector disp; 00060 random(disp,-0.001, 0.001); 00061 p->position() = m_p+disp; 00062 } 00063 return true; 00064 } 00065 00066 protected: 00067 00068 vector m_p; 00069 vector m_v; 00070 00071 }; // End class PointEmitter 00072 00073 } // namespace sph 00074 } // namespace OpenTissue 00075 00076 // OPENTISSUE_DYNAMICS_SPH_EMITTERS_SPH_POINT_H 00077 #endif