From 600ba0ef2437faceae97003bd6147acc238bc5a1 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 20 Jul 2004 18:46:17 +0000 Subject: [PATCH] (score_extra_encompass): add break ; (score_extra_encompass): process scripts at edges too, by checking control points directly. --- ChangeLog | 6 +++++ lily/slur-quanting.cc | 51 +++++++++++++++++++++++++++++++++---------- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2c113f086f..2d74b469b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-07-20 Han-Wen Nienhuys + + * lily/slur-quanting.cc (score_extra_encompass): add break ; + (score_extra_encompass): process scripts at edges too, by checking + control points directly. + 2004-07-20 Jan Nieuwenhuizen * po/nl.po: Update. diff --git a/lily/slur-quanting.cc b/lily/slur-quanting.cc index bb77307284..970a5a873d 100644 --- a/lily/slur-quanting.cc +++ b/lily/slur-quanting.cc @@ -830,8 +830,9 @@ score_extra_encompass (Grob *me, Grob *common[], Real lt = me->get_paper ()->get_dimension (ly_symbol2scm ("linethickness")); Real thick = robust_scm2double (me->get_property ("thickness"), 1.0) * lt; - Array xs; + Array xidxs; Array yexts; + Array xexts; for (int i = 0; i < encompasses.size (); i++) { Grob *g = encompasses [i]; @@ -873,29 +874,55 @@ score_extra_encompass (Grob *me, Grob *common[], } } - xs.push (xe.linear_combination (xp)); + xidxs.push (xp); ye.widen (thick * 0.5); yexts.push (ye); + xexts.push (xe); } for (int i = 0; i < scores->size (); i++) { Bezier const &bez (scores->elem (i).curve_); Real demerit = 0.0; - for (int j = 0; j < xs.size(); j++) + for (int j = 0; j < xidxs.size(); j++) { - Real x = xs[j]; - if ((x < scores->elem (i).attachment_[RIGHT][X_AXIS] - && x > scores->elem (i).attachment_[LEFT][X_AXIS])) + Drul_array at = scores->elem (i).attachment_; + Interval slur_wid (at[LEFT][X_AXIS], at[RIGHT][X_AXIS]); + + /* + to prevent numerical inaccuracies in + Bezier::get_other_coordinate(). + */ + slur_wid.widen (- 0.5 * thick); + Real x = xexts[j].linear_combination (xidxs[j]); + Real y = 0.0; + if (!slur_wid.contains (x)) { - Real y = bez.get_other_coordinate (X_AXIS, x); - if (yexts[j].contains (y)) + Direction contains_dir = CENTER; + Direction d = LEFT; + do { - if (Accidental_interface::has_interface (encompasses[j])) - demerit += score_param->ACCIDENTAL_COLLISION; - else - demerit += score_param->EXTRA_OBJECT_COLLISION; + if (xexts[j].contains (at[d][X_AXIS])) + contains_dir = d; } + while (flip (&d) != LEFT); + + if (!contains_dir) + continue; + else + y = at[contains_dir][Y_AXIS]; + } + else + { + y = scores->elem (i).curve_.get_other_coordinate (X_AXIS, x); + } + + if (yexts[j].contains (y)) + { + if (Accidental_interface::has_interface (encompasses[j])) + demerit += score_param->ACCIDENTAL_COLLISION; + else + demerit += score_param->EXTRA_OBJECT_COLLISION; } } #if DEBUG_SLUR_QUANTING -- 2.39.5