Files Classes Functions Hierarchy
00001 #ifndef CELLD3_H 00002 #define CELLD3_H 00003 00004 #include <iostream> 00005 #include <sstream> 00006 using namespace std; 00007 00008 #include <typedefs.h> 00009 00018 template< typename T > 00019 class cellD3 00020 { 00021 public: 00022 00024 T ni[6]; 00025 00027 T id; 00028 00030 cellD3(); 00031 00033 uintc degree() const; 00034 00036 uintc niInv(T x) const; 00037 00039 boolc unvisited() const 00040 { return degree()==0; } 00041 00043 operator stringc () const; 00044 00045 }; 00046 00047 00048 //---------------------------------------------------------- 00049 // Implementation 00050 00051 template< typename T > 00052 cellD3<T>::cellD3() 00053 { 00054 id=0; 00055 ni[0]=0; 00056 ni[1]=0; 00057 ni[2]=0; 00058 ni[3]=0; 00059 ni[4]=0; 00060 ni[5]=0; 00061 } 00062 00063 template< typename T > 00064 uintc cellD3<T>::niInv(T x) const 00065 { 00066 if (ni[0]==x) 00067 return 0; 00068 if (ni[1]==x) 00069 return 1; 00070 if (ni[2]==x) 00071 return 2; 00072 if (ni[3]==x) 00073 return 3; 00074 if (ni[4]==x) 00075 return 4; 00076 if (ni[5]==x) 00077 return 5; 00078 00079 return 6; 00080 } 00081 00082 template< typename T > 00083 uintc cellD3<T>::degree() const 00084 { 00085 uint count=0; 00086 if (ni[0]) 00087 ++count; 00088 if (ni[1]) 00089 ++count; 00090 if (ni[2]) 00091 ++count; 00092 if (ni[3]) 00093 ++count; 00094 if (ni[4]) 00095 ++count; 00096 if (ni[5]) 00097 ++count; 00098 00099 return count; 00100 } 00101 00102 00103 template< typename T > 00104 cellD3<T>::operator stringc () const 00105 { 00106 string s; 00107 stringstream ss; 00108 ss << id; 00109 ss << " "; 00110 ss << ni[0]; 00111 ss << " "; 00112 ss << ni[1]; 00113 ss << " "; 00114 ss << ni[2]; 00115 ss << " "; 00116 ss << ni[3]; 00117 ss << " "; 00118 ss << ni[4]; 00119 ss << " "; 00120 ss << ni[5]; 00121 00122 return ss.str(); 00123 } 00124 00125 00126 00127 00128 00129 #endif 00130
1.5.8