X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fslur-configuration.cc;h=1285a3bb5d2357f66f3ef61918c036c455439b1c;hb=057106293b07b74b00553fe4dc3dfac5c1f3b682;hp=3aabe8407da921647f503d701d13f8d2a3c9855e;hpb=9f3572d98bb948c9689cd1f75401a029451fa001;p=lilypond.git diff --git a/lily/slur-configuration.cc b/lily/slur-configuration.cc index 3aabe8407d..1285a3bb5d 100644 --- a/lily/slur-configuration.cc +++ b/lily/slur-configuration.cc @@ -1,9 +1,20 @@ /* - slur-configuration.cc -- implement Slur_configuration + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2004--2011 Han-Wen Nienhuys - (c) 2004--2006 Han-Wen Nienhuys + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "slur-configuration.hh" @@ -170,7 +181,6 @@ Slur_configuration::Slur_configuration () index_ = -1; }; - void Slur_configuration::add_score (Real s, string desc) { @@ -401,6 +411,7 @@ Slur_configuration::score_edges (Slur_score_state const &state) Real demerit = factor * dy; if (state.extremes_[d].stem_ && state.extremes_[d].stem_dir_ == state.dir_ + // TODO - Stem::get_beaming() should be precomputed. && !Stem::get_beaming (state.extremes_[d].stem_, -d)) demerit /= 5; @@ -455,11 +466,51 @@ Slur_configuration ::score_slopes (Slur_score_state const &state) add_score (demerit, "slope"); } + +// This is a temporary hack to see how much we can gain by using a +// priority queue on the beams to score. +static int score_count = 0; +LY_DEFINE (ly_slur_score_count, "ly:slur-score-count", 0, 0, 0, + (), + "count number of slur scores.") { + return scm_from_int (score_count); +} + void -Slur_configuration::calculate_score (Slur_score_state const &state) +Slur_configuration::run_next_scorer (Slur_score_state const &state) +{ + switch (next_scorer_todo) { + case EXTRA_ENCOMPASS: + score_extra_encompass (state); + break; + case SLOPE: + score_slopes (state); + break; + case EDGES: + score_edges (state); + break; + case ENCOMPASS: + score_encompass (state); + break; + default: + assert (false); + } + next_scorer_todo++; + score_count++; +} + +bool +Slur_configuration::done () const +{ + return next_scorer_todo >= NUM_SCORERS; +} + +Slur_configuration * +Slur_configuration::new_config (Drul_array const &offs, int idx) { - score_extra_encompass (state); - score_slopes (state); - score_edges (state); - score_encompass (state); + Slur_configuration *conf = new Slur_configuration; + conf->attachment_ = offs; + conf->index_ = idx; + conf->next_scorer_todo = INITIAL_SCORE + 1; + return conf; }