![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsHexBarycentricCoordsForVertexRef.cpp 00003 ******************************************************************************/ 00007 /****************************************************************************** 00008 SUKITTI PUNAK (01/08/2010) 00009 UPDATE (09/28/2010) 00010 ******************************************************************************/ 00011 #include "TAPsHexBarycentricCoordsForVertexRef.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, typename DATA> 00020 //HexBarycentricCoordsForVertexRef<T,DATA>::HexBarycentricCoordsForVertexRef () 00021 // : 00022 // m_pVertex( NULL ), m_pHexahedron( NULL ) 00023 //{} 00024 //----------------------------------------------------------------------------- 00025 template <typename T, typename DATA> 00026 HexBarycentricCoordsForVertexRef<T,DATA>::HexBarycentricCoordsForVertexRef ( 00027 Vector3<T> & vertex, 00028 unsigned int i, 00029 unsigned int j, 00030 unsigned int k, 00031 T u, 00032 T v, 00033 T w 00034 ) : BaseBarycentricCoordsForVertexRef( vertex, u, v, w ), 00035 m_locations( i, j, k ), m_pHexahedron( NULL ) 00036 {} 00037 //----------------------------------------------------------------------------- 00038 template <typename T, typename DATA> 00039 HexBarycentricCoordsForVertexRef<T,DATA>::HexBarycentricCoordsForVertexRef ( 00040 HexBarycentricCoordsForVertexRef<T,DATA> const & orig 00041 ) 00042 : BaseBarycentricCoordsForVertexRef<T>( orig ), 00043 m_locations( orig.m_locations ), m_pHexahedron( orig.m_pHexahedron ) 00044 {} 00045 //----------------------------------------------------------------------------- 00046 template <typename T, typename DATA> 00047 HexBarycentricCoordsForVertexRef<T,DATA>::~HexBarycentricCoordsForVertexRef () 00048 {} 00049 //----------------------------------------------------------------------------- 00050 template <typename T, typename DATA> 00051 HexBarycentricCoordsForVertexRef<T,DATA> & HexBarycentricCoordsForVertexRef<T,DATA>::operator= ( 00052 HexBarycentricCoordsForVertexRef<T,DATA> const & orig 00053 ) 00054 { 00055 // Inherited properties 00056 m_pVertex = orig.m_pVertex; 00057 m_coords = orig.m_coords; 00058 m_uiElementID = orig.m_uiElementID; 00059 // Added properties 00060 m_locations = orig.m_locations; 00061 m_pHexahedron = orig.m_pHexahedron; 00062 return *this; 00063 } 00064 //----------------------------------------------------------------------------- 00065 template <typename T, typename DATA> 00066 std::string HexBarycentricCoordsForVertexRef<T,DATA>::StrInfo () const 00067 { 00068 std::ostringstream ss; 00069 ss << "HexBarycentricCoordsForVertexRef<" << typeid(T).name() << ">"; 00070 ss << "ref vertex: " << *m_pVertex << " at location(x:" 00071 << (unsigned int)m_locations[0] << ", y:" << (unsigned int)m_locations[1] << ", z:" << (unsigned int)m_locations[2] 00072 << ") with coordinates " << m_coords 00073 << " and elementID " << m_uiElementID 00074 << " associated with hexahedron "; 00075 if ( m_pHexahedron ) { 00076 ss << *m_pHexahedron; 00077 } 00078 else { 00079 ss << "NULL\n"; 00080 } 00081 return ss.str(); 00082 } 00083 //----------------------------------------------------------------------------- 00084 template <typename T, typename DATA> 00085 void HexBarycentricCoordsForVertexRef<T,DATA>::ComputeNewVertexLocation ( 00086 T x0, T y0, T z0, 00087 T x1, T y1, T z1, 00088 T x2, T y2, T z2, 00089 T x3, T y3, T z3, 00090 T x4, T y4, T z4, 00091 T x5, T y5, T z5, 00092 T x6, T y6, T z6, 00093 T x7, T y7, T z7 00094 ) 00095 { 00096 T s0 = 1 - m_coords[0]; 00097 T s1 = 1 + m_coords[0]; 00098 T t0 = 1 - m_coords[1]; 00099 T t1 = 1 + m_coords[1]; 00100 T r0 = 1 - m_coords[2]; 00101 T r1 = 1 + m_coords[2]; 00102 00103 T N0 = s0 * t0 * r0; 00104 T N1 = s1 * t0 * r0; 00105 T N2 = s1 * t1 * r0; 00106 T N3 = s0 * t1 * r0; 00107 T N4 = s0 * t0 * r1; 00108 T N5 = s1 * t0 * r1; 00109 T N6 = s1 * t1 * r1; 00110 T N7 = s0 * t1 * r1; 00111 00112 T x = 0.125 * ( x0*N0 + x1*N1 + x2*N2 + x3*N3 + x4*N4 + x5*N5 + x6*N6 + x7*N7 ); 00113 T y = 0.125 * ( y0*N0 + y1*N1 + y2*N2 + y3*N3 + y4*N4 + y5*N5 + y6*N6 + y7*N7 ); 00114 T z = 0.125 * ( z0*N0 + z1*N1 + z2*N2 + z3*N3 + z4*N4 + z5*N5 + z6*N6 + z7*N7 ); 00115 00116 m_pVertex->SetXYZ( x, y, z ); 00117 } 00118 //----------------------------------------------------------------------------- 00119 template <typename T, typename DATA> 00120 void HexBarycentricCoordsForVertexRef<T,DATA>::ComputeNewVertexLocation () 00121 { 00122 T s0 = 1 - m_coords[0]; 00123 T s1 = 1 + m_coords[0]; 00124 T t0 = 1 - m_coords[1]; 00125 T t1 = 1 + m_coords[1]; 00126 T r0 = 1 - m_coords[2]; 00127 T r1 = 1 + m_coords[2]; 00128 00129 T N0 = s0 * t0 * r0; 00130 T N1 = s1 * t0 * r0; 00131 T N2 = s1 * t1 * r0; 00132 T N3 = s0 * t1 * r0; 00133 T N4 = s0 * t0 * r1; 00134 T N5 = s1 * t0 * r1; 00135 T N6 = s1 * t1 * r1; 00136 T N7 = s0 * t1 * r1; 00137 00138 T x = 0.125 * ( 00139 (*m_pHexahedron->DeformedNode(0))[0]*N0 + 00140 (*m_pHexahedron->DeformedNode(1))[0]*N1 + 00141 (*m_pHexahedron->DeformedNode(2))[0]*N2 + 00142 (*m_pHexahedron->DeformedNode(3))[0]*N3 + 00143 (*m_pHexahedron->DeformedNode(4))[0]*N4 + 00144 (*m_pHexahedron->DeformedNode(5))[0]*N5 + 00145 (*m_pHexahedron->DeformedNode(6))[0]*N6 + 00146 (*m_pHexahedron->DeformedNode(7))[0]*N7 ); 00147 T y = 0.125 * ( 00148 (*m_pHexahedron->DeformedNode(0))[1]*N0 + 00149 (*m_pHexahedron->DeformedNode(1))[1]*N1 + 00150 (*m_pHexahedron->DeformedNode(2))[1]*N2 + 00151 (*m_pHexahedron->DeformedNode(3))[1]*N3 + 00152 (*m_pHexahedron->DeformedNode(4))[1]*N4 + 00153 (*m_pHexahedron->DeformedNode(5))[1]*N5 + 00154 (*m_pHexahedron->DeformedNode(6))[1]*N6 + 00155 (*m_pHexahedron->DeformedNode(7))[1]*N7 ); 00156 T z = 0.125 * ( 00157 (*m_pHexahedron->DeformedNode(0))[2]*N0 + 00158 (*m_pHexahedron->DeformedNode(1))[2]*N1 + 00159 (*m_pHexahedron->DeformedNode(2))[2]*N2 + 00160 (*m_pHexahedron->DeformedNode(3))[2]*N3 + 00161 (*m_pHexahedron->DeformedNode(4))[2]*N4 + 00162 (*m_pHexahedron->DeformedNode(5))[2]*N5 + 00163 (*m_pHexahedron->DeformedNode(6))[2]*N6 + 00164 (*m_pHexahedron->DeformedNode(7))[2]*N7 ); 00165 00166 m_pVertex->SetXYZ( x, y, z ); 00167 } 00168 //----------------------------------------------------------------------------- 00169 template <typename T, typename DATA> 00170 Vector3<T> HexBarycentricCoordsForVertexRef<T,DATA>::GetNewVertexLocation () const 00171 { 00172 T s0 = 1 - m_coords[0]; 00173 T s1 = 1 + m_coords[0]; 00174 T t0 = 1 - m_coords[1]; 00175 T t1 = 1 + m_coords[1]; 00176 T r0 = 1 - m_coords[2]; 00177 T r1 = 1 + m_coords[2]; 00178 00179 T N0 = s0 * t0 * r0; 00180 T N1 = s1 * t0 * r0; 00181 T N2 = s1 * t1 * r0; 00182 T N3 = s0 * t1 * r0; 00183 T N4 = s0 * t0 * r1; 00184 T N5 = s1 * t0 * r1; 00185 T N6 = s1 * t1 * r1; 00186 T N7 = s0 * t1 * r1; 00187 00188 T x = 0.125 * ( 00189 (*m_pHexahedron->DeformedNode(0))[0]*N0 + 00190 (*m_pHexahedron->DeformedNode(1))[0]*N1 + 00191 (*m_pHexahedron->DeformedNode(2))[0]*N2 + 00192 (*m_pHexahedron->DeformedNode(3))[0]*N3 + 00193 (*m_pHexahedron->DeformedNode(4))[0]*N4 + 00194 (*m_pHexahedron->DeformedNode(5))[0]*N5 + 00195 (*m_pHexahedron->DeformedNode(6))[0]*N6 + 00196 (*m_pHexahedron->DeformedNode(7))[0]*N7 ); 00197 T y = 0.125 * ( 00198 (*m_pHexahedron->DeformedNode(0))[1]*N0 + 00199 (*m_pHexahedron->DeformedNode(1))[1]*N1 + 00200 (*m_pHexahedron->DeformedNode(2))[1]*N2 + 00201 (*m_pHexahedron->DeformedNode(3))[1]*N3 + 00202 (*m_pHexahedron->DeformedNode(4))[1]*N4 + 00203 (*m_pHexahedron->DeformedNode(5))[1]*N5 + 00204 (*m_pHexahedron->DeformedNode(6))[1]*N6 + 00205 (*m_pHexahedron->DeformedNode(7))[1]*N7 ); 00206 T z = 0.125 * ( 00207 (*m_pHexahedron->DeformedNode(0))[2]*N0 + 00208 (*m_pHexahedron->DeformedNode(1))[2]*N1 + 00209 (*m_pHexahedron->DeformedNode(2))[2]*N2 + 00210 (*m_pHexahedron->DeformedNode(3))[2]*N3 + 00211 (*m_pHexahedron->DeformedNode(4))[2]*N4 + 00212 (*m_pHexahedron->DeformedNode(5))[2]*N5 + 00213 (*m_pHexahedron->DeformedNode(6))[2]*N6 + 00214 (*m_pHexahedron->DeformedNode(7))[2]*N7 ); 00215 00216 return Vector3<T>( x, y, z ); 00217 } 00218 //----------------------------------------------------------------------------- 00219 //============================================================================= 00220 END_NAMESPACE_TAPs 00221 //34567890123456789012345678901234567890123456789012345678901234567890123456789 00222 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----