TAPs 0.7.7.3
TAPsBaseBarycentricCoordsForVertexRef.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsBaseBarycentricCoordsForVertexRef.cpp
00003 ******************************************************************************/
00007 /******************************************************************************
00008 SUKITTI PUNAK   (04/16/2010)
00009 UPDATE          (06/25/2010)
00010 ******************************************************************************/
00011 #include "TAPsBaseBarycentricCoordsForVertexRef.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 //BaseBarycentricCoordsForVertexRef<T>::BaseBarycentricCoordsForVertexRef ()
00021 //  : m_pVertex( NULL )
00022 //{}
00023 //-----------------------------------------------------------------------------
00024 template <typename T>
00025 BaseBarycentricCoordsForVertexRef<T>::BaseBarycentricCoordsForVertexRef ( 
00026     Vector3<T> & vertex,    
00027     T u,    
00028     T v,    
00029     T w     
00030 )   : m_pVertex( &vertex ), m_coords( u, v, w ), m_uiElementID( 0 )
00031 {}
00032 //-----------------------------------------------------------------------------
00033 template <typename T>
00034 BaseBarycentricCoordsForVertexRef<T>::BaseBarycentricCoordsForVertexRef (
00035     BaseBarycentricCoordsForVertexRef<T> const & orig
00036 )   : m_pVertex( orig.m_pVertex ), m_coords( orig.m_coords ), m_uiElementID( orig.m_uiElementID )
00037 {}
00038 //-----------------------------------------------------------------------------
00039 template <typename T>
00040 BaseBarycentricCoordsForVertexRef<T>::~BaseBarycentricCoordsForVertexRef ()
00041 {}  
00042 //-----------------------------------------------------------------------------
00043 template <typename T>
00044 BaseBarycentricCoordsForVertexRef<T> & BaseBarycentricCoordsForVertexRef<T>::operator= (
00045     BaseBarycentricCoordsForVertexRef<T> const & orig
00046 )
00047 {
00048     m_pVertex = orig.m_pVertex;
00049     m_coords = orig.m_coords;
00050     m_uiElementID = orig.m_uiElementID;
00051     return *this;
00052 }
00053 //-----------------------------------------------------------------------------
00054 template <typename T>
00055 std::string BaseBarycentricCoordsForVertexRef<T>::StrInfo () const
00056 {
00057     std::ostringstream ss;
00058     ss << "BaseBarycentricCoordsForVertexRef<" << typeid(T).name() << ">";
00059     ss << "ref vertex: " << *m_pVertex
00060         << ") with coordinates " << m_coords 
00061         << " and elementID " << m_uiElementID
00062         << "\n.";
00063     return ss.str();
00064 }
00065 //-----------------------------------------------------------------------------
00066 template <typename T>
00067 void BaseBarycentricCoordsForVertexRef<T>::ComputeNewVertexLocationBasedOnTetrahedralVertices (
00068     T x0, T y0, T z0,
00069     T x1, T y1, T z1,
00070     T x2, T y2, T z2,
00071     T x3, T y3, T z3
00072 )
00073 {
00074     T x = (x1-x0)*m_coords[0] + (x2-x0)*m_coords[1] + (x3-x0)*m_coords[2] + x0;
00075     T y = (y1-y0)*m_coords[0] + (y2-y0)*m_coords[1] + (y3-y0)*m_coords[2] + y0;
00076     T z = (z1-z0)*m_coords[0] + (z2-z0)*m_coords[1] + (z3-z0)*m_coords[2] + z0;
00077     m_pVertex->SetXYZ( x, y, z );
00078 }
00079 //-----------------------------------------------------------------------------
00080 template <typename T>
00081 void BaseBarycentricCoordsForVertexRef<T>::ComputeNewVertexLocationBasedOnHexahedralVertices (
00082     T x0, T y0, T z0,
00083     T x1, T y1, T z1,
00084     T x2, T y2, T z2,
00085     T x3, T y3, T z3,
00086     T x4, T y4, T z4,
00087     T x5, T y5, T z5,
00088     T x6, T y6, T z6,
00089     T x7, T y7, T z7
00090 )
00091 {
00092     T s0 = 1 - m_coords[0];
00093     T s1 = 1 + m_coords[0];
00094     T t0 = 1 - m_coords[1];
00095     T t1 = 1 + m_coords[1];
00096     T r0 = 1 - m_coords[2];
00097     T r1 = 1 + m_coords[2];
00098 
00099     T N0 = s0 * t0 * r0;
00100     T N1 = s1 * t0 * r0;
00101     T N2 = s1 * t1 * r0;
00102     T N3 = s0 * t1 * r0;
00103     T N4 = s0 * t0 * r1;
00104     T N5 = s1 * t0 * r1;
00105     T N6 = s1 * t1 * r1;
00106     T N7 = s0 * t1 * r1;
00107 
00108     T x = 0.125 * ( x0*N0 + x1*N1 + x2*N2 + x3*N3 + x4*N4 + x5*N5 + x6*N6 + x7*N7 );
00109     T y = 0.125 * ( y0*N0 + y1*N1 + y2*N2 + y3*N3 + y4*N4 + y5*N5 + y6*N6 + y7*N7 );
00110     T z = 0.125 * ( z0*N0 + z1*N1 + z2*N2 + z3*N3 + z4*N4 + z5*N5 + z6*N6 + z7*N7 );
00111 
00112     m_pVertex->SetXYZ( x, y, z );
00113 }
00114 //-----------------------------------------------------------------------------
00115 //=============================================================================
00116 END_NAMESPACE_TAPs
00117 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00118 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines