![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsTetBarycentricCoordsForVertexRef.cpp 00003 ******************************************************************************/ 00007 /****************************************************************************** 00008 SUKITTI PUNAK (03/16/2010) 00009 UPDATE (09/28/2010) 00010 ******************************************************************************/ 00011 #include "TAPsTetBarycentricCoordsForVertexRef.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 //----------------------------------------------------------------------------- 00019 //template <typename T> 00020 //TetBarycentricCoordsForVertexRef<T>::TetBarycentricCoordsForVertexRef () 00021 // : 00022 // m_pVertex( NULL ), m_pTetrahedron( NULL ) 00023 //{} 00024 //----------------------------------------------------------------------------- 00025 template <typename T> 00026 TetBarycentricCoordsForVertexRef<T>::TetBarycentricCoordsForVertexRef ( 00027 Vector3<T> & vertex, 00028 FEM::Tetrahedron<T> & tetrahedron, 00029 T u, 00030 T v, 00031 T w 00032 ) : BaseBarycentricCoordsForVertexRef( vertex, u, v, w), m_pTetrahedron( &tetrahedron ) 00033 {} 00034 //----------------------------------------------------------------------------- 00035 template <typename T> 00036 TetBarycentricCoordsForVertexRef<T>::TetBarycentricCoordsForVertexRef ( 00037 Vector3<T> & vertex, 00038 FEM::Tetrahedron<T> * pTetrahedron, 00039 T u, 00040 T v, 00041 T w 00042 ) : BaseBarycentricCoordsForVertexRef( vertex, u, v, w), m_pTetrahedron( pTetrahedron ) 00043 {} 00044 //----------------------------------------------------------------------------- 00045 template <typename T> 00046 TetBarycentricCoordsForVertexRef<T>::TetBarycentricCoordsForVertexRef ( 00047 TetBarycentricCoordsForVertexRef<T> const & orig 00048 ) 00049 : BaseBarycentricCoordsForVertexRef( orig ), 00050 m_pTetrahedron( orig.m_pTetrahedron ) 00051 {} 00052 //----------------------------------------------------------------------------- 00053 template <typename T> 00054 TetBarycentricCoordsForVertexRef<T>::~TetBarycentricCoordsForVertexRef () 00055 {} 00056 //----------------------------------------------------------------------------- 00057 template <typename T> 00058 TetBarycentricCoordsForVertexRef<T> & TetBarycentricCoordsForVertexRef<T>::operator= ( 00059 TetBarycentricCoordsForVertexRef<T> const & orig 00060 ) 00061 { 00062 // Inherited properties 00063 m_pVertex = orig.m_pVertex; 00064 m_coords = orig.m_coords; 00065 m_uiElementID = orig.m_uiElementID; 00066 // Added properties 00067 m_pTetrahedron = orig.m_pTetrahedron; 00068 return *this; 00069 } 00070 //----------------------------------------------------------------------------- 00071 template <typename T> 00072 std::string TetBarycentricCoordsForVertexRef<T>::StrInfo () const 00073 { 00074 std::ostringstream ss; 00075 ss << "TetBarycentricCoordsForVertexRef<" << typeid(T).name() << ">"; 00076 ss << "ref vertex: " << m_pVertex << " " << *m_pVertex 00077 << ") with coordinates " << &m_coords << " " << m_coords 00078 << " and elementID " << m_uiElementID 00079 << " associated with tetrahedron "; 00080 if ( m_pTetrahedron ) { 00081 ss << *m_pTetrahedron; 00082 } 00083 else { 00084 ss << "NULL\n"; 00085 } 00086 return ss.str(); 00087 } 00088 //----------------------------------------------------------------------------- 00089 template <typename T> 00090 void TetBarycentricCoordsForVertexRef<T>::ComputeNewVertexLocation () 00091 { 00092 Vector3<T> &T0 = *m_pTetrahedron->DeformedNode(0); 00093 Vector3<T> &T10 = *m_pTetrahedron->DeformedNode(1) - T0; 00094 Vector3<T> &T20 = *m_pTetrahedron->DeformedNode(2) - T0; 00095 Vector3<T> &T30 = *m_pTetrahedron->DeformedNode(3) - T0; 00096 00097 T x = T10[0]*m_coords[0] + T20[0]*m_coords[1] + T30[0]*m_coords[2] + T0[0]; 00098 T y = T10[1]*m_coords[0] + T20[1]*m_coords[1] + T30[1]*m_coords[2] + T0[1]; 00099 T z = T10[2]*m_coords[0] + T20[2]*m_coords[1] + T30[2]*m_coords[2] + T0[2]; 00100 00101 m_pVertex->SetXYZ( x, y, z ); 00102 } 00103 //----------------------------------------------------------------------------- 00104 template <typename T> 00105 Vector3<T> TetBarycentricCoordsForVertexRef<T>::GetNewVertexLocation () const 00106 { 00107 Vector3<T> &T0 = *m_pTetrahedron->DeformedNode(0); 00108 Vector3<T> &T10 = *m_pTetrahedron->DeformedNode(1) - T0; 00109 Vector3<T> &T20 = *m_pTetrahedron->DeformedNode(2) - T0; 00110 Vector3<T> &T30 = *m_pTetrahedron->DeformedNode(3) - T0; 00111 00112 T x = T10[0]*m_coords[0] + T20[0]*m_coords[1] + T30[0]*m_coords[2] + T0[0]; 00113 T y = T10[1]*m_coords[0] + T20[1]*m_coords[1] + T30[1]*m_coords[2] + T0[1]; 00114 T z = T10[2]*m_coords[0] + T20[2]*m_coords[1] + T30[2]*m_coords[2] + T0[2]; 00115 00116 return Vector3<T>( x, y, z ); 00117 } 00118 //----------------------------------------------------------------------------- 00119 //============================================================================= 00120 END_NAMESPACE_TAPs 00121 //34567890123456789012345678901234567890123456789012345678901234567890123456789 00122 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----