HexahedronCube< T > Class Template Reference

#include <TAPsHexahedronCube.hpp>

Inheritance diagram for HexahedronCube< T >:

Inheritance graph
[legend]
Collaboration diagram for HexahedronCube< T >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 HexahedronCube (Vector3< T > const p[8])
 HexahedronCube ()
virtual ~HexahedronCube ()

Protected Types

typedef std::vector< int > LIST

Protected Member Functions

virtual void CalNormals ()
virtual void Setup ()

Static Protected Member Functions

static void SetupStaticMembers ()

Static Protected Attributes

static bool m_gbHasBeenSet = false
static std::vector< LIST >
::iterator 
m_itor
static std::vector< LISTm_vFace
static std::vector< LISTm_vVertexFace
static std::vector< LISTm_vVertexValence


Detailed Description

template<typename T>
class HexahedronCube< T >

Definition at line 21 of file TAPsHexahedronCube.hpp.


Member Typedef Documentation

template<typename T>
typedef std::vector<int> HexahedronCube< T >::LIST [protected]

Definition at line 27 of file TAPsHexahedronCube.hpp.


Constructor & Destructor Documentation

template<typename T>
HexahedronCube< T >::HexahedronCube (  )  [inline]

Definition at line 38 of file TAPsHexahedronCube.cpp.

00039     : AbstractPolyhedron<T>( 8, 6 )
00040 {
00041     // Point Numbering:
00042     // ----------------
00043     // with the right-handed coordinate system
00044     //           7        6
00045     //           +--------+            y
00046     //          /|       /|            |
00047     //         / |      / |            |
00048     //       3+--------+2 |            |________x
00049     //        | 4+-----|--+5          /
00050     //        | /      | /           /
00051     //        |/       |/           z
00052     //        +--------+
00053     //        0        1
00054     //----------------------------------------------------------------
00055     m_vVertex[0] = Vector3<T>( 0, 0, 1 );
00056     m_vVertex[1] = Vector3<T>( 1, 0, 1 );
00057     m_vVertex[2] = Vector3<T>( 1, 1, 1 );
00058     m_vVertex[3] = Vector3<T>( 0, 1, 1 );
00059     m_vVertex[4] = Vector3<T>( 0, 0, 0 );
00060     m_vVertex[5] = Vector3<T>( 1, 0, 0 );
00061     m_vVertex[6] = Vector3<T>( 1, 1, 0 );
00062     m_vVertex[7] = Vector3<T>( 0, 1, 0 );
00063     Setup();
00064 }

template<typename T>
HexahedronCube< T >::HexahedronCube ( Vector3< T > const   p[8]  )  [inline]

Definition at line 67 of file TAPsHexahedronCube.cpp.

00068     : AbstractPolyhedron<T>( 8, 6 )
00069 {
00070     // Point Numbering:
00071     // ----------------
00072     // with the right-handed coordinate system
00073     //           7        6
00074     //           +--------+            y
00075     //          /|       /|            |
00076     //         / |      / |            |
00077     //       3+--------+2 |            |________x
00078     //        | 4+-----|--+5          /
00079     //        | /      | /           /
00080     //        |/       |/           z
00081     //        +--------+
00082     //        0        1
00083     //----------------------------------------------------------------
00084     m_vVertex[0] = p[0];
00085     m_vVertex[1] = p[1];
00086     m_vVertex[2] = p[2];
00087     m_vVertex[3] = p[3];
00088     m_vVertex[4] = p[4];
00089     m_vVertex[5] = p[5];
00090     m_vVertex[6] = p[6];
00091     m_vVertex[7] = p[7];
00092     Setup();
00093 }

template<typename T>
HexahedronCube< T >::~HexahedronCube (  )  [inline, virtual]

Definition at line 96 of file TAPsHexahedronCube.cpp.

00097 {}


Member Function Documentation

template<typename T>
void HexahedronCube< T >::CalNormals (  )  [inline, protected, virtual]

Implements AbstractPolyhedron< T >.

Definition at line 237 of file TAPsHexahedronCube.cpp.

