vtf-logo

Triangle.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00008 #if !defined(__geom_Triangle_h__)
00009 #define __geom_Triangle_h__
00010 
00011 // If we are debugging the whole geom namespace.
00012 #if defined(DEBUG_geom) && !defined(DEBUG_Triangle)
00013 #define DEBUG_Triangle
00014 #endif
00015 
00016 #ifdef DEBUG_Triangle
00017 #ifndef DEBUG_Plane
00018 #define DEBUG_Plane
00019 #endif
00020 #endif
00021 
00022 #include "Plane.h"
00023 
00024 BEGIN_NAMESPACE_GEOM
00025 
00027 
00031 template<int N, typename T = double>
00032 class Triangle {
00033   //
00034   // Public types.
00035   //
00036 
00037 public:
00038 
00040   typedef ads::FixedArray<N,T> Point;
00041 
00042   //
00043   // Data
00044   //
00045 
00046 private:
00047 
00048   ads::FixedArray<3,Point> _vertices;
00049 
00050 public:
00051 
00052   //--------------------------------------------------------------------------
00054   // @{
00055 
00057   Triangle() 
00058   {}
00059 
00061   Triangle(const Point& a, const Point& b, const Point& c) {
00062     _vertices[0] = a;
00063     _vertices[1] = b;
00064     _vertices[2] = c;
00065   }
00066 
00068   Triangle(const Triangle& other)
00069   {
00070     _vertices[0] = other._vertices[0];
00071     _vertices[1] = other._vertices[1];
00072     _vertices[2] = other._vertices[2];
00073   }
00074 
00076   const Triangle& 
00077   operator=(const Triangle& other);
00078 
00080   ~Triangle() 
00081   {}
00082 
00083   // @}
00084   //--------------------------------------------------------------------------
00086   // @{
00087 
00089   const Point&
00090   getVertex(const int n) const { 
00091     return _vertices[n]; 
00092   }
00093 
00094   // @}
00095   //--------------------------------------------------------------------------
00097   // @{
00098 
00100   void
00101   setVertex(const int n, const Point& x) const { 
00102     _vertices[n] = x; 
00103   }
00104 
00105   // @}
00106   //--------------------------------------------------------------------------
00108   // @{
00109 
00111   Triangle& 
00112   operator+=(const Point& p);
00113 
00115   Triangle& 
00116   operator-=(const Point& p);
00117 
00118   // @}
00119 };
00120 
00121 //
00122 // Mathematical Functions.
00123 //
00124 
00125 
00127 
00128 template<typename T>
00129 Plane<T> 
00130 buildSupportingPlane(const Triangle<3,T>& triangle);
00131 
00132 
00133 //
00134 // File I/O operators.
00135 //
00136 
00137 
00139 
00140 template<int N, typename T>
00141 std::istream& 
00142 operator>>(std::istream& in, Triangle<N,T>& t);
00143 
00144 
00146 
00147 template<int N, typename T>
00148 std::ostream& 
00149 operator<<(std::ostream& out, const Triangle<N,T>& t);
00150 
00151 
00152 END_NAMESPACE_GEOM
00153 
00154 #define __geom_Triangle_ipp__
00155 #include "Triangle.ipp"
00156 #undef __geom_Triangle_ipp__
00157 
00158 #endif

Generated on Fri Aug 24 12:55:59 2007 for Computational Geometry Package by  doxygen 1.4.7