00001 #ifndef OPENTISSUE_DYNAMICS_PSYS_CONSTRAINTS_PSYS_PIN_H 00002 #define OPENTISSUE_DYNAMICS_PSYS_CONSTRAINTS_PSYS_PIN_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/psys/psys_constraint.h> 00013 #include <cassert> 00014 00015 namespace OpenTissue 00016 { 00017 namespace psys 00018 { 00019 00020 template<typename types> 00021 class Pin 00022 : public Constraint< types > 00023 { 00024 public: 00025 00026 typedef typename types::math_types math_types; 00027 typedef typename math_types::real_type real_type; 00028 typedef typename math_types::vector3_type vector3_type; 00029 typedef typename types::particle_type particle_type; 00030 00031 protected: 00032 00033 particle_type * m_particle; 00034 vector3_type m_r; 00035 00036 public: 00037 00038 vector3_type & pin_position() { return m_r; } 00039 vector3_type const & pin_position() const { return m_r; } 00040 00041 public: 00042 00043 Pin() 00044 : m_particle(0) 00045 , m_r(0,0,0) 00046 {} 00047 00048 virtual ~Pin(){} 00049 00050 public: 00051 00055 void init(particle_type * particle) 00056 { 00057 assert(particle || !"Pin::init(): particle was null?"); 00058 00059 m_particle = particle; 00060 m_r = m_particle->position(); 00061 } 00062 00063 void satisfy() 00064 { 00065 if(!m_particle) 00066 return; 00067 m_particle->position() = m_r; 00068 } 00069 00070 }; 00071 00072 } // namespace psys 00073 } // namespace OpenTissue 00074 00075 // OPENTISSUE_DYNAMICS_PSYS_CONSTRAINTS_PSYS_PIN_H 00076 #endif