Files Classes Functions Hierarchy
00001 #include <cassert> 00002 #include <iostream> 00003 #include <sstream> 00004 using namespace std; 00005 00006 #include <simplexD2linked.h> 00007 00008 //uint * simplexD2linked::niFrompiInverse(uintc gpt) 00009 //{ 00010 // return & ni[ piInverse(gpt) ]; 00011 //} 00012 00013 00014 simplexD2linked::operator string() const 00015 { 00016 string s; 00017 for (uint i=0; i<3; ++i) 00018 { 00019 { stringstream ss; ss << pi[i]; s+=ss.str(); } 00020 s += " "; 00021 } 00022 00023 s += " "; 00024 00025 for (uint i=0; i<3; ++i) 00026 { 00027 { stringstream ss; ss << ni[i]; s+=ss.str(); } 00028 s += " "; 00029 } 00030 00031 return s; 00032 } 00033 00034 simplexD2linked::simplexD2linked() 00035 { 00036 for (uint i=0; i<3; ++i) 00037 { 00038 pi[i] = 0; 00039 ni[i] = 0; 00040 } 00041 } 00042 00043 simplexD2linked::simplexD2linked 00044 ( 00045 uintc a, 00046 uintc b, 00047 uintc c, 00048 uintc na, 00049 uintc nb, 00050 uintc nc 00051 ) 00052 { 00053 construct(a,b,c,na,nb,nc); 00054 } 00055 00056 00057 /* 00058 uintc simplexD2linked::piInverse 00059 ( 00060 bool & res, 00061 uintc gpt 00062 ) const 00063 { 00064 assert(gpt!=0); 00065 00066 res=true; 00067 00068 if (pi[0]==gpt) return 0; 00069 if (pi[1]==gpt) return 1; 00070 if (pi[2]==gpt) return 2; 00071 00072 res=false; 00073 return 3; // Return crap. 00074 } 00075 */ 00076 00077 00078 boolc simplexD2linked::isonboundary() const 00079 { 00080 if (ni[0]==0) return true; 00081 if (ni[1]==0) return true; 00082 if (ni[2]==0) return true; 00083 00084 return false; 00085 } 00086 00087 00088 /* 00089 uintc simplexD2linked::niInverse 00090 ( 00091 bool & res, 00092 uintc neib 00093 ) const 00094 { 00095 res=true; 00096 00097 if (ni[0]==neib) return 0; 00098 if (ni[1]==neib) return 1; 00099 if (ni[2]==neib) return 2; 00100 00101 res=false; 00102 return 3; // Return crap. 00103 } 00104 */ 00105 00106 00107 00108 00109 /* 00110 boolc simplexD2linked::isavertex( uintc gpt ) const 00111 { 00112 if (gpt==pi[0]) return true; 00113 if (gpt==pi[1]) return true; 00114 if (gpt==pi[2]) return true; 00115 00116 return false; 00117 } 00118 */ 00119 00120 void simplexD2linked::serializeInverse(stringc & s) 00121 { 00122 stringstream ss(s); 00123 for (uint i=0; i<3; ++i) 00124 ss >> pi[i]; 00125 00126 for (uint i=0; i<3; ++i) 00127 ss >> ni[i]; 00128 } 00129 00130 istream & simplexD2linked::serializeInverse(istream & is) 00131 { 00132 for (uint i=0; i<3; ++i) 00133 is >> pi[i]; 00134 00135 for (uint i=0; i<3; ++i) 00136 is >> ni[i]; 00137 00138 return is; 00139 } 00140 00141 00142 00143 ostream & simplexD2linked::print(ostream& os) const 00144 { 00145 for (uint i=0; i<3; ++i) 00146 os << pi[i] << " "; 00147 00148 os << " "; 00149 00150 for (uint i=0; i<3; ++i) 00151 os << ni[i] << " "; 00152 00153 return os; 00154 } 00155 00156 00157 void simplexD2linked::construct 00158 ( 00159 uintc a, 00160 uintc b, 00161 uintc c, 00162 uintc na, 00163 uintc nb, 00164 uintc nc 00165 ) 00166 { 00167 pi[0] = a; 00168 pi[1] = b; 00169 pi[2] = c; 00170 ni[0] = na; 00171 ni[1] = nb; 00172 ni[2] = nc; 00173 }; 00174 00175 00176 void simplexD2linked::getanticlockwiseface 00177 ( 00178 uint & a, 00179 uint & b, 00180 uintc face 00181 ) const 00182 { 00183 switch (face) 00184 { 00185 case 0: 00186 a=1; b=2; 00187 break; 00188 00189 case 1: 00190 a=2; b=0; 00191 break; 00192 00193 case 2: 00194 a=0; b=1; 00195 break; 00196 00197 default: 00198 assert(false); 00199 } 00200 } 00201 00202 void simplexD2linked::getclockwiseface 00203 ( 00204 uint & a, 00205 uint & b, 00206 uintc face 00207 ) const 00208 { 00209 switch (face) 00210 { 00211 case 0: 00212 a=2; b=1; 00213 break; 00214 00215 case 1: 00216 a=0; b=2; 00217 break; 00218 00219 case 2: 00220 a=1; b=0; 00221 break; 00222 00223 default: 00224 assert(false); 00225 } 00226 } 00227 00228 boolc simplexD2linked::isnull() const 00229 { 00230 for (uint i=0; i<3; ++i) 00231 { 00232 if (pi[i]!=0) 00233 return false; 00234 00235 if (ni[i]!=0) 00236 return false; 00237 } 00238 00239 return true; 00240 } 00241 00242 void simplexD2linked::setnull() 00243 { 00244 for (uint i=0; i<3; ++i) 00245 { 00246 pi[i]=0; 00247 ni[i]=0; 00248 } 00249 } 00250 00251 boolc simplexD2linked::operator == (simplexD2linked const & w) const 00252 { 00253 if (pi[0]+pi[1]+pi[2] != w.pi[0]+w.pi[1]+w.pi[2]) 00254 return false; 00255 00256 for (uint i=0; i<3; ++i) 00257 { 00258 bool res(false); 00259 for (uint k=0; k<3; ++k) 00260 { 00261 if (w.pi[k]==pi[i]) 00262 { 00263 res=true; 00264 k=3; 00265 } 00266 } 00267 if (res==false) 00268 return false; 00269 } 00270 00271 return true; 00272 } 00273 00274 00275 00276 00277 ostream & operator << (ostream& os, simplexD2linked const & x) 00278 { 00279 return x.print(os); 00280 } 00281 00282 istream & operator >> (istream & is, simplexD2linked & x) 00283 { 00284 return x.serializeInverse(is); 00285 } 00286 00287 00288
1.5.8