/*
- slur-configuration.cc -- implement Slur_configuration
+ slur-configuration.cc -- implement Slur_configuration
source file of the GNU LilyPond music typesetter
- (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
+#include "slur-configuration.hh"
+
#include <math.h>
#include "stem.hh"
#include "group-interface.hh"
#include "slur.hh"
#include "slur-scoring.hh"
-#include "slur-configuration.hh"
#include "spanner.hh"
#include "staff-symbol-referencer.hh"
#include "libc-extension.hh"
avoid_staff_line (Slur_score_state const &state,
Bezier bez)
{
- Offset horiz (1,0);
+ Offset horiz (1, 0);
Array<Real> ts = bez.solve_derivative (horiz);
/* TODO: handle case of broken slur. */
return fit_factor;
}
-
-Bezier
-get_bezier (Slur_score_state const &state,
- Drul_array<Offset> attachments,
- Real r_0, Real h_inf)
+void
+Slur_configuration::generate_curve (Slur_score_state const &state,
+ Real r_0, Real h_inf )
{
Link_array<Grob> encompasses = state.columns_;
}
Link_array<Grob> extra_encompasses
- = Pointer_group_interface__extract_grobs (state.slur_, (Grob *)0, "encompass-objects");
+ = extract_grob_array (state.slur_, ly_symbol2scm ("encompass-objects"));
for (int i = 0; i < extra_encompasses.size (); i++)
if (Slur::has_interface (extra_encompasses[i]))
{
avoid.push (z);
}
- Offset dz = attachments[RIGHT]- attachments[LEFT];;
+ Offset dz = attachment_[RIGHT]- attachment_[LEFT];;
Offset dz_unit = dz;
dz_unit *= 1 / dz.length ();
Offset dz_perp = dz_unit * Offset (0, 1);
Real x2 = (excentricity - indent);
Bezier curve;
- curve.control_[0] = attachments[LEFT];
- curve.control_[1] = attachments[LEFT] + dz_perp * height * state.dir_
+ curve.control_[0] = attachment_[LEFT];
+ curve.control_[1] = attachment_[LEFT] + dz_perp * height * state.dir_
+ dz_unit * x1;
- curve.control_[2] = attachments[RIGHT] + dz_perp * height * state.dir_
+ curve.control_[2] = attachment_[RIGHT] + dz_perp * height * state.dir_
+ dz_unit * x2;
- curve.control_[3] = attachments[RIGHT];
+ curve.control_[3] = attachment_[RIGHT];
Real ff = fit_factor (dz_unit, dz_perp, curve, state.dir_, avoid);
height = height >? ((height * ff) <? max_h);
- curve.control_[0] = attachments[LEFT];
- curve.control_[1] = attachments[LEFT] + dz_perp * height * state.dir_
+ curve.control_[0] = attachment_[LEFT];
+ curve.control_[1] = attachment_[LEFT] + dz_perp * height * state.dir_
+ dz_unit * x1;
- curve.control_[2] = attachments[RIGHT] + dz_perp * height * state.dir_
+ curve.control_[2] = attachment_[RIGHT] + dz_perp * height * state.dir_
+ dz_unit * x2;
- curve.control_[3] = attachments[RIGHT];
+ curve.control_[3] = attachment_[RIGHT];
- return curve;
+ curve_ = avoid_staff_line (state, curve);
+ height_ = height;
}
Slur_configuration::Slur_configuration()
{
score_ = 0.0;
+ index_ = -1;
};
-void
-Slur_configuration::generate_curve (Slur_score_state const &state,
- Real r_0, Real h_inf )
-{
- Bezier bez = get_bezier (state,
- attachment_, r_0, h_inf);
- bez = avoid_staff_line (state, bez);
- attachment_[LEFT] = bez.control_[0];
- attachment_[RIGHT] = bez.control_[3];
- curve_ = bez;
-}
+
void
Slur_configuration::score_encompass (Slur_score_state const &state)
attachment points.
*/
Array<Real> convex_head_distances;
- Array<Real> edge_distances;
for (int j = 0; j < state.encompass_infos_.size (); j++)
{
Real x = state.encompass_infos_[j].x_;
- bool l_edge = j==0;
- bool r_edge = j==state.encompass_infos_.size ()-1;
+ bool l_edge = j == 0;
+ bool r_edge = j == state.encompass_infos_.size ()-1;
bool edge = l_edge || r_edge;
-
- if (edge)
- {
- edge_distances.push (fabs (attachment_[l_edge ? LEFT : RIGHT][Y_AXIS]
- - state.encompass_infos_[j].get_point (state.dir_)));
- }
-
-
if (! (x < attachment_[RIGHT][X_AXIS]
&& x > attachment_[LEFT][X_AXIS]))
continue;
if (state.dir_ * (y - state.encompass_infos_[j].stem_) < 0)
{
- Real stem_dem =state.parameters_.stem_encompass_penalty_ ;
+ Real stem_dem = state.parameters_.stem_encompass_penalty_ ;
if ((l_edge && state.dir_ == UP)
|| (r_edge && state.dir_ == DOWN))
stem_dem /= 5;
For slurs over 3 or 4 heads, the average distance is not a
good normalizer.
*/
- int n = convex_head_distances.size ();
- if (convex_head_distances.size () <= 2)
+ Real n = convex_head_distances.size ();
+ if (n <= 2)
{
- // Real min_edge_dist = 1e6;
- for (int j = 0; j < edge_distances.size (); j++)
- {
- avg_distance += edge_distances[j];
- n++;
- }
-
+ Real fact = 1.0;
+ avg_distance += height_ * fact;
+ n += fact;
}
/*
avg_distance /= n;
variance_penalty = state.parameters_.head_slur_distance_max_ratio_;
if (min_dist > 0.0)
- variance_penalty = ((avg_distance / (min_dist +state.parameters_.free_head_distance_)) - 1.0)
+ variance_penalty =
+ (avg_distance / (min_dist + state.parameters_.absolute_closeness_measure_ ) - 1.0)
<? variance_penalty;
+ variance_penalty = variance_penalty >? 0.0;
variance_penalty *= state.parameters_.head_slur_distance_factor_;
}
+
#if DEBUG_SLUR_SCORING
score_card_ += to_string ("C%.2f", demerit);
score_card_ += to_string ("D%.2f", variance_penalty);