/*
This file is part of LilyPond, the GNU music typesetter.
- Copyright (C) 2004--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ Copyright (C) 2004--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
LilyPond is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
}
Real
-fit_factor (Offset dz_unit, Offset dz_perp,
+fit_factor (Offset dz_unit, Offset dz_perp, Real close_to_edge_length,
Bezier curve, Direction d, vector<Offset> const &avoid)
{
Real fit_factor = 0.0;
Offset p (dot_product (z, dz_unit),
d * dot_product (z, dz_perp));
+ bool close_to_edge = false;
+ Direction d = LEFT;
+ do
+ close_to_edge = close_to_edge || -d * (p[X_AXIS] - curve_xext[d]) < close_to_edge_length;
+ while (flip (&d) != LEFT);
+
+ if (close_to_edge)
+ continue;
+
Real eps = 0.01;
Interval pext = eps * Interval (-1, 1) + p[X_AXIS];
pext.intersect (curve_xext);
+
if (pext.is_empty () || pext.length () <= 1.999 * eps)
continue;
+ dz_unit * x2;
curve.control_[3] = attachment_[RIGHT];
- Real ff = fit_factor (dz_unit, dz_perp, curve, state.dir_, avoid);
+ Real ff = fit_factor (dz_unit, dz_perp, state.parameters_.close_to_edge_length_,
+ curve, state.dir_, avoid);
height = max (height, min (height * ff, max_h));
demerit += stem_dem;
}
- else if (!edge)
- {
- Interval ext;
- ext.add_point (state.encompass_infos_[j].stem_);
- ext.add_point (state.encompass_infos_[j].head_);
-
- // ?
- demerit += -state.parameters_.closeness_factor_
- * min (state.dir_
- * (y - (ext[state.dir_] + state.dir_ * state.parameters_.free_head_distance_)), 0.0)
- / state.encompass_infos_.size ();
- }
}
add_score (demerit, "encompass");