![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsParticleBase.hpp 00003 ******************************************************************************/ 00007 /****************************************************************************** 00008 SUKITTI PUNAK (08/06/2010) 00009 UPDATE (03/22/2011) 00010 ******************************************************************************/ 00011 #include "TAPsParticleBase.hpp" 00012 // Using Inclusion Model (i.e. definitions are included in declarations) 00013 // (this name.cpp is included in name.hpp) 00014 // Each friend is defined directly inside its declaration. 00015 00016 BEGIN_NAMESPACE_TAPs 00017 //============================================================================= 00018 // Constructors and Destructor 00019 //----------------------------------------------------------------------------- 00020 // ParticleBase Default Constructor 00021 template <typename T> 00022 ParticleBase<T>::ParticleBase () : m_tMass( 1 ), m_bFixed( false ) 00023 {} 00024 //----------------------------------------------------------------------------- 00025 // ParticleBase Constructor 00026 template <typename T> 00027 ParticleBase<T>::ParticleBase 00028 ( 00029 T mass, 00030 //Vector3<T> const & vPosition, 00031 Vector3<T> const & vVelocity, 00032 Vector3<T> const & vAcceleration, 00033 Vector3<T> const & vForce, 00034 bool fixed 00035 ) : 00036 m_tMass( mass ), 00037 //m_vtPosit( vPosition ), 00038 m_vtVeloc( vVelocity ), 00039 m_vtAccel( vAcceleration ), 00040 m_vtForce( vForce ), 00041 m_bFixed( fixed ) 00042 { 00043 //m_vtNormal will be initialized to zero 00044 } 00045 //----------------------------------------------------------------------------- 00046 // ParticleBase Copy Constructor 00047 template <typename T> 00048 ParticleBase<T>::ParticleBase ( ParticleBase<T> const &P ) 00049 : m_tMass( P.m_tMass ), 00050 //m_vtPosit( P.m_vtPosit ), 00051 m_vtVeloc( P.m_vtVeloc ), 00052 m_vtAccel( P.m_vtAccel ), 00053 m_vtForce( P.m_vtForce ), 00054 m_bFixed( P.m_bFixed ) 00055 //m_vtNormal( P.m_vtNormal ) 00056 {} 00057 //----------------------------------------------------------------------------- 00058 // ParticleBase Destructor 00059 template <typename T> 00060 ParticleBase<T>::~ParticleBase () 00061 {} 00062 //----------------------------------------------------------------------------- 00063 // Return this object info as a string 00064 template <typename T> 00065 std::string ParticleBase<T>::StrInfo () const 00066 { 00067 std::stringstream ss; 00068 ss << "ParticleBase<" << typeid(T).name() << "> ==> " 00069 << "\n Mass: " << m_tMass 00070 //<< "\n Normal: " << P.m_vtNormal 00071 //<< "\n Position: " << P.m_vtPosit 00072 << "\n Velocity: " << m_vtVeloc 00073 << "\n Acceleration: " << m_vtAccel 00074 << "\n Force: " << m_vtForce 00075 << "\n Fix Status: " << ( m_bFixed == true ? "true" : "false" ) 00076 << "\n"; 00077 return ss.str(); 00078 } 00079 //----------------------------------------------------------------------------- 00080 //============================================================================= 00081 // ParticleBase Assignment Operator 00082 //----------------------------------------------------------------------------- 00083 template <typename T> 00084 ParticleBase<T> const & ParticleBase<T>::operator= ( ParticleBase<T> const &P ) 00085 { 00086 if ( this != &P ) 00087 { 00088 m_tMass = P.m_tMass; 00089 //m_vtNormal = P.m_vtNormal; 00090 //m_vtPosit = P.m_vtPosit; 00091 m_vtVeloc = P.m_vtVeloc; 00092 m_vtAccel = P.m_vtAccel; 00093 m_vtForce = P.m_vtForce; 00094 m_bFixed = P.m_bFixed; 00095 } 00096 return *this; 00097 } 00098 //============================================================================= 00099 // Get/Set Functions 00100 //----------------------------------------------------------------------------- 00101 template <typename T> 00102 inline T ParticleBase<T>::GetMass () const 00103 { return m_tMass; } 00104 //----------------------------------------------------------------------------- 00105 template <typename T> 00106 inline void ParticleBase<T>::SetMass ( T m ) 00107 { m_tMass = m; } 00108 //----------------------------------------------------------------------------- 00109 template <typename T> 00110 inline Vector3<T> const & ParticleBase<T>::RefToVelocity () const 00111 { return m_vtVeloc; } 00112 //----------------------------------------------------------------------------- 00113 template <typename T> 00114 inline Vector3<T> & ParticleBase<T>::RefToVelocity () 00115 { return m_vtVeloc; } 00116 //----------------------------------------------------------------------------- 00117 template <typename T> 00118 inline Vector3<T> const & ParticleBase<T>::GetVelocity () const 00119 { return m_vtVeloc; } 00120 //----------------------------------------------------------------------------- 00121 template <typename T> 00122 inline void ParticleBase<T>::SetVelocity ( Vector3<T> const &v ) 00123 { m_vtVeloc = v; } 00124 //----------------------------------------------------------------------------- 00125 template <typename T> 00126 inline void ParticleBase<T>::SetVelocity ( T x, T y, T z ) 00127 { m_vtVeloc.SetXYZ( x, y, z ); } 00128 //----------------------------------------------------------------------------- 00129 template <typename T> 00130 inline Vector3<T> const & ParticleBase<T>::RefToAcceleration () const 00131 { return m_vtAccel; } 00132 //----------------------------------------------------------------------------- 00133 template <typename T> 00134 inline Vector3<T> & ParticleBase<T>::RefToAcceleration () 00135 { return m_vtAccel; } 00136 //----------------------------------------------------------------------------- 00137 template <typename T> 00138 inline Vector3<T> const & ParticleBase<T>::GetAcceleration () const 00139 { return m_vtAccel; } 00140 //----------------------------------------------------------------------------- 00141 template <typename T> 00142 inline void ParticleBase<T>::SetAcceleration ( Vector3<T> const &v ) 00143 { m_vtAccel = v; } 00144 //----------------------------------------------------------------------------- 00145 template <typename T> 00146 inline void ParticleBase<T>::SetAcceleration ( T x, T y, T z ) 00147 { m_vtAccel.SetXYZ( x, y, z ); } 00148 //----------------------------------------------------------------------------- 00149 template <typename T> 00150 inline Vector3<T> const & ParticleBase<T>::RefToForce () const 00151 { return m_vtForce; } 00152 //----------------------------------------------------------------------------- 00153 template <typename T> 00154 inline Vector3<T> & ParticleBase<T>::RefToForce () 00155 { return m_vtForce; } 00156 //----------------------------------------------------------------------------- 00157 template <typename T> 00158 inline Vector3<T> const & ParticleBase<T>::GetForce () const 00159 { return m_vtForce; } 00160 //----------------------------------------------------------------------------- 00161 template <typename T> 00162 inline void ParticleBase<T>::SetForce ( Vector3<T> const &v ) 00163 { m_vtForce = v; } 00164 //----------------------------------------------------------------------------- 00165 template <typename T> 00166 inline void ParticleBase<T>::SetForce ( T x, T y, T z ) 00167 { m_vtForce.SetXYZ( x, y, z ); } 00168 //----------------------------------------------------------------------------- 00169 template <typename T> 00170 inline bool ParticleBase<T>::GetFixStatus () const 00171 { return m_bFixed; } 00172 //----------------------------------------------------------------------------- 00173 template <typename T> 00174 inline void ParticleBase<T>::SetFixStatus ( bool b ) 00175 { m_bFixed = b; } 00176 //----------------------------------------------------------------------------- 00177 //============================================================================= 00178 END_NAMESPACE_TAPs 00179 //345678901234567890123456789012345678901234567890123456789012345678901234567890 00180 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8