Files Classes Functions Hierarchy
00001 #ifndef POLYTOPED2TESS_H 00002 #define POLYTOPED2TESS_H 00003 00004 #include <typedefs.h> 00005 00006 template< typename VPOLY, typename VPTS > 00007 class polytopeD2tess 00008 { 00009 public: 00010 00012 VPOLY & vi; 00014 VPTS & pts; 00015 00017 polytopeD2tess 00018 ( 00019 VPOLY & vi_, 00020 VPTS & pts_ 00021 ) 00022 : vi(vi_), pts(pts_) {} 00023 00025 boolc verify(uintc k) const; 00026 00028 boolc verify() const; 00029 00032 void addpoint( uintc k, uintc ptindex, uintc ptglobal ); 00033 00035 void printvi() const; 00036 }; 00037 00038 //--------------------------------------------------------- 00039 // Implementation 00040 00041 template< typename VPOLY, typename VPTS > 00042 void polytopeD2tess<VPOLY,VPTS>::printvi() const 00043 { 00044 for (uint i=1; i<vi.size(); ++i) 00045 cout << (string)vi[i] << endl; 00046 } 00047 00048 template< typename VPOLY, typename VPTS > 00049 boolc polytopeD2tess<VPOLY,VPTS>::verify() const 00050 { 00051 uintc imax = vi.size(); 00052 for (uint i=0; i<imax; ++i) 00053 { 00054 if (verify(i)==false) 00055 return false; 00056 } 00057 00058 return true; 00059 } 00060 00061 template< typename VPOLY, typename VPTS > 00062 boolc polytopeD2tess<VPOLY,VPTS>::verify(uintc k) const 00063 { 00064 polytopeD2linked const & x(vi[k]); 00065 if (x.isnull()) 00066 return true; 00067 00068 uintc sz = x.ni.size(); 00069 assert(x.pi.size()==sz); 00070 if (x.pi.size()!=sz) 00071 return false; 00072 00073 uint nicurrent; 00074 for (uint i=0; i<sz; ++i) 00075 { 00076 nicurrent=x.ni[i]; 00077 if (nicurrent==0) 00078 continue; 00079 00080 assert(nicurrent<vi.size()); 00081 if ((nicurrent<vi.size())==false) 00082 return false; 00083 00084 assert(vi[nicurrent].niInverseHas(k)==true); 00085 if (vi[nicurrent].niInverseHas(k)==false) 00086 return false; 00087 } 00088 00089 return true; 00090 } 00091 00092 00093 template< typename VPOLY, typename VPTS > 00094 void polytopeD2tess<VPOLY,VPTS>::addpoint 00095 ( 00096 uintc k, 00097 uintc ptindex, 00098 uintc ptglobal 00099 ) 00100 { 00101 assert(k<vi.size()); 00102 assert(ptindex<pts.size()); 00103 assert(ptglobal<pts.size()); 00104 00105 polytopeD2linked & A(vi[k]); 00106 00107 //cout << SHOW(k) << endl; 00108 //cout << SHOW(ptindex) << endl; 00109 uintc j = A.piInverse(ptindex); 00110 uintc neib = A.ni[j]; 00111 uint i = (j+1) % A.pi.size(); 00112 //cout << SHOW(i) << endl; 00113 //cout << SHOW(neib) << endl; 00114 // Has the polygon got a neighbor? 00115 if (neib!=0) 00116 { 00117 uintc ptindex2 = A.pi[i]; 00118 //cout << SHOW(ptindex2) << endl; 00119 polytopeD2linked & B(vi[neib]); 00120 B.addpoint(ptindex2,ptglobal); 00121 } 00122 00123 A.addpoint(ptindex,ptglobal); 00124 } 00125 00126 00127 #endif 00128
1.5.8