From: fred Date: Sun, 24 Mar 2002 20:00:53 +0000 (+0000) Subject: lilypond-0.1.25 X-Git-Tag: release/1.5.59~3699 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=c0a87021db55bf6a2a19030d393408b2a850b636;p=lilypond.git lilypond-0.1.25 --- diff --git a/lily/beam.cc b/lily/beam.cc index ea102e4457..a7cfd829ca 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -128,33 +128,36 @@ Beam::do_width() const void Beam::set_default_dir() { - int up = 0, down = 0; - int up_count = 0, down_count = 0; - + Drul_array total; + total[UP] = total[DOWN] = 0; + Drul_array count; + count[UP] = count[DOWN] = 0; + Direction d = DOWN; + for (int i=0; i get_center_distance_from_top(); - int cur_up = sl->get_center_distance_from_bottom(); - if (cur_down) - { - down += cur_down; - down_count++; - } - if (cur_up) + do { + Stem *s = stems[i]; + int current = s->dir_ + ? (1 + d * s->dir_)/2 + : s->get_center_distance(Direction(-d)); + + if (current) { - up += cur_up; - up_count++; + total[d] += current; + count[d] ++; } - } - if (!down) - down_count = 1; - if (!up) - up_count = 1; - - // the following relation is equal to - // up / up_count > down / down_count - dir_ = (up * down_count > down * up_count) ? UP : DOWN; + + } while ((d *= -1) != DOWN); + + do { + if (!total[d]) + count[d] = 1; + } while ((d *= -1) != DOWN); + + /* the following relation is equal to + up / up_count > down / down_count + */ + dir_ = (total[UP] * count[DOWN] > total[DOWN] * count[UP]) ? UP : DOWN; for (int i=0; i