Commit 5a9a7e74 authored by Federico Ciuffardi's avatar Federico Ciuffardi
Browse files

some fixes, still broken

parent c1a1967c
......@@ -178,14 +178,14 @@ struct collapsedGraph : genericGraph<graph> {
pos_set full_neighbors(pos p){
pos_set adj_p = all_adj(p);
pos_set neighbors;
for(auto it = adj_p; it != adj_p.end(); it++){
pos_set f_neighbors;
for(auto it = adj_p.begin(); it != adj_p.end(); it++){
pos n = *it;
if(is_elem(full_graph, n)){
neighbor.insert(n);
f_neighbors.insert(n);
}
}
return neighbors;
return f_neighbors;
}
// vertex is uncollapsed
......@@ -200,11 +200,13 @@ struct collapsedGraph : genericGraph<graph> {
return false;
}
auto it_n = full_neighbors(p).begin();
pos dir1 = (*it_n) - p;
pos_set f_neighbors = full_neighbors(p);
auto it_n = f_neighbors.begin();
pos n1 = (*it_n);
pos dir1 = n1 - p;
it_n++;
pos dir2 = (*it_n) - p;
pos n2 = (*it_n);
pos dir2 = n2 - p;
return same_direction(dir1,dir2);
}
......@@ -216,7 +218,7 @@ struct collapsedGraph : genericGraph<graph> {
cout<<p<<endl;
if(!is_elem(full_graph, p)){
cout<<"warning: "<<p<<endl;
return p - dir;
exit(1);
}
}
return p;
......@@ -254,6 +256,7 @@ struct collapsedGraph : genericGraph<graph> {
// TODO
void collapse(pos p) {
cout<<"collapsing p "<<p<<endl;
AdjacencyIterator it, it_end;
boost::tie(it, it_end) = super::neighbors(p);
......@@ -302,11 +305,11 @@ struct collapsedGraph : genericGraph<graph> {
if (is_uncollapsed(p)) {
super::erase_v(p);
// 1.1. collapse neighbors of p if possible
collapse_neighbors(p);
}
// 2. collapse neighbors of p if possible
collapse_neighbors(p);
// 2. uncolloapse collapsed neighbors of p
// 3. uncolloapse collapsed neighbors of p
uncollapse_neighbors(p);
}
......
......@@ -65,7 +65,16 @@ pos normalized(pos p) {
}
bool same_direction(pos p1, pos p2) {
return normalized(p1) == -normalized(p2);
float normalized_p1_x = p1.first / lenght(p1);
float normalized_p1_y = p1.second / lenght(p1);
float normalized_p2_x = p2.first / lenght(p2);
float normalized_p2_y = p2.second / lenght(p2);
bool same_x = normalized_p1_x == -normalized_p2_x;
bool same_y = normalized_p1_y == -normalized_p2_y;
return same_x && same_y;
}
float angle(pos p) {
......
No preview for this file type
......@@ -351,7 +351,7 @@ string colorize(string s, string color) {
}
int main(int argc, char** argv) {
vector<grid_type> test = test_2;
vector<grid_type> test = test_5;
if (argc == 2) {
char* a = argv[1];
int num = atoi(a);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment