TAPs 0.7.7.3
TAPsTriangle.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsTriangle.hpp
00003 
00004 Triangle class is a class for 3D Triangle composed of three Vector3<T> as their 
00005 vertices.  The vertices must be listed in counter-clockwise direction.
00006 
00007 Example:
00008           2-------1
00009            \      |
00010             \     |
00011              \    |
00012               \   |
00013                \  |
00014                 \ |
00015                  \|
00016                   0
00017 
00018 SUKITTI PUNAK   (03/11/2006)
00019 UPDATE          (03/15/2006)
00020 ******************************************************************************/
00021 #ifndef TAPs_TRIANGLE_HPP
00022 #define TAPs_TRIANGLE_HPP
00023 
00024 #include "../Core/TAPsVector3.hpp"
00025 
00026 BEGIN_NAMESPACE_TAPs
00027 //=============================================================================
00028 template <typename T>
00029 class Triangle {
00030 //=============================================================================
00031 protected:
00032     Vector3<T>  m_vVertex[3];           // three vertices
00033 //=============================================================================
00034 public:
00035     //-------------------------------------------------------------------------
00036     // Output Operator <<
00037     friend std::ostream & operator<< ( std::ostream &output,  const Triangle<T> &f )
00038     {
00039         output  << "Triangle<" << typeid(T).name() << ">:  " 
00040                 << m_vVertex[0] << "  " 
00041                 << m_vVertex[1] << "  " 
00042                 << m_vVertex[2] << "\n";
00043         return output;
00044     }
00045     //-------------------------------------------------------------------------
00046     // Constructors and destructor
00047     Triangle ( Vector3<T> V0, Vector3<T> V1, Vector3<T> V2 );
00048     Triangle ( const T[3] V0, const T[3] V1, const T[3] V2 );
00049     Triangle ( T V0x, T V0y, T V0z, 
00050                T V1x, T V1y, T V1z, 
00051                T V2x, T V2y, T V2z );
00052     Triangle ( const Triangle<T> & tri );       // copy ctor
00053     virtual ~Triangle ();
00054     //-------------------------------------------------------------------------
00055     // Fn(s) for Normal
00056     Vector3<T> CalNormal() const;
00057     //-------------------------------------------------------------------------
00058     // Get/Set Fn(s)
00059     inline Vector3<T> & GetVertexNo ( int i )
00060         { assert( 0 <= i && i < 3 ); return m_vVertex[i]; }
00061     inline const Vector3<T> & GetVertexNo ( int i ) const
00062         { assert( 0 <= i && i < 3 ); return m_vVertex[i]; }
00063     inline void SetVertexNo ( int i, const Vector3<T> & v )
00064         { assert( 0 <= i && i < 3 ); m_vVertex[i] = v; }
00065     //-------------------------------------------------------------------------
00066     // Assignment (Conversion) Operator
00067     inline Triangle<T> & operator= ( Triangle<T> const & tri );
00068     //-------------------------------------------------------------------------
00069 }; // END CLASS Triangle
00070 //=============================================================================
00071 END_NAMESPACE_TAPs
00072 //-----------------------------------------------------------------------------
00073 // Include definition if TAPs_USE_EXPORT is not defined
00074 //#if !defined( TAPs_USE_EXPORT )
00075     #include "TAPsTriangle.cpp"
00076 //#endif
00077 //-----------------------------------------------------------------------------
00078 #endif
00079 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00080 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines