]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/slur-configuration.cc
Imported Upstream version 2.14.2
[lilypond.git] / lily / slur-configuration.cc
index ce368ab9eb2c62eca6aab62947128cc44848869b..1285a3bb5d2357f66f3ef61918c036c455439b1c 100644 (file)
@@ -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 <hanwen@xs4all.nl>
 
-  (c) 2004--2009 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
+  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 <http://www.gnu.org/licenses/>.
 */
 
 #include "slur-configuration.hh"
@@ -166,12 +177,10 @@ Slur_configuration::generate_curve (Slur_score_state const &state,
 
 Slur_configuration::Slur_configuration ()
 {
-  tags_ = 0x0;
   score_ = 0.0;
   index_ = -1;
 };
 
-
 void
 Slur_configuration::add_score (Real s, string desc)
 {
@@ -402,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;
 
@@ -456,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<Offset> 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;
 }