Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 Jan Nieuwenhuizen <janneke@gnu.org> | 5 Jan Nieuwenhuizen <janneke@gnu.org> |
6 | 6 |
7 LilyPond is free software: you can redistribute it and/or modify | 7 LilyPond is free software: you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation, either version 3 of the License, or | 9 the Free Software Foundation, either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 else if (!orig->broken_intos_.size ()) | 192 else if (!orig->broken_intos_.size ()) |
193 consistent_broken_slope_ = false; | 193 consistent_broken_slope_ = false; |
194 else | 194 else |
195 beams.insert (beams.end (), orig->broken_intos_.begin (), orig->broken_i ntos_.end ()); | 195 beams.insert (beams.end (), orig->broken_intos_.begin (), orig->broken_i ntos_.end ()); |
196 } | 196 } |
197 if (!consistent_broken_slope_) | 197 if (!consistent_broken_slope_) |
198 beams.push_back (beam_); | 198 beams.push_back (beam_); |
199 ·· | 199 ·· |
200 x_span_ = 0.0; | 200 x_span_ = 0.0; |
201 normal_stem_count_ = 0; | 201 normal_stem_count_ = 0; |
202 for (vsize i = 0; i < beams.size (); i++) | 202 for (vsize i = 0; i < beams.size (); i++) |
Keith
2011/10/26 18:57:38
When there is more than one beam in 'beams' what d
MikeSol
2011/10/26 19:18:07
All of Beam_scoring_problem happens in an artifici
| |
203 { | 203 { |
204 Interval local_x_span; | 204 Interval local_x_span; |
205 extract_grob_set (beams[i], "stems", stems); | 205 extract_grob_set (beams[i], "stems", stems); |
206 extract_grob_set (beams[i], "covered-grobs", fake_collisions); | 206 extract_grob_set (beams[i], "covered-grobs", fake_collisions); |
207 vector<Grob *> collisions; | 207 vector<Grob *> collisions; |
208 ······ | 208 ······ |
209 for (vsize j = 0; j < fake_collisions.size (); j++) | 209 for (vsize j = 0; j < fake_collisions.size (); j++) |
210 if (fake_collisions[j]->get_system () == beams[i]->get_system ()) | 210 if (fake_collisions[j]->get_system () == beams[i]->get_system ()) |
211 collisions.push_back (fake_collisions[j]); | 211 collisions.push_back (fake_collisions[j]); |
212 | 212 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 add_collision (x, y, factor); | 346 add_collision (x, y, factor); |
347 } | 347 } |
348 x_span_ += beams[i]->spanner_length (); | 348 x_span_ += beams[i]->spanner_length (); |
349 } | 349 } |
350 | 350 |
351 /* | 351 /* |
352 Here, we eliminate all extremal hangover, be it from non-normal stems | 352 Here, we eliminate all extremal hangover, be it from non-normal stems |
353 (like stemlets) or broken beams (if we're not calculating consistent | 353 (like stemlets) or broken beams (if we're not calculating consistent |
354 slope). | 354 slope). |
355 */ | 355 */ |
356 Interval trimmings (0.0, 0.0); | 356 if (normal_stem_count_) |
357 Direction d = LEFT; | 357 { |
358 | 358 Interval trimmings (0.0, 0.0); |
359 do | 359 Direction d = LEFT; |
360 { | 360 |
361 vsize idx = d == LEFT ? first_normal_index () : last_normal_index (); | 361 do |
362 if (!(idx == (d == LEFT ? 0 : is_normal_.size () - 1))) | 362 { |
363 trimmings[d] = d * ((d == LEFT ? 0 : x_span_) - stem_xpositions_[idx]); | 363 vsize idx = d == LEFT ? first_normal_index () : last_normal_index (); |
364 } | 364 trimmings[d] = d * ((d == LEFT ? 0 : x_span_) - stem_xpositions_[idx]) ; |
365 while (flip (&d) != LEFT); | 365 } |
366 | 366 while (flip (&d) != LEFT); |
367 do | 367 |
368 x_span_ -= trimmings[d]; | 368 do |
369 while (flip (&d) != LEFT); | 369 x_span_ -= trimmings[d]; |
370 | 370 while (flip (&d) != LEFT); |
371 for (vsize i = 0; i < stem_xpositions_.size (); i++) | 371 |
372 stem_xpositions_[i] -= trimmings[LEFT]; | 372 for (vsize i = 0; i < stem_xpositions_.size (); i++) |
373 stem_xpositions_[i] -= trimmings[LEFT]; | |
374 } | |
373 } | 375 } |
374 | 376 |
375 Beam_scoring_problem::Beam_scoring_problem (Grob *me, Drul_array<Real> ys) | 377 Beam_scoring_problem::Beam_scoring_problem (Grob *me, Drul_array<Real> ys) |
376 { | 378 { |
377 beam_ = dynamic_cast<Spanner *> (me); | 379 beam_ = dynamic_cast<Spanner *> (me); |
378 unquanted_y_ = ys; | 380 unquanted_y_ = ys; |
379 consistent_broken_slope_ = to_boolean (me->get_property ("consistent-broken-sl ope")); | 381 consistent_broken_slope_ = to_boolean (me->get_property ("consistent-broken-sl ope")); |
380 /* | 382 /* |
381 Calculations are relative to a unit-scaled staff, i.e. the quants are | 383 Calculations are relative to a unit-scaled staff, i.e. the quants are |
382 divided by the current staff_space_. | 384 divided by the current staff_space_. |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
935 } | 937 } |
936 #endif | 938 #endif |
937 | 939 |
938 junk_pointers (configs); | 940 junk_pointers (configs); |
939 if (consistent_broken_slope_) | 941 if (consistent_broken_slope_) |
940 { | 942 { |
941 Interval normalized_endpoints = robust_scm2interval (beam_->get_property ( "normalized-endpoints"), Interval (0, 1)); | 943 Interval normalized_endpoints = robust_scm2interval (beam_->get_property ( "normalized-endpoints"), Interval (0, 1)); |
942 Real y_length = final_positions[RIGHT] - final_positions[LEFT]; | 944 Real y_length = final_positions[RIGHT] - final_positions[LEFT]; |
943 | 945 |
944 final_positions[LEFT] += normalized_endpoints[LEFT] * y_length; | 946 final_positions[LEFT] += normalized_endpoints[LEFT] * y_length; |
945 final_positions[RIGHT] -= (1 - normalized_endpoints[RIGHT]) * y_length; | 947 final_positions[RIGHT] -= (1 - normalized_endpoints[RIGHT]) * y_length; |
Keith
2011/10/26 18:57:38
At what horizontal locations are these final_posit
MikeSol
2011/10/26 19:18:07
Including overhang. This is improved in the most
| |
946 } | 948 } |
947 | 949 |
948 return final_positions; | 950 return final_positions; |
949 } | 951 } |
950 | 952 |
951 void | 953 void |
952 Beam_scoring_problem::score_stem_lengths (Beam_configuration *config) const | 954 Beam_scoring_problem::score_stem_lengths (Beam_configuration *config) const |
953 { | 955 { |
954 Real limit_penalty = parameters_.STEM_LENGTH_LIMIT_PENALTY; | 956 Real limit_penalty = parameters_.STEM_LENGTH_LIMIT_PENALTY; |
955 Drul_array<Real> score (0, 0); | 957 Drul_array<Real> score (0, 0); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1196 Real scale_free | 1198 Real scale_free |
1197 = max (parameters_.COLLISION_PADDING - dist, 0.0) / | 1199 = max (parameters_.COLLISION_PADDING - dist, 0.0) / |
1198 parameters_.COLLISION_PADDING; | 1200 parameters_.COLLISION_PADDING; |
1199 demerits | 1201 demerits |
1200 += collisions_[i].base_penalty_ * | 1202 += collisions_[i].base_penalty_ * |
1201 pow (scale_free, 3) * parameters_.COLLISION_PENALTY; | 1203 pow (scale_free, 3) * parameters_.COLLISION_PENALTY; |
1202 } | 1204 } |
1203 | 1205 |
1204 config->add (demerits, "C"); | 1206 config->add (demerits, "C"); |
1205 } | 1207 } |
LEFT | RIGHT |