![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsInteractionPoint.cpp 00003 ******************************************************************************/ 00007 /****************************************************************************** 00008 SUKITTI PUNAK (07/23/2010) 00009 UPDATE (10/28/2010) 00010 ******************************************************************************/ 00011 #include "TAPsInteractionPoint.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 00019 //----------------------------------------------------------------------------- 00020 template <typename T> 00021 InteractionPoint<T>::InteractionPoint ( typename PointMass<T>::Type typeOfPointMass, unsigned int id ) 00022 : m_id( id ) 00023 { 00024 CreatePointMass( typeOfPointMass ); 00025 } 00026 //----------------------------------------------------------------------------- 00027 template <typename T> 00028 InteractionPoint<T>::InteractionPoint ( Vector3<T> const &location, typename PointMass<T>::Type typeOfPointMass, unsigned int id ) 00029 : m_id( id ) 00030 { 00031 CreatePointMass( typeOfPointMass ); 00032 SetPosition( location ); 00033 } 00034 //----------------------------------------------------------------------------- 00035 template <typename T> 00036 InteractionPoint<T>::InteractionPoint ( T const location[3], typename PointMass<T>::Type typeOfPointMass, unsigned int id ) 00037 : m_id( id ) 00038 { 00039 CreatePointMass( typeOfPointMass ); 00040 SetPosition( Vector3<T>( location ) ); 00041 } 00042 //----------------------------------------------------------------------------- 00043 template <typename T> 00044 InteractionPoint<T>::InteractionPoint ( T locX, T locY, T locZ, typename PointMass<T>::Type typeOfPointMass, unsigned int id ) 00045 : m_id( id ) 00046 { 00047 CreatePointMass( typeOfPointMass ); 00048 SetPosition( Vector3<T>( locX, locY, locZ ) ); 00049 } 00050 //----------------------------------------------------------------------------- 00051 template <typename T> 00052 InteractionPoint<T>::InteractionPoint ( InteractionPoint<T> const &orig ) 00053 : m_id( orig.m_id ) 00054 { 00055 CreatePointMass( orig.PtrToPointMass()->GetType() ); 00056 *m_pPointMass = *(orig.PtrToPointMass()); 00057 } 00058 //----------------------------------------------------------------------------- 00059 template <typename T> 00060 InteractionPoint<T>::~InteractionPoint () 00061 { 00062 DeletePointMass(); 00063 } 00064 //----------------------------------------------------------------------------- 00065 template <typename T> 00066 std::string InteractionPoint<T>::StrInfo () const 00067 { 00068 std::ostringstream ss; 00069 ss << "InteractionPoint<" << typeid(T).name() << ">"; 00070 ss << " has id of " << m_id; 00071 ss << " and is a point mass of " << *PtrToPointMass(); 00072 ss << "\n"; 00073 return ss.str(); 00074 } 00075 //----------------------------------------------------------------------------- 00076 //============================================================================= 00077 // Assignment Operator 00078 //----------------------------------------------------------------------------- 00079 template <typename T> 00080 InteractionPoint<T> & InteractionPoint<T>::operator= ( InteractionPoint<T> const &orig ) 00081 { 00082 DeletePointMass(); 00083 CreatePointMass( orig.PtrToPointMass()->GetType() ); 00084 *m_pPointMass = *(orig.PtrToPointMass()); 00085 m_id = orig.m_id; 00086 return *this; 00087 } 00088 //----------------------------------------------------------------------------- 00089 //----------------------------------------------------------------------------- 00090 template <typename T> 00091 void InteractionPoint<T>::CreatePointMass ( typename PointMass<T>::Type typeOfPointMass ) 00092 { 00093 switch ( typeOfPointMass ) { 00094 case PointMass<T>::TYPE_STATIC: 00095 m_pPointMass = new PointMass<T>(); 00096 break; 00097 case PointMass<T>::TYPE_DYNAMIC: 00098 m_pPointMass = new PointMassDynamic<T>(); 00099 break; 00100 case PointMass<T>::TYPE_DYNAMIC_WITH_ORIENTATION: 00101 m_pPointMass = new PointMassDynamicWithQuaternionRotation<T>(); 00102 break; 00103 } 00104 } 00105 //----------------------------------------------------------------------------- 00106 template <typename T> 00107 void InteractionPoint<T>::DeletePointMass () 00108 { 00109 if ( m_pPointMass ) { 00110 delete m_pPointMass; 00111 m_pPointMass = NULL; 00112 } 00113 } 00114 //----------------------------------------------------------------------------- 00115 //============================================================================= 00116 // Get/Set & Operations 00117 //----------------------------------------------------------------------------- 00118 template <typename T> 00119 unsigned int InteractionPoint<T>::GetID () const 00120 { 00121 return m_id; 00122 } 00123 //----------------------------------------------------------------------------- 00124 template <typename T> 00125 void InteractionPoint<T>::SetID ( unsigned int id ) 00126 { 00127 m_id = id; 00128 } 00129 //----------------------------------------------------------------------------- 00130 template <typename T> 00131 Vector3<T> const & InteractionPoint<T>::GetPosition () const 00132 { 00133 return m_pPointMass->GetPosition(); 00134 } 00135 //----------------------------------------------------------------------------- 00136 template <typename T> 00137 Vector3<T> & InteractionPoint<T>::GetPosition () 00138 { 00139 return m_pPointMass->GetPosition(); 00140 } 00141 //----------------------------------------------------------------------------- 00142 template <typename T> 00143 void InteractionPoint<T>::SetPosition ( Vector3<T> const & position ) 00144 { 00145 return m_pPointMass->SetPosition( position ); 00146 } 00147 //----------------------------------------------------------------------------- 00148 template <typename T> 00149 T InteractionPoint<T>::GetSize () const 00150 { 00151 return m_pPointMass->GetSize(); 00152 } 00153 //----------------------------------------------------------------------------- 00154 template <typename T> 00155 void InteractionPoint<T>::SetSize ( T size ) 00156 { 00157 m_pPointMass->SetSize( size ); 00158 } 00159 //----------------------------------------------------------------------------- 00160 template <typename T> 00161 T InteractionPoint<T>::GetMass () const 00162 { 00163 return m_pPointMass->GetMass(); 00164 } 00165 //----------------------------------------------------------------------------- 00166 template <typename T> 00167 void InteractionPoint<T>::SetMass ( T mass ) 00168 { 00169 m_pPointMass->SetMass( mass ); 00170 } 00171 //----------------------------------------------------------------------------- 00172 template <typename T> 00173 DS::SimulationFlags const & InteractionPoint<T>::GetSimFlags () const 00174 { 00175 return m_pPointMass->GetFlags(); 00176 } 00177 //----------------------------------------------------------------------------- 00178 template <typename T> 00179 DS::SimulationFlags & InteractionPoint<T>::GetSimFlags () 00180 { 00181 return m_pPointMass->GetFlags(); 00182 } 00183 //----------------------------------------------------------------------------- 00184 template <typename T> 00185 PointMass<T> const * InteractionPoint<T>::PtrToPointMass () const 00186 { 00187 return m_pPointMass; 00188 } 00189 //----------------------------------------------------------------------------- 00190 template <typename T> 00191 PointMass<T> * InteractionPoint<T>::PtrToPointMass () 00192 { 00193 return m_pPointMass; 00194 } 00195 //----------------------------------------------------------------------------- 00196 template <typename T> 00197 bool InteractionPoint<T>::CompareDistanceFromOriginPos_LessThan ( InteractionPoint<T> A, InteractionPoint<T> B ) 00198 { 00199 return A.GetPosition().Length() < B.GetPosition().Length(); 00200 } 00201 //----------------------------------------------------------------------------- 00202 template <typename T> 00203 bool InteractionPoint<T>::CompareDistanceFromOriginPos_GreaterThan ( InteractionPoint<T> A, InteractionPoint<T> B ) 00204 { 00205 return A.GetPosition().Length() > B.GetPosition().Length(); 00206 } 00207 //----------------------------------------------------------------------------- 00208 //============================================================================= 00209 END_NAMESPACE_TAPs 00210 //34567890123456789012345678901234567890123456789012345678901234567890123456789 00211 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----