//---------------------------------------------------------------------------// void FindTriangleNeighbors ( LTNeighbor tn[], //neighbors const LTTriangle t[], //triangles const uint16 tc, //triangle count const LTVector3f V[] //vertices ) { uint16* p = (uint16*)tn; //initialize all tn's to 0xFFFF, //denoting an unshared edge for( int32 i=0 ; i<(3*tc) ; i++ ) { p[i] = 0xFFFF; } //for each triangle (except for the last one), //check to see if any subsequent triangles //share an edge with it for( uint16 i=0 ; i<tc-1 ; i++ ) { for( uint16 k=i+1 ; k<tc ; k++ ) { edge_check( tn, i, k, t, V ); } } }
void PopulateGraph(std::vector< std::set<ulong> > &Graph, std::vector< std::set<ulong> > &vertex_tri_hash) { std::set<ulong> myneighbors; // Populate the hash table which tells us which triangles are sharing a specific node. for (ulong i=0; i<nele; ++i) { for (int j=0; j<3; ++j) vertex_tri_hash[(ulong) (ele(i,j)-1)].insert(i+1); } std::set<ulong> tmpSet; std::queue<ulong> q; std::vector<long> edge_check (nele, White); bool endflag=false; ulong starte=1; while (!endflag) { q.push(starte); ulong dummyc=0; while (!q.empty()) { ulong u = q.front(); myneighbors = FindNeighboringTriangles(u, vertex_tri_hash); for (std::set<ulong>::iterator it=myneighbors.begin(); it!=myneighbors.end(); ++it) { if (edge_check[(*it)-1]==Black) continue; if (u != *it) { ulong tempak = *it; tmpSet.clear(); tmpSet = Graph[u-1]; tmpSet.insert(*it); Graph[u-1] = tmpSet; tmpSet.clear(); tmpSet = Graph[(*it)-1]; tmpSet.insert(u); Graph[(*it)-1] = tmpSet; if (edge_check[(*it)-1] == White) q.push(*it); edge_check[(*it)-1] = edge_check[(*it)-1] + 1; // if (edge_check[(*it)-1]>=3) // edge_check[(*it)-1] = Black; } } edge_check[u-1] = Black; q.pop(); dummyc++; } endflag=true; for (ulong i=0; i<nele; ++i) { if (edge_check[i]!=Black) { starte = i+1; endflag=false; break; } } } }