• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

Point.h

Go to the documentation of this file.
00001 // GMTL is (C) Copyright 2001-2010 by Allen Bierbaum
00002 // Distributed under the GNU Lesser General Public License 2.1 with an
00003 // addendum covering inlined code. (See accompanying files LICENSE and
00004 // LICENSE.addendum or http://www.gnu.org/copyleft/lesser.txt)
00005 
00006 #ifndef _GMTL_POINT_H_
00007 #define _GMTL_POINT_H_
00008 
00009 #include <gmtl/Defines.h>
00010 #include <gmtl/VecBase.h>
00011 
00012 namespace gmtl
00013 {
00014 
00029 template<class DATA_TYPE, unsigned SIZE>
00030 class Point : public VecBase<DATA_TYPE, SIZE>
00031 {
00032 public:
00033    typedef DATA_TYPE DataType;
00034    enum Params { Size = SIZE };
00035 
00037    typedef VecBase<DATA_TYPE, SIZE> BaseType;
00038    typedef Point<DATA_TYPE, SIZE> VecType;
00039 
00040 public:
00043    Point()
00044    {
00045       for (unsigned i = 0; i < SIZE; ++i)
00046          this->mData[i] = (DATA_TYPE)0;
00047    }
00048 
00053    /*
00054    Point(const Point<DATA_TYPE, SIZE>& rVec)
00055       : BaseType(static_cast<BaseType>(rVec))
00056    {;}
00057    */
00058 
00059 #ifdef GMTL_NO_METAPROG
00060    Point(const VecBase<DATA_TYPE, SIZE>& rVec)
00061       : BaseType(rVec)
00062    {;}
00063 #else
00064    template<typename REP2>
00065    Point( const VecBase<DATA_TYPE, SIZE, REP2>& rVec )
00066       : BaseType( rVec )
00067    {
00068    }
00069 #endif
00070 
00074    Point(const DATA_TYPE& val0,const DATA_TYPE& val1)
00075    : BaseType(val0, val1)
00076    {
00077       // @todo need compile time assert
00078       gmtlASSERT( SIZE == 2 && "out of bounds element access in Point" );
00079    }
00080 
00084    Point(const DATA_TYPE& val0,const DATA_TYPE& val1,const DATA_TYPE& val2)
00085    : BaseType(val0, val1, val2)
00086    {
00087       // @todo need compile time assert
00088       gmtlASSERT( SIZE == 3 && "out of bounds element access in Point" );
00089    }
00090 
00094    Point(const DATA_TYPE& val0,const DATA_TYPE& val1,const DATA_TYPE& val2,const DATA_TYPE& val3)
00095    : BaseType(val0, val1, val2, val3)
00096    {
00097       // @todo need compile time assert
00098       gmtlASSERT( SIZE == 4 && "out of bounds element access in Point" );
00099    }
00101 
00103 #ifdef GMTL_NO_METAPROG
00104    inline VecType& operator=(const VecBase<DATA_TYPE,SIZE>& rhs)
00105    {
00106       BaseType::operator=(rhs);
00107       return *this;
00108    }
00109 #else
00110    template<typename REP2>
00111    inline VecType& operator=(const VecBase<DATA_TYPE,SIZE,REP2>& rhs)
00112    {
00113       BaseType::operator=(rhs);
00114       return *this;
00115    }
00116 #endif
00117 
00118 };
00119 
00120 // --- helper types --- //
00121 typedef Point<int,2> Point2i;
00122 typedef Point<float,2> Point2f;
00123 typedef Point<double,2> Point2d;
00124 typedef Point<int, 3> Point3i;
00125 typedef Point<float,3> Point3f;
00126 typedef Point<double,3> Point3d;
00127 typedef Point<int, 4> Point4i;
00128 typedef Point<float,4> Point4f;
00129 typedef Point<double,4> Point4d;
00130 
00131 
00132 }
00133 
00134 #endif

Generated on Sun Sep 19 2010 14:35:14 for GenericMathTemplateLibrary by  doxygen 1.7.1