int find_connected_components(int a[], int rs[], int cs[], int ss[], int n) { int i, ncc, cc; // if(!n) return 0; // for(i=0; i<n; ++i) a[i] = 0; // ncc = 0; cc = 1; for(i=0; i<n; ++i) if(a[i] == 0) { // a[i] = cc; // ccdfs(a, i, rs, cs, ss, n); // ++ncc; ++cc; } // return ncc; }
int findConnectedComponents(vector<int> &a, vector<Vec4f> &obj) { int cc = 1; for (size_t i=0; i<obj.size(); ++i) { if (a[i] == 0) { a[i] = cc++; ccdfs(a, i, obj); } } return cc-1; }
void ccdfs(vector<int> &a, int i, vector<Vec4f> &obj) { for (size_t j=0; j<obj.size(); ++j) { if (a[j]!=0) continue; if (getOverlap(obj[i][1],obj[i][2],obj[i][3], obj[j][1],obj[j][2],obj[j][3])<=0.3f) continue; a[j] = a[i]; ccdfs(a, j, obj); } }
void ccdfs(int a[], int i, int rs[], int cs[], int ss[], int n) { int j; // for(j=0; j<n; ++j) if(a[j]==0 && get_overlap(rs[i], cs[i], ss[i], rs[j], cs[j], ss[j])>0.75f) { // a[j] = a[i]; // ccdfs(a, j, rs, cs, ss, n); } }