Files Classes Functions Hierarchy
00001 #ifndef SIMPLEXD1LINKED_H 00002 #define SIMPLEXD1LINKED_H 00003 00004 00005 #include <cassert> 00006 #include <sstream> 00007 using namespace std; 00008 00009 #include <typedefs.h> 00010 00022 template< typename INDX=uint> 00023 class simplexD1linked 00024 { 00025 public: 00026 00028 INDX pi[2]; 00031 INDX ni[2]; 00032 00034 simplexD1linked() {}; 00036 simplexD1linked 00037 ( 00038 INDX const a, INDX const b, INDX const na=0, INDX const nb=0 00039 ); 00040 00042 void construct 00043 ( 00044 INDX const a, INDX const b, INDX const na=0, INDX const nb=0 00045 ); 00046 00048 void togglelinedirection() 00049 { 00050 INDX p0 = pi[0]; 00051 INDX n0 = ni[0]; 00052 pi[0] = pi[1]; 00053 ni[0] = ni[1]; 00054 pi[1] = p0; 00055 ni[1] = n0; 00056 } 00057 00058 // Query Functions 00059 00061 INDX const piInverse( INDX const gpt ) const 00062 { 00063 assert(gpt!=0); 00064 00065 if (pi[0]==gpt) return 0; 00066 if (pi[1]==gpt) return 1; 00067 00068 assert(false); 00069 return 3; // Return crap. 00070 } 00071 00073 boolc isonboundary() const 00074 { 00075 if (ni[0]==0) return true; 00076 if (ni[1]==0) return true; 00077 return false; 00078 } 00079 00081 void setnull() 00082 { pi[0] = pi[1] = ni[0] = ni[1] = 0; } 00083 00085 boolc isnull() const 00086 { 00087 if (pi[0]!=0) return false; 00088 if (pi[1]!=0) return false; 00089 if (ni[0]!=0) return false; 00090 if (ni[1]!=0) return false; 00091 return true; 00092 } 00093 00095 operator stringc () const; 00096 00098 void serializeInverse(stringc & s) 00099 { 00100 stringstream w(s); 00101 w >> pi[0]; 00102 w >> pi[1]; 00103 w >> ni[0]; 00104 w >> ni[1]; 00105 } 00106 }; 00107 00108 00109 //--------------------------------------------------------- 00110 // Implementation 00111 00112 template< typename INDX > 00113 simplexD1linked<INDX>::operator stringc () const 00114 { 00115 stringstream ss; 00116 ss << pi[0] << " " << pi[1] << " " << ni[0] << " " << ni[1]; 00117 return ss.str(); 00118 } 00119 00120 template< typename INDX > 00121 simplexD1linked<INDX>::simplexD1linked 00122 ( 00123 INDX const a, INDX const b, INDX const na, INDX const nb 00124 ) 00125 { 00126 pi[0] = a; 00127 pi[1] = b; 00128 ni[0] = na; 00129 ni[1] = nb; 00130 } 00131 00132 template< typename INDX > 00133 void simplexD1linked<INDX>::construct 00134 ( 00135 INDX const a, INDX const b, INDX const na, INDX const nb 00136 ) 00137 { 00138 pi[0] = a; 00139 pi[1] = b; 00140 ni[0] = na; 00141 ni[1] = nb; 00142 } 00143 00144 00145 00146 00147 #endif 00148
1.5.8