Files Classes Functions Hierarchy
00001 #ifndef D3MESHITERRECURSIVE_H 00002 #define D3MESHITERRECURSIVE_H 00003 00004 #include <cassert> 00005 #include <vector> 00006 using namespace std; 00007 00008 #include <simplexD2linked.h> 00009 #include <typedefs.h> 00010 00011 00012 /* 00013 Recursivly process the simplex by applying the binary operator 00014 it with its neighbors. If it or any neighbors 00015 change they are processed too. 00016 00017 B - binary operator returns true if the mesh was changed. 00018 00019 The mesh is represented as a vector of simplexes and references are integers 00020 into this stack. 00021 */ 00022 template < typename B > 00023 class d3meshiterrecursive 00024 { 00025 vector<uint> process; 00026 public: 00027 00028 vector<simplexD2linked> & vi; 00029 B & op; 00030 00032 d3meshiterrecursive( vector<simplexD2linked> & _vi, B & _op ) 00033 : vi(_vi), op(_op) {} 00034 00036 void eval(uintc s0); 00037 00039 void evallinear(); 00040 }; 00041 00042 template < typename B > 00043 void d3meshiterrecursive<B>::eval(uintc s0) 00044 { 00045 assert(s0>0); 00046 assert( s0<vi.size() ); 00047 00048 if (vi[s0].isnull()==true) 00049 return; 00050 00051 process.clear(); 00052 process.push_back(s0); 00053 00054 uint k; 00055 simplexD2linked * x; 00056 uint psz; 00057 uint nb; 00058 uint visz; 00059 for (; process.empty()==false; ) 00060 { 00061 psz = process.size(); 00062 k = process[psz-1]; 00063 process.pop_back(); 00064 x = & vi[k]; 00065 assert(x->isnull()==false); 00066 for (uint i=0; i<3; ++i) 00067 { 00068 nb = x->ni[i]; 00069 visz = vi.size(); 00070 if (op.eval(k,i)) 00071 { 00072 if (nb!=0) 00073 process.push_back(nb); 00074 process.push_back(k); 00075 00076 for (uint j=visz; j<vi.size(); ++j) 00077 process.push_back(j); 00078 i=10; // kill loop 00079 } 00080 } 00081 } 00082 00083 } 00084 00085 template < typename B > 00086 void d3meshiterrecursive<B>::evallinear() 00087 { 00088 for ( uint i=1; i<vi.size(); ++i) 00089 eval(i); 00090 } 00091 00092 00093 #endif 00094 00095
1.5.8