00238 {
00239     // Assume all faces are planer which works perfectly for triangular faces
00240     //----------------------------------------------------------------
00241     // Calculate Face Normals (Unnormalized)
00242     int p = 0;
00243     for ( m_itor = m_vFace.begin(); m_itor != m_vFace.end(); ++m_itor, ++p ) {
00244         m_vFaceNormal[p] = ( m_vVertex[(*m_itor)[1]] - m_vVertex[(*m_itor)[0]] )
00245                          ^ ( m_vVertex[(*m_itor)[2]] - m_vVertex[(*m_itor)[0]] );
00246     }
00247     //----------------------------------------------------------------
00248     // Calculate Vertex Normals
00249     for ( p = 0; p < 8; ++p ) {
00250         m_vVertexNormal[p].SetXYZ( 0, 0, 0);
00251         for ( int i = 0; i < static_cast<int>( m_vVertexFace[p].size() ); ++i ) {
00252             m_vVertexNormal[p] += m_vFaceNormal[ m_vVertexFace[p][i] ];
00253         }
00254         m_vVertexNormal[p].Normalized();
00255         std::cout << m_vVertexNormal[p] << std::endl;
00256     }
00257     //----------------------------------------------------------------
00258     // Normalize Face Normals
00259     for ( p = 0; p < static_cast<int>(m_vFaceNormal.size()); ++p ) {
00260         m_vFaceNormal[p].Normalized();
00261         //std::cout << m_vFaceNormal[p] << std::endl;
00262         //m_vVertexNormal[p] = m_vFaceNormal[p];
00263     }
00264 }

template<typename T>
void HexahedronCube< T >::Setup (  )  [inline, protected, virtual]

Implements AbstractPolyhedron< T >.

Definition at line 217 of file TAPsHexahedronCube.cpp.

00218 {
00219     // REMARK:
00220     // =======
00221     // In theory, we should be able to set m_gbHasBeenSet to true.
00222     // However, calling DrawByOpenGL fn will have static member size equals zero.
00223     // Therefore, we will set it to true in DrawByOpenGL fn.
00224     // See DrawByOpenGL source code below.
00225     // I believe this must be an effect from DrawByOpenGL is passed as an 
00226     // argument to a function.
00227     if ( !m_gbHasBeenSet ) {
00228         //m_gbHasBeenSet = true;
00229         SetupStaticMembers();
00230     }
00231     //----------------------------------------------------------------
00232     CalNormals();
00233 }

template<typename T>
void HexahedronCube< T >::SetupStaticMembers (  )  [inline, static, protected]

Definition at line 104 of file TAPsHexahedronCube.cpp.

00105 {
00106     //----------------------------------------------------------------
00107     m_vVertexValence.resize(8);
00108     m_vVertexFace.resize(8);
00109     m_vFace.resize(6);
00110     //----------------------------------------------------------------
00111     // Initialize Vertex Valence
00112     //----------------------------------------------------------------
00113     // Vertex#0: 1 3 4 ----------------
00114     m_vVertexValence[0].push_back( 1 );
00115     m_vVertexValence[0].push_back( 3 );
00116     m_vVertexValence[0].push_back( 4 );
00117     // Vertex#1: 0 2 5 ----------------
00118     m_vVertexValence[1].push_back( 0 );
00119     m_vVertexValence[1].push_back( 2 );
00120     m_vVertexValence[1].push_back( 5 );
00121     // Vertex#2: 1 3 6 ----------------
00122     m_vVertexValence[2].push_back( 1 );
00123     m_vVertexValence[2].push_back( 3 );
00124     m_vVertexValence[2].push_back( 6 );
00125     // Vertex#3: 0 2 7 ----------------
00126     m_vVertexValence[3].push_back( 0 );
00127     m_vVertexValence[3].push_back( 2 );
00128     m_vVertexValence[3].push_back( 7 );
00129     // Vertex#4: 0 5 7 ----------------
00130     m_vVertexValence[4].push_back( 0 );
00131     m_vVertexValence[4].push_back( 5 );
00132     m_vVertexValence[4].push_back( 7 );
00133     // Vertex#5: 1 4 6 ----------------
00134     m_vVertexValence[5].push_back( 1 );
00135     m_vVertexValence[5].push_back( 4 );
00136     m_vVertexValence[5].push_back( 6 );
00137     // Vertex#6: 2 5 7 ----------------
00138     m_vVertexValence[6].push_back( 2 );
00139     m_vVertexValence[6].push_back( 5 );
00140     m_vVertexValence[6].push_back( 7 );
00141     // Vertex#7: 3 4 6 ----------------
00142     m_vVertexValence[7].push_back( 3 );
00143     m_vVertexValence[7].push_back( 4 );
00144     m_vVertexValence[7].push_back( 6 );
00145     //----------------------------------------------------------------
00146     // Initialize Face List
00147     //----------------------------------------------------------------
00148     // Face#0: 0 1 2 3 --------- (front)
00149     m_vFace[0].push_back( 0 );
00150     m_vFace[0].push_back( 1 );
00151     m_vFace[0].push_back( 2 );
00152     m_vFace[0].push_back( 3 );
00153     // Face#1: 1 5 6 2 --------- (right)
00154     m_vFace[1].push_back( 1 );
00155     m_vFace[1].push_back( 5 );
00156     m_vFace[1].push_back( 6 );
00157     m_vFace[1].push_back( 2 );
00158     // Face#2: 7 6 5 4 --------- (back)
00159     m_vFace[2].push_back( 7 );
00160     m_vFace[2].push_back( 6 );
00161     m_vFace[2].push_back( 5 );
00162     m_vFace[2].push_back( 4 );
00163     // Face#3: 0 3 7 4 --------- (left)
00164     m_vFace[3].push_back( 0 );
00165     m_vFace[3].push_back( 3 );
00166     m_vFace[3].push_back( 7 );
00167     m_vFace[3].push_back( 4 );
00168     // Face#4: 0 4 5 1 --------- (bottom)
00169     m_vFace[4].push_back( 0 );
00170     m_vFace[4].push_back( 4 );
00171     m_vFace[4].push_back( 5 );
00172     m_vFace[4].push_back( 1 );
00173     // Face#5: 2 6 7 3 --------- (top)
00174     m_vFace[5].push_back( 2 );
00175     m_vFace[5].push_back( 6 );
00176     m_vFace[5].push_back( 7 );
00177     m_vFace[5].push_back( 3 );
00178     //----------------------------------------------------------------
00179     // Initialize Vertex Face List (face that has this vertex)
00180     //----------------------------------------------------------------
00181     // Vertex#0: 0 3 4 ---------
00182     m_vVertexFace[0].push_back( 0 );
00183     m_vVertexFace[0].push_back( 3 );
00184     m_vVertexFace[0].push_back( 4 );
00185     // Vertex#1: 0 1 4 ---------
00186     m_vVertexFace[1].push_back( 0 );
00187     m_vVertexFace[1].push_back( 1 );
00188     m_vVertexFace[1].push_back( 4 );
00189     // Vertex#2: 0 1 5 ---------
00190     m_vVertexFace[2].push_back( 0 );
00191     m_vVertexFace[2].push_back( 1 );
00192     m_vVertexFace[2].push_back( 5 );
00193     // Vertex#3: 0 3 5 ---------
00194     m_vVertexFace[3].push_back( 0 );
00195     m_vVertexFace[3].push_back( 3 );
00196     m_vVertexFace[3].push_back( 5 );
00197     // Vertex#4: 2 3 4 ---------
00198     m_vVertexFace[4].push_back( 2 );
00199     m_vVertexFace[4].push_back( 3 );
00200     m_vVertexFace[4].push_back( 4 );
00201     // Vertex#5: 1 2 4 ---------
00202     m_vVertexFace[5].push_back( 1 );
00203     m_vVertexFace[5].push_back( 2 );
00204     m_vVertexFace[5].push_back( 4 );
00205     // Vertex#6: 1 2 5 ---------
00206     m_vVertexFace[6].push_back( 1 );
00207     m_vVertexFace[6].push_back( 2 );
00208     m_vVertexFace[6].push_back( 5 );
00209     // Vertex#7: 2 3 5 ---------
00210     m_vVertexFace[7].push_back( 2 );
00211     m_vVertexFace[7].push_back( 3 );
00212     m_vVertexFace[7].push_back( 5 );
00213 }


Member Data Documentation

template<typename T>
BEGIN_NAMESPACE_TAPs bool HexahedronCube< T >::m_gbHasBeenSet = false [inline, static, protected]

Definition at line 26 of file TAPsHexahedronCube.hpp.

template<typename T>
std::vector< std::vector< int > >::iterator HexahedronCube< T >::m_itor [inline, static, protected]

Definition at line 31 of file TAPsHexahedronCube.hpp.

template<typename T>
std::vector< std::vector< int > > HexahedronCube< T >::m_vFace [inline, static, protected]

Definition at line 30 of file TAPsHexahedronCube.hpp.

template<typename T>
std::vector< std::vector< int > > HexahedronCube< T >::m_vVertexFace [inline, static, protected]

Definition at line 29 of file TAPsHexahedronCube.hpp.

template<typename T>
std::vector< std::vector< int > > HexahedronCube< T >::m_vVertexValence [inline, static, protected]

Definition at line 28 of file TAPsHexahedronCube.hpp.


The documentation for this class was generated from the following files:

Generated on Mon Oct 13 11:45:05 2008 for TAPs by  doxygen 1.5.6