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