X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Finclude%2Fbeam-scoring-problem.hh;h=6e2302d19a8811960ccb9c30c0a7b7d8ebd7724e;hb=06f227dd80f3a30cbf33c879b7c125079dfaf5c3;hp=755fb388f2b8d6ba3dac2ce24547861e7a3c2c20;hpb=3bd8002b58b0408bf9d0f796744fb012b40ba47d;p=lilypond.git diff --git a/lily/include/beam-scoring-problem.hh b/lily/include/beam-scoring-problem.hh index 755fb388f2..6e2302d19a 100644 --- a/lily/include/beam-scoring-problem.hh +++ b/lily/include/beam-scoring-problem.hh @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 1996--2011 Han-Wen Nienhuys + Copyright (C) 1996--2012 Han-Wen Nienhuys Jan Nieuwenhuizen LilyPond is free software: you can redistribute it and/or modify @@ -21,19 +21,25 @@ #ifndef BEAM_SCORING_PROBLEM_HH #define BEAM_SCORING_PROBLEM_HH +#include "beam.hh" #include "interval.hh" -#include "lily-proto.hh" -#include "lily-guile.hh" -#include "std-vector.hh" -#include "stem-info.hh" +#include "lily-guile.hh" +#include "lily-proto.hh" #include "main.hh" // DEBUG_BEAM_SCORING +#include "std-vector.hh" +#include "stem-info.hh" -enum Scorers { +enum Scorers +{ // Should be ordered by increasing expensiveness. ORIGINAL_DISTANCE, - SLOPES, + SLOPE_IDEAL, + SLOPE_MUSICAL, + SLOPE_DIRECTION, + HORIZONTAL_INTER, FORBIDDEN, STEM_LENGTHS, + COLLISIONS, NUM_SCORERS, }; @@ -50,22 +56,21 @@ struct Beam_configuration Beam_configuration (); bool done () const; void add (Real demerit, const string &reason); - static Beam_configuration* new_config(Interval start, - Interval offset); + static Beam_configuration *new_config (Interval start, + Interval offset); }; // Comparator for a queue of Beam_configuration*. class Beam_configuration_less { public: - bool operator() (Beam_configuration* const& l, Beam_configuration* const& r) + bool operator () (Beam_configuration *const &l, Beam_configuration *const &r) { // Invert return l->demerits > r->demerits; } }; - struct Beam_quant_parameters { Real SECONDARY_BEAM_DEMERIT; @@ -84,38 +89,48 @@ struct Beam_quant_parameters Real HINT_DIRECTION_PENALTY; Real IDEAL_SLOPE_FACTOR; Real ROUND_TO_ZERO_SLOPE; + Real COLLISION_PENALTY; + Real COLLISION_PADDING; + Real HORIZONTAL_INTER_QUANT_PENALTY; + Real STEM_COLLISION_FACTOR; void fill (Grob *him); }; +struct Beam_collision +{ + Real x_; + Interval y_; + Real base_penalty_; + // Need to add beam_config->y to get actual offsets. + Interval beam_y_; +}; /* Parameters for a single beam. Precomputed to save time in scoring individual configurations. - TODO - use trailing _ on data members. - */ class Beam_scoring_problem { public: - Beam_scoring_problem (Grob *me, Drul_array ys); - Drul_array solve() const; + Beam_scoring_problem (Grob *me, Drul_array ys, bool); + Drul_array solve () const; private: - Grob *beam; + Spanner *beam_; - Interval unquanted_y; - - Real staff_space; - Real beam_thickness; - Real line_thickness; - Real musical_dy; + Interval unquanted_y_; + bool align_broken_intos_; + bool do_initial_slope_calculations_; - Interval x_span; - - vector stem_infos; + Real staff_space_; + Real beam_thickness_; + Real line_thickness_; + Real musical_dy_; + int normal_stem_count_; + Real x_span_; /* Do stem computations. These depend on YL and YR linearly, so we can @@ -125,31 +140,58 @@ private: affine linear in YL and YR. If YL == YR == 0, then we might have stem_y != 0.0, when we're cross staff. */ - vector base_lengths; - vector stem_xpositions; - - Grob *common[2]; - bool is_xstaff; - bool is_knee; - - Beam_quant_parameters parameters; - - Real staff_radius; - Drul_array edge_beam_counts; - Drul_array edge_dirs; - Real beam_translation; - - void init_stems (); - - void one_scorer (Beam_configuration* config) const; + vector stem_infos_; + vector chord_start_y_; + vector head_positions_; + vector beam_multiplicity_; + vector is_normal_; + vector base_lengths_; + vector stem_xpositions_; + vector stem_ypositions_; + + bool is_xstaff_; + bool is_knee_; + + Beam_quant_parameters parameters_; + + Real staff_radius_; + Drul_array edge_beam_counts_; + Drul_array edge_dirs_; + + // Half-open intervals, representing allowed positions for the beam, + // starting from close to the notehead to the direction of the stem + // end. This is used for quickly weeding out invalid + // Beam_configurations. + Drul_array quant_range_; + Real beam_translation_; + vector collisions_; + vector segments_; + + vsize first_normal_index (); + vsize last_normal_index (); + + void init_instance_variables (Grob *me, Drul_array ys, bool align_broken_intos); + void add_collision (Real x, Interval y, Real factor); + void no_visible_stem_positions (); + void least_squares_positions (); + Real calc_concaveness (); + void slope_damping (); + void shift_region_to_valid (); + + void one_scorer (Beam_configuration *config) const; Beam_configuration *force_score (SCM inspect_quants, - const vector &configs) const; + const vector &configs) const; + Real y_at (Real x, Beam_configuration const *c) const; // Scoring functions: void score_forbidden_quants (Beam_configuration *config) const; - void score_slopes_dy (Beam_configuration *config) const; - void score_stem_lengths (Beam_configuration* config) const; - void generate_quants(vector* scores) const; + void score_horizontal_inter_quants (Beam_configuration *config) const; + void score_slope_ideal (Beam_configuration *config) const; + void score_slope_direction (Beam_configuration *config) const; + void score_slope_musical (Beam_configuration *config) const; + void score_stem_lengths (Beam_configuration *config) const; + void generate_quants (vector* scores) const; + void score_collisions (Beam_configuration *config) const; }; #endif /* BEAM_SCORING_PROBLEM_HH */