Jan Nieuwenhuizen <janneke@gnu.org>
*/
+#include "beam.hh"
+
+#include <algorithm>
#include <math.h>
#include "warn.hh"
#include "staff-symbol-referencer.hh"
-#include "beam.hh"
#include "stem.hh"
#include "output-def.hh"
#include "group-interface.hh"
}
}
- if (best_idx < 0)
- {
- programming_error ("Huh? No best beam quant score?");
- best_idx = 0;
- }
-
return best_idx;
}
}
int best_idx = best_quant_score_idx (qscores);
-
+
#if DEBUG_QUANTING
SCM inspect_quants = me->get_property ("inspect-quants");
- if (to_boolean (me->get_layout ()->lookup_variable (ly_symbol2scm ("debug-beam-quanting")))
+ if ( to_boolean (me->get_layout ()->lookup_variable (ly_symbol2scm ("debug-beam-quanting")))
&& scm_is_pair (inspect_quants))
{
Drul_array<Real> ins = ly_scm2interval (inspect_quants);
}
}
if (mindist > 1e5)
- programming_error ("Could not find quant.");
+ programming_error ("can't find quant");
}
#endif
-
- me->set_property ("positions",
- ly_interval2scm (Drul_array<Real> (qscores[best_idx].yl,
- qscores[best_idx].yr)));
+ if (best_idx < 0)
+ {
+ warning (_ ("no feasible beam position"));
+ me->set_property ("positions", ly_interval2scm (Interval (0,0)));
+ }
+ else
+ me->set_property ("positions",
+ ly_interval2scm (Drul_array<Real> (qscores[best_idx].yl,
+ qscores[best_idx].yr)));
#if DEBUG_QUANTING
- if (to_boolean (me->get_layout ()->lookup_variable (ly_symbol2scm ("debug-beam-quanting"))))
+ if (best_idx >= 0
+ && to_boolean (me->get_layout ()->lookup_variable (ly_symbol2scm ("debug-beam-quanting"))))
{
qscores[best_idx].score_card_ += to_string ("i%d", best_idx);
Stem_info info = stem_infos[i];
Direction d = info.dir_;
- score[d] += limit_penalty * (0 >? (d * (info.shortest_y_ - current_y)));
+ score[d] += limit_penalty * max (0.0, (d * (info.shortest_y_ - current_y)));
Real ideal_diff = d * (current_y - info.ideal_y_);
Real ideal_score = shrink_extra_weight (ideal_diff, 1.5);
Direction d = DOWN;
do
{
- score[d] /= (count[d] >? 1);
+ score[d] /= max (count[d], 1);
}
while (flip (&d) != DOWN);
dem += DAMPING_DIRECTION_PENALTY;
}
- dem += MUSICAL_DIRECTION_FACTOR *(0 >? (fabs (dy) - fabs (dy_mus)));
+ dem += MUSICAL_DIRECTION_FACTOR * max (0.0, (fabs (dy) - fabs (dy_mus)));
Real slope_penalty = IDEAL_SLOPE_FACTOR;
Drul_array<Real> y (yl, yr);
Drul_array<Direction> dirs (ldir, rdir);
- Real extra_demerit = SECONDARY_BEAM_DEMERIT / (beam_counts[LEFT] >? beam_counts[RIGHT]);
+ Real extra_demerit = SECONDARY_BEAM_DEMERIT / (max (beam_counts[LEFT], beam_counts[RIGHT]));
Direction d = LEFT;
Real dem = 0.0;
k <= radius + BEAM_EPS; k += 1.0)
if (gap.contains (k))
{
- Real dist = fabs (gap[UP] - k) <? fabs (gap[DOWN] - k);
+ Real dist = min (fabs (gap[UP] - k), fabs (gap[DOWN] - k));
/*
this parameter is tuned to grace-stem-length.ly
}
while ((flip (&d)) != LEFT);
- if ((beam_counts[LEFT] >? beam_counts[RIGHT]) >= 2)
+ if (max (beam_counts[LEFT], beam_counts[RIGHT]) >= 2)
{
Real straddle = 0.0;
Real sit = (thickness - slt) / 2;