Files Classes Functions Hierarchy
00001 #ifndef DELAUNAYSIMPLED2_H 00002 #define DELAUNAYSIMPLED2_H 00003 00004 #include <vector> 00005 using namespace std; 00006 00007 #include <point.h> 00008 #include <simplexD2indexed.h> 00009 #include <triangle.h> 00010 #include <typedefs.h> 00011 00019 template< typename PT, typename PD, typename INDX > 00020 class delaunaysimpleD2 00021 { 00022 void evaluateTriangle 00023 ( 00024 INDX const i, 00025 INDX const j, 00026 INDX const k 00027 ); 00028 public: 00029 00031 delaunaysimpleD2(); 00032 00034 vector< PT > pts; 00036 vector< simplexD2indexed<INDX> > vi; 00037 00039 void get( PT & a, PT & b, PT & c, INDX const i) const; 00040 00042 void eval(); 00043 00044 }; 00045 00046 00047 //--------------------------------------------------------- 00048 // Implementation 00049 00050 template< typename PT, typename PD, typename INDX > 00051 delaunaysimpleD2<PT,PD,INDX>::delaunaysimpleD2() 00052 { 00053 pts.push_back(PT()); 00054 vi.push_back( simplexD2indexed<INDX>() ); 00055 } 00056 00057 template< typename PT, typename PD, typename INDX > 00058 void delaunaysimpleD2<PT,PD,INDX>::evaluateTriangle 00059 ( 00060 INDX const i, 00061 INDX const j, 00062 INDX const k 00063 ) 00064 { 00065 triangle<PT,PD> t; 00066 t.constructUnordered( pts[i],pts[j],pts[k]); 00067 00068 PT p0; 00069 PD radius; 00070 t.outercircle(radius,p0); 00071 00072 //cout << SHOW(i) << " " << SHOW(j) << " " << SHOW(k) << endl; 00073 00074 INDX const n=pts.size(); 00075 for (uint w=1; w<n; ++w) 00076 { 00077 if (w==i) 00078 continue; 00079 if (w==j) 00080 continue; 00081 if (w==k) 00082 continue; 00083 00084 if ((p0-pts[w]).dot() < radius*radius ) 00085 return; 00086 } 00087 00088 vi.push_back( simplexD2indexed<INDX>(i,j,k) ); 00089 } 00090 00091 template< typename PT, typename PD, typename INDX > 00092 void delaunaysimpleD2<PT,PD,INDX>::eval() 00093 { 00094 INDX const n=pts.size(); 00095 INDX i,j,k; 00096 for (i=1; i<n-2; ++i) 00097 { 00098 for (j=i+1; j<n-1; ++j) 00099 { 00100 for (k=j+1; k<n; ++k) 00101 { 00102 //cout << SHOW(i) << " " << SHOW(j) << " " << SHOW(k) << endl; 00103 evaluateTriangle(i,j,k); 00104 } 00105 } 00106 } 00107 00108 //cout << print(vi,"\n") << endl; 00109 } 00110 00111 template< typename PT, typename PD, typename INDX > 00112 void delaunaysimpleD2<PT,PD,INDX>::get 00113 ( 00114 PT & a, 00115 PT & b, 00116 PT & c, 00117 INDX const i 00118 ) const 00119 { 00120 simplexD2indexed<INDX> const & t(vi[i]); 00121 00122 a = pts[t.pi[0]]; 00123 b = pts[t.pi[1]]; 00124 c = pts[t.pi[2]]; 00125 } 00126 00127 00128 00129 #endif 00130 00131
1.5.8