diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2005-11-07 22:57:12 +0100 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2005-11-07 22:57:12 +0100 |
commit | e29ef252eb5f119a0b7318f909a7c5fcadbff727 (patch) | |
tree | 8ea03f7b231bdf2f203388fd513a72cd1463528f | |
parent | c580cd9f2890979b7af611079720c3bbb101c41c (diff) |
initial version of hidden hill detection
-rw-r--r-- | src/GipfelWidget.cxx | 2 | ||||
-rw-r--r-- | src/Hill.H | 3 | ||||
-rw-r--r-- | src/Panorama.H | 2 | ||||
-rw-r--r-- | src/Panorama.cxx | 40 |
4 files changed, 46 insertions, 1 deletions
diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index 32ffbe2..a22c7a9 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -318,6 +318,8 @@ GipfelWidget::draw() { } else if (m == m2) { fl_color(FL_RED); draw_flag(center_x + m->x + x(), center_y + m->y + y(), "2"); + } else if (m->flags & Hill::HIDDEN) { + fl_color(FL_BLUE); } else { fl_color(FL_BLACK); } @@ -32,7 +32,8 @@ class Hill { typedef enum { DUPLICATE = 0x01, TRACK_POINT = 0x02, - VISIBLE = 0x04 + VISIBLE = 0x04, + HIDDEN = 0x08 } flags_t; double phi, lam; diff --git a/src/Panorama.H b/src/Panorama.H index 0333338..62b2b88 100644 --- a/src/Panorama.H +++ b/src/Panorama.H @@ -50,6 +50,8 @@ class Panorama { void update_close_mountains(); void update_visible_mountains(); + + void mark_hidden(); double distance(double phi, double lam); diff --git a/src/Panorama.cxx b/src/Panorama.cxx index 8a296aa..22539cb 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -398,11 +398,50 @@ Panorama::update_angles() { } } + mountains->sort(); update_close_mountains(); } + +void +Panorama::mark_hidden() { + int i, j; + Hill *m, *n; + double hide_val; + + + for (i=0; i<visible_mountains->get_num(); i++) { + m = visible_mountains->get(i); + if (m->flags & Hill::DUPLICATE) { + continue; + } + for (j=0; j<visible_mountains->get_num(); j++) { + n = visible_mountains->get(j); + + if (n->flags & Hill::DUPLICATE) { + continue; + } + if (m == n || fabs(m->a_view - n->a_view > pi_d / 2.0)) { + continue; + } + if (m->dist < n->dist || m->a_nick > n->a_nick) { + continue; + } + + hide_val = (n->a_nick - m->a_nick) / fabs(m->a_view - n->a_view); + if (hide_val > 5.0) { + m->flags |= Hill::HIDDEN; + +fprintf(stderr, "%s %f %f %s %f %f => %f\n", m->name, m->dist, m->a_nick, n->name, n->dist, n->a_nick, hide_val); + } + } + + } + +} + void Panorama::update_close_mountains() { int i; @@ -451,6 +490,7 @@ Panorama::update_visible_mountains() { } } + mark_hidden(); update_coordinates(); } |