Files Classes Functions Hierarchy
00001 #include <d4minoperator.h> 00002 00003 #include <d4tri.h> 00004 00005 #include <tetrahedron.h> 00006 00007 #include <d4tess.h> 00008 00009 double d4minoperator::delta = 0.1; 00010 00011 d4minoperator::d4minoperator(d4tess & _tess) 00012 : tess(_tess) 00013 { 00014 00015 } 00016 00017 bool const d4minoperator::evalInvert(uint a, uintc index) 00018 { 00019 assert(index<4); 00020 00021 d4tri A(tess.vi[a]); 00022 uint n; 00023 00024 for (uint i=0; i<4; ++i) 00025 { 00026 if (i==index) 00027 continue; 00028 00029 n = A.ni[i]; 00030 if (n==0) 00031 continue; 00032 00033 if( this->eval(a,n) ) 00034 return true; 00035 } 00036 00037 return false; 00038 } 00039 00040 bool const d4minoperator::twotetrahedronMInvert 00041 ( 00042 uintc a, 00043 uintc ai, 00044 uintc b, 00045 uintc bi 00046 ) 00047 { 00048 bool res(false); 00049 if ( evalInvert(a,ai) ) 00050 res=true; 00051 if ( evalInvert(b,bi) ) 00052 res=true; 00053 00054 return res; 00055 } 00056 00057 00058 00059 bool const d4minoperator::approximatelyequal 00060 ( 00061 double const a, 00062 double const b 00063 ) 00064 { 00065 double a2(a); 00066 if (a2<0.0) 00067 a2*=-1.0; 00068 double b2(b); 00069 if (b2<0.0) 00070 b2*=-1.0; 00071 00072 double m(a); 00073 if (a<b) 00074 m=b; 00075 00076 // res will look at the relative magnitude of the numbers. 00077 // If a == b in approximate sense res will be small. 00078 double res = (a-b); 00079 if (res<0.0) 00080 res *= -1.0; 00081 00082 res /= m; 00083 00084 return res<delta; 00085 } 00086 00087 00088 /* 00089 00090 00091 00092 00093 bool const d4minoperator::isconnected 00094 ( 00095 uint & ai, 00096 uint & bi, 00097 uintc a, 00098 uintc b 00099 ) const 00100 { 00101 uintc sz(tess->vi.size()); 00102 assert(a<sz); 00103 assert(b<sz); 00104 00105 if ((a==0)||(b==0)) 00106 return false; 00107 00108 d4tri const & A(tess->vi[a]); 00109 d4tri const & B(tess->vi[b]); 00110 00111 bool res; 00112 00113 ai = A.niInverse(res,b); 00114 if (res==false) 00115 return false; 00116 00117 bi = B.niInverse(res,a); 00118 if (res==false) 00119 return false; 00120 00121 return true; 00122 } 00123 00124 00125 bool const d4minoperator::isconvex( uintc a, uintc b ) const 00126 { 00127 assert(a<tess->vi.size()); 00128 assert(b<tess->vi.size()); 00129 00130 if ((a==0)||(b==0)) 00131 return false; 00132 00133 d4tri const & A(tess->vi[a]); 00134 d4tri const & B(tess->vi[b]); 00135 00136 uint ai, bi; 00137 if (isconnected(ai,bi,a,b)==false) 00138 return false; 00139 00140 tetrahedron<double> t 00141 ( 00142 tess->pt[A.pi[0] ], 00143 tess->pt[A.pi[1] ], 00144 tess->pt[A.pi[2] ], 00145 tess->pt[A.pi[3] ] 00146 ); 00147 00148 pt4 p(tess->pt[B.pi[ai]]); 00149 00150 for (uint i=0; i<4; ++i) 00151 { 00152 if (i==ai) 00153 continue; 00154 00155 if ( t.hi[i].eval(p)==true ) 00156 return false; 00157 } 00158 00159 return true; 00160 } 00161 00162 00163 */ 00164 00165 00166 00167 00168 00169 00170
1.5.8