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 12 matching lines...) Expand all Loading... | |
23 #include <algorithm> | 23 #include <algorithm> |
24 #include <queue> | 24 #include <queue> |
25 #include <set> | 25 #include <set> |
26 using namespace std; | 26 using namespace std; |
27 | 27 |
28 #include "align-interface.hh" | 28 #include "align-interface.hh" |
29 #include "beam.hh" | 29 #include "beam.hh" |
30 #include "direction.hh" | 30 #include "direction.hh" |
31 #include "directional-element-interface.hh" | 31 #include "directional-element-interface.hh" |
32 #include "grob.hh" | 32 #include "grob.hh" |
33 #include "grob-array.hh" | |
34 #include "item.hh" | |
33 #include "international.hh" | 35 #include "international.hh" |
34 #include "least-squares.hh" | 36 #include "least-squares.hh" |
35 #include "libc-extension.hh" | 37 #include "libc-extension.hh" |
36 #include "main.hh" | 38 #include "main.hh" |
39 #include "note-head.hh" | |
37 #include "output-def.hh" | 40 #include "output-def.hh" |
38 #include "pointer-group-interface.hh" | 41 #include "pointer-group-interface.hh" |
39 #include "spanner.hh" | 42 #include "spanner.hh" |
40 #include "staff-symbol-referencer.hh" | 43 #include "staff-symbol-referencer.hh" |
41 #include "stencil.hh" | 44 #include "stencil.hh" |
42 #include "stem.hh" | 45 #include "stem.hh" |
43 #include "warn.hh" | 46 #include "warn.hh" |
44 | 47 |
45 Real | 48 Real |
46 get_detail (SCM alist, SCM sym, Real def) | 49 get_detail (SCM alist, SCM sym, Real def) |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 (), | 153 (), |
151 "count number of beam scores.") | 154 "count number of beam scores.") |
152 { | 155 { |
153 return scm_from_int (score_count); | 156 return scm_from_int (score_count); |
154 } | 157 } |
155 | 158 |
156 void Beam_scoring_problem::add_collision (Real x, Interval y, | 159 void Beam_scoring_problem::add_collision (Real x, Interval y, |
157 Real score_factor) | 160 Real score_factor) |
158 { | 161 { |
159 // We used to screen for quant range, but no more. | 162 // We used to screen for quant range, but no more. |
163 | |
160 Beam_collision c; | 164 Beam_collision c; |
161 c.beam_y_.set_empty (); | 165 c.beam_y_.set_empty (); |
162 | 166 |
163 for (vsize j = 0; j < segments_.size (); j++) | 167 for (vsize j = 0; j < segments_.size (); j++) |
164 { | 168 { |
165 if (segments_[j].horizontal_.contains (x)) | 169 if (segments_[j].horizontal_.contains (x)) |
166 c.beam_y_.add_point (segments_[j].vertical_count_ * beam_translation_); | 170 c.beam_y_.add_point (segments_[j].vertical_count_ * beam_translation_); |
167 if (segments_[j].horizontal_[LEFT] > x) | 171 if (segments_[j].horizontal_[LEFT] > x) |
168 break; | 172 break; |
169 } | 173 } |
(...skipping 18 matching lines...) Expand all Loading... | |
188 else if (!orig->broken_intos_.size ()) | 192 else if (!orig->broken_intos_.size ()) |
189 consistent_broken_slope_ = false; | 193 consistent_broken_slope_ = false; |
190 else | 194 else |
191 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 ()); |
192 } | 196 } |
193 if (!consistent_broken_slope_) | 197 if (!consistent_broken_slope_) |
194 beams.push_back (beam_); | 198 beams.push_back (beam_); |
195 ·· | 199 ·· |
196 x_span_ = 0.0; | 200 x_span_ = 0.0; |
197 normal_stem_count_ = 0; | 201 normal_stem_count_ = 0; |
198 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
| |
199 { | 203 { |
200 Interval local_x_span; | 204 Interval local_x_span; |
201 extract_grob_set (beams[i], "stems", stems); | 205 extract_grob_set (beams[i], "stems", stems); |
202 extract_grob_set (beams[i], "covered-grobs", fake_collisions); | 206 extract_grob_set (beams[i], "covered-grobs", fake_collisions); |
203 vector<Grob *> collisions; | 207 vector<Grob *> collisions; |
204 ···· | 208 ······ |
205 for (vsize j = 0; j < fake_collisions.size (); j++) | 209 for (vsize j = 0; j < fake_collisions.size (); j++) |
206 if (fake_collisions[j]->get_system () == beams[i]->get_system ()) | 210 if (fake_collisions[j]->get_system () == beams[i]->get_system ()) |
207 collisions.push_back (fake_collisions[j]); | 211 collisions.push_back (fake_collisions[j]); |
208 | 212 |
209 Grob *common[2]; | 213 Grob *common[2]; |
210 for (int a = 2; a--;) | 214 for (int a = 2; a--;) |
211 common[a] = common_refpoint_of_array (stems, beams[i], Axis (a)); | 215 common[a] = common_refpoint_of_array (stems, beams[i], Axis (a)); |
212 | 216 |
213 Real x_left = beams[i]->relative_coordinate(common[X_AXIS], X_AXIS); | 217 Real x_left = beams[i]->relative_coordinate(common[X_AXIS], X_AXIS); |
214 ···· | 218 ······ |
215 Drul_array<Grob *> edge_stems (Beam::first_normal_stem (beams[i]), | 219 Drul_array<Grob *> edge_stems (Beam::first_normal_stem (beams[i]), |
216 Beam::last_normal_stem (beams[i])); | 220 Beam::last_normal_stem (beams[i])); |
217 Direction d = LEFT; | 221 Direction d = LEFT; |
218 do | 222 do |
219 local_x_span[d] = edge_stems[d] ? edge_stems[d]->relative_coordinate (comm on[X_AXIS], X_AXIS) : 0.0; | 223 local_x_span[d] = edge_stems[d] ? edge_stems[d]->relative_coordinate (co mmon[X_AXIS], X_AXIS) : 0.0; |
220 while (flip (&d) != LEFT); | 224 while (flip (&d) != LEFT); |
221 | 225 |
222 Drul_array<bool> dirs_found (0, 0); | 226 Drul_array<bool> dirs_found (0, 0); |
223 ···· | 227 ······ |
224 Real my_y = beams[i]->relative_coordinate (common[Y_AXIS], Y_AXIS); | 228 Real my_y = beams[i]->relative_coordinate (common[Y_AXIS], Y_AXIS); |
225 | 229 |
226 Interval beam_width (-1.0,-1.0); | 230 Interval beam_width (-1.0,-1.0); |
227 for (vsize j = 0; j < stems.size (); j++) | 231 for (vsize j = 0; j < stems.size (); j++) |
228 { | 232 { |
229 Grob *s = stems[j]; | 233 Grob *s = stems[j]; |
230 beam_multiplicity_.push_back (Stem::beam_multiplicity (stems[j])); | 234 beam_multiplicity_.push_back (Stem::beam_multiplicity (stems[j])); |
231 head_positions_.push_back (Stem::head_positions (stems[j])); | 235 head_positions_.push_back (Stem::head_positions (stems[j])); |
232 is_normal_.push_back (Stem::is_normal_stem (stems[j])); | 236 is_normal_.push_back (Stem::is_normal_stem (stems[j])); |
233 | 237 |
234 Stem_info si (Stem::get_stem_info (s)); | 238 Stem_info si (Stem::get_stem_info (s)); |
235 si.scale (1 / staff_space_); | 239 si.scale (1 / staff_space_); |
236 stem_infos_.push_back (si); | 240 stem_infos_.push_back (si); |
237 chord_start_y_.push_back (Stem::chord_start_y (s)); | 241 chord_start_y_.push_back (Stem::chord_start_y (s)); |
238 dirs_found[si.dir_] = true; | 242 dirs_found[si.dir_] = true; |
239 | 243 |
240 bool f = to_boolean (s->get_property ("french-beaming")) | 244 bool f = to_boolean (s->get_property ("french-beaming")) |
241 && s != edge_stems[LEFT] && s != edge_stems[RIGHT]; | 245 && s != edge_stems[LEFT] && s != edge_stems[RIGHT]; |
242 | 246 |
243 Real y = Beam::calc_stem_y (beams[i], s, common, local_x_span[LEFT], loc al_x_span[RIGHT], CENTER, | 247 Real y = Beam::calc_stem_y (beams[i], s, common, local_x_span[LEFT], l ocal_x_span[RIGHT], CENTER, |
244 Interval (0, 0), f); | 248 Interval (0, 0), f); |
245 base_lengths_.push_back (y / staff_space_); | 249 base_lengths_.push_back (y / staff_space_); |
246 stem_xpositions_.push_back (s->relative_coordinate (common[X_AXIS], X_AX IS) - x_left + x_span_); | 250 stem_xpositions_.push_back (s->relative_coordinate (common[X_AXIS], X_ AXIS) - x_left + x_span_); |
247 stem_ypositions_.push_back (s->relative_coordinate (common[Y_AXIS], Y_AX IS) - my_y); | 251 stem_ypositions_.push_back (s->relative_coordinate (common[Y_AXIS], Y_ AXIS) - my_y); |
248 if (is_normal_.back ()) | 252 if (is_normal_.back ()) |
249 { | 253 { |
250 if (beam_width[LEFT] == -1.0) | 254 if (beam_width[LEFT] == -1.0) |
251 beam_width[LEFT] = stem_xpositions_.back (); | 255 beam_width[LEFT] = stem_xpositions_.back (); |
252 beam_width[RIGHT] = stem_xpositions_.back (); | 256 beam_width[RIGHT] = stem_xpositions_.back (); |
253 } | 257 } |
254 } | 258 } |
255 | 259 |
256 edge_dirs_ = Drul_array<Direction> (CENTER, CENTER); | 260 edge_dirs_ = Drul_array<Direction> (CENTER, CENTER); |
257 normal_stem_count_ += Beam::normal_stem_count (beams[i]); | 261 normal_stem_count_ += Beam::normal_stem_count (beams[i]); |
258 if (normal_stem_count_) | 262 if (normal_stem_count_) |
259 edge_dirs_ = Drul_array<Direction> (stem_infos_[0].dir_, | 263 edge_dirs_ = Drul_array<Direction> (stem_infos_[0].dir_, |
260 stem_infos_.back ().dir_); | 264 stem_infos_.back ().dir_); |
261 | 265 |
262 is_xstaff_ = Align_interface::has_interface (common[Y_AXIS]); | 266 is_xstaff_ = Align_interface::has_interface (common[Y_AXIS]); |
263 is_knee_ = dirs_found[LEFT] && dirs_found[RIGHT]; | 267 is_knee_ = dirs_found[LEFT] && dirs_found[RIGHT]; |
264 | 268 |
265 staff_radius_ = Staff_symbol_referencer::staff_radius (beams[i]); | 269 staff_radius_ = Staff_symbol_referencer::staff_radius (beams[i]); |
266 edge_beam_counts_ = Drul_array<int> | 270 edge_beam_counts_ = Drul_array<int> |
267 (Stem::beam_multiplicity (stems[0]).length () + 1, | 271 (Stem::beam_multiplicity (stems[0]).length () + 1, |
268 Stem::beam_multiplicity (stems.back ()).length () + 1); | 272 Stem::beam_multiplicity (stems.back ()).length () + 1) ; |
269 | 273 |
270 // TODO - why are we dividing by staff_space_? | 274 // TODO - why are we dividing by staff_space_? |
271 beam_translation_ = Beam::get_beam_translation (beams[i]) / staff_space_; | 275 beam_translation_ = Beam::get_beam_translation (beams[i]) / staff_space_; |
272 | 276 |
273 d = LEFT; | 277 d = LEFT; |
274 do | 278 do |
275 { | 279 { |
276 quant_range_[d].set_full (); | 280 quant_range_[d].set_full (); |
277 if (!edge_stems[d]) | 281 if (!edge_stems[d]) |
278 continue; | 282 continue; |
279 | 283 |
280 Real stem_offset = edge_stems[d]->relative_coordinate (common[Y_AXIS], Y _AXIS) | 284 Real stem_offset = edge_stems[d]->relative_coordinate (common[Y_AXIS], Y_AXIS) |
281 - beams[i]->relative_coordinate (common[Y_AXIS], Y_AX IS); | 285 - beams[i]->relative_coordinate (common[Y_AXIS], Y_ AXIS); |
282 Interval heads = Stem::head_positions (edge_stems[d]) * 0.5 * staff_spac e_; | 286 Interval heads = Stem::head_positions (edge_stems[d]) * 0.5 * staff_sp ace_; |
283 | 287 |
284 Direction ed = edge_dirs_[d]; | 288 Direction ed = edge_dirs_[d]; |
285 heads.widen (0.5 * staff_space_ | 289 heads.widen (0.5 * staff_space_ |
286 + (edge_beam_counts_[d] - 1) * beam_translation_ + beam_thi ckness_ * .5); | 290 + (edge_beam_counts_[d] - 1) * beam_translation_ + beam_t hickness_ * .5); |
287 quant_range_[d][-ed] = heads[ed] + stem_offset; | 291 quant_range_[d][-ed] = heads[ed] + stem_offset; |
288 } | 292 } |
289 while (flip (&d) != LEFT); | 293 while (flip (&d) != LEFT); |
290 Grob *common_x = NULL; | 294 Grob *common_x = NULL; |
291 segments_ = Beam::get_beam_segments (beams[i], &common_x); | 295 segments_ = Beam::get_beam_segments (beams[i], &common_x); |
292 vector_sort (segments_, beam_segment_less); | 296 vector_sort (segments_, beam_segment_less); |
293 for (vsize j = 0; j < segments_.size (); j++) | 297 for (vsize j = 0; j < segments_.size (); j++) |
294 segments_[j].horizontal_ += (x_span_ - x_left); | 298 segments_[j].horizontal_ += (x_span_ - x_left); |
295 | 299 |
296 set<Grob *> colliding_stems; | 300 set<Grob *> colliding_stems; |
297 for (vsize j = 0; j < collisions.size (); j++) | 301 for (vsize j = 0; j < collisions.size (); j++) |
298 { | 302 { |
299 if (!collisions[j]->is_live ()) | 303 if (!collisions[j]->is_live ()) |
300 continue; | 304 continue; |
301 | 305 |
302 if (Beam::has_interface (collisions[j]) && Beam::is_cross_staff (collisi ons[j])) | 306 if (Beam::has_interface (collisions[j]) && Beam::is_cross_staff (colli sions[j])) |
303 continue; | 307 continue; |
304 | 308 |
305 Box b; | 309 Box b; |
306 for (Axis a = X_AXIS; a < NO_AXES; incr (a)) | 310 for (Axis a = X_AXIS; a < NO_AXES; incr (a)) |
307 b[a] = collisions[j]->extent (common[a], a); | 311 b[a] = collisions[j]->extent (common[a], a); |
308 | 312 |
309 if (b[X_AXIS].is_empty () || b[Y_AXIS].is_empty ()) | 313 if (b[X_AXIS].is_empty () || b[Y_AXIS].is_empty ()) |
310 continue; | 314 continue; |
311 | 315 |
312 b[X_AXIS] += (x_span_ - x_left); | 316 b[X_AXIS] += (x_span_ - x_left); |
313 Real width = b[X_AXIS].length (); | 317 Real width = b[X_AXIS].length (); |
314 Real width_factor = sqrt (width / staff_space_); | 318 Real width_factor = sqrt (width / staff_space_); |
315 | 319 |
316 Direction d = LEFT; | 320 Direction d = LEFT; |
317 do | 321 do |
318 add_collision (b[X_AXIS][d], b[Y_AXIS], width_factor); | 322 add_collision (b[X_AXIS][d], b[Y_AXIS], width_factor); |
319 while (flip (&d) != LEFT); | 323 while (flip (&d) != LEFT); |
320 | 324 |
321 Grob *stem = unsmob_grob (collisions[j]->get_object ("stem")); | 325 Grob *stem = unsmob_grob (collisions[j]->get_object ("stem")); |
322 if (stem && Stem::has_interface (stem) && Stem::is_normal_stem (stem)) | 326 if (stem && Stem::has_interface (stem) && Stem::is_normal_stem (stem)) |
323 { | 327 { |
324 colliding_stems.insert (stem); | 328 colliding_stems.insert (stem); |
325 } | 329 } |
326 } | 330 } |
327 | 331 |
328 for (set<Grob *>::const_iterator it (colliding_stems.begin ()); it != collid ing_stems.end (); it++) | 332 for (set<Grob *>::const_iterator it (colliding_stems.begin ()); it != coll iding_stems.end (); it++) |
329 { | 333 { |
330 Grob *s = *it; | 334 Grob *s = *it; |
331 Real x = (s->extent (common[X_AXIS], X_AXIS) - x_left + x_span_).center (); | 335 Real x = (s->extent (common[X_AXIS], X_AXIS) - x_left + x_span_).cente r (); |
332 | 336 |
333 Direction stem_dir = get_grob_direction (*it); | 337 Direction stem_dir = get_grob_direction (*it); |
334 Interval y; | 338 Interval y; |
335 y.set_full (); | 339 y.set_full (); |
336 y[-stem_dir] = Stem::chord_start_y (*it) + (*it)->relative_coordinate (c ommon[Y_AXIS], Y_AXIS) | 340 y[-stem_dir] = Stem::chord_start_y (*it) + (*it)->relative_coordinate (common[Y_AXIS], Y_AXIS) |
337 - beams[i]->relative_coordinate (common[Y_AXIS], Y_AXIS); | 341 - beams[i]->relative_coordinate (common[Y_AXIS], Y_AXIS ); |
338 | 342 |
339 Real factor = parameters_.STEM_COLLISION_FACTOR; | 343 Real factor = parameters_.STEM_COLLISION_FACTOR; |
340 if (!unsmob_grob (s->get_object ("beam"))) | 344 if (!unsmob_grob (s->get_object ("beam"))) |
341 factor = 1.0; | 345 factor = 1.0; |
342 add_collision (x, y, factor); | 346 add_collision (x, y, factor); |
343 } | 347 } |
344 /* | 348 x_span_ += beams[i]->spanner_length (); |
345 Note that this x_span_ omits all "hangover" from beams, both for | 349 } |
346 stemlets and for the parts that break over stems. | 350 |
347 Perhaps a better solution would be just to omit hangover for | 351 /* |
348 stemlets and count the length for the broken parts. | 352 Here, we eliminate all extremal hangover, be it from non-normal stems |
349 However, that requires more code, and it seems from the regtests that | 353 (like stemlets) or broken beams (if we're not calculating consistent |
350 it wouldn't really have an effect. | 354 slope). |
351 */ | 355 */ |
352 x_span_ += beam_width.length () ? beam_width.length () : beam_->spanner_leng th (); | 356 if (normal_stem_count_) |
353 } | 357 { |
358 Interval trimmings (0.0, 0.0); | |
359 Direction d = LEFT; | |
360 | |
361 do | |
362 { | |
363 vsize idx = d == LEFT ? first_normal_index () : last_normal_index (); | |
364 trimmings[d] = d * ((d == LEFT ? 0 : x_span_) - stem_xpositions_[idx]) ; | |
365 } | |
366 while (flip (&d) != LEFT); | |
367 | |
368 do | |
369 x_span_ -= trimmings[d]; | |
370 while (flip (&d) != LEFT); | |
371 | |
372 for (vsize i = 0; i < stem_xpositions_.size (); i++) | |
373 stem_xpositions_[i] -= trimmings[LEFT]; | |
374 } | |
354 } | 375 } |
355 | 376 |
356 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) |
357 { | 378 { |
358 beam_ = dynamic_cast<Spanner *> (me); | 379 beam_ = dynamic_cast<Spanner *> (me); |
359 unquanted_y_ = ys; | 380 unquanted_y_ = ys; |
360 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")); |
361 /* | 382 /* |
362 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 |
363 divided by the current staff_space_. | 384 divided by the current staff_space_. |
(...skipping 17 matching lines...) Expand all Loading... | |
381 point_in_interval (Interval v, Real dist) | 402 point_in_interval (Interval v, Real dist) |
382 { | 403 { |
383 if (isinf (v[DOWN])) | 404 if (isinf (v[DOWN])) |
384 return v[UP] - dist; | 405 return v[UP] - dist; |
385 else if (isinf (v[UP])) | 406 else if (isinf (v[UP])) |
386 return v[DOWN] + dist; | 407 return v[DOWN] + dist; |
387 else | 408 else |
388 return v.center (); | 409 return v.center (); |
389 } | 410 } |
390 | 411 |
412 /* Set stem's shorten property if unset. | |
413 | |
414 TODO: | |
415 take some y-position (chord/beam/nearest?) into account | |
416 scmify forced-fraction | |
417 | |
418 This is done in beam because the shorten has to be uniform over the | |
419 entire beam. | |
420 */ | |
421 | |
422 void | |
423 set_minimum_dy (Grob *me, Real *dy) | |
424 { | |
425 if (*dy) | |
426 { | |
427 /* | |
428 If dy is smaller than the smallest quant, we | |
429 get absurd direction-sign penalties. | |
430 */ | |
431 | |
432 Real ss = Staff_symbol_referencer::staff_space (me); | |
433 Real beam_thickness = Beam::get_beam_thickness (me) / ss; | |
434 Real slt = Staff_symbol_referencer::line_thickness (me) / ss; | |
435 Real sit = (beam_thickness - slt) / 2; | |
436 Real inter = 0.5; | |
437 Real hang = 1.0 - (beam_thickness - slt) / 2; | |
438 | |
439 *dy = sign (*dy) * max (fabs (*dy), | |
440 min (min (sit, inter), hang)); | |
441 } | |
442 } | |
443 | |
391 void | 444 void |
392 Beam_scoring_problem::no_visible_stem_positions () | 445 Beam_scoring_problem::no_visible_stem_positions () |
393 { | 446 { |
394 if (!head_positions_.size ()) | 447 if (!head_positions_.size ()) |
395 { | 448 { |
396 unquanted_y_ = Interval (0, 0); | 449 unquanted_y_ = Interval (0, 0); |
397 return; | 450 return; |
398 } | 451 } |
399 | 452 |
400 Interval head_positions; | 453 Interval head_positions; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 for (vsize i = 0; i < stem_infos_.size (); i++) | 549 for (vsize i = 0; i < stem_infos_.size (); i++) |
497 if (is_normal_[i]) | 550 if (is_normal_[i]) |
498 ideals.push_back (Offset (stem_xpositions_[i], | 551 ideals.push_back (Offset (stem_xpositions_[i], |
499 stem_infos_[i].ideal_y_ | 552 stem_infos_[i].ideal_y_ |
500 + stem_ypositions_[i])); | 553 + stem_ypositions_[i])); |
501 | 554 |
502 minimise_least_squares (&slope, &y, ideals); | 555 minimise_least_squares (&slope, &y, ideals); |
503 | 556 |
504 dy = slope * x_span_; | 557 dy = slope * x_span_; |
505 | 558 |
506 Beam::set_minimum_dy (beam_, &dy); | 559 set_minimum_dy (beam_, &dy); |
507 | 560 |
508 ldy = dy; | 561 ldy = dy; |
509 unquanted_y_ = Interval (y, (y + dy)); | 562 unquanted_y_ = Interval (y, (y + dy)); |
510 } | 563 } |
511 | 564 |
512 musical_dy_ = ldy; | 565 musical_dy_ = ldy; |
513 } | 566 } |
514 | 567 |
515 void | 568 void |
516 Beam_scoring_problem::slope_damping () | 569 Beam_scoring_problem::slope_damping () |
(...skipping 14 matching lines...) Expand all Loading... | |
531 if (damping) | 584 if (damping) |
532 { | 585 { |
533 Real dy = unquanted_y_[RIGHT] - unquanted_y_[LEFT]; | 586 Real dy = unquanted_y_[RIGHT] - unquanted_y_[LEFT]; |
534 | 587 |
535 Real slope = dy && x_span_ ? dy / x_span_ : 0; | 588 Real slope = dy && x_span_ ? dy / x_span_ : 0; |
536 | 589 |
537 slope = 0.6 * tanh (slope) / (damping + concaveness); | 590 slope = 0.6 * tanh (slope) / (damping + concaveness); |
538 | 591 |
539 Real damped_dy = slope * x_span_; | 592 Real damped_dy = slope * x_span_; |
540 | 593 |
541 Beam::set_minimum_dy (beam_, &damped_dy); | 594 set_minimum_dy (beam_, &damped_dy); |
542 | 595 |
543 unquanted_y_[LEFT] += (dy - damped_dy) / 2; | 596 unquanted_y_[LEFT] += (dy - damped_dy) / 2; |
544 unquanted_y_[RIGHT] -= (dy - damped_dy) / 2; | 597 unquanted_y_[RIGHT] -= (dy - damped_dy) / 2; |
545 | |
546 } | 598 } |
547 } | 599 } |
548 | 600 |
549 void | 601 void |
550 Beam_scoring_problem::shift_region_to_valid () | 602 Beam_scoring_problem::shift_region_to_valid () |
551 { | 603 { |
552 if (!normal_stem_count_) | 604 if (!normal_stem_count_) |
553 return; | 605 return; |
554 | 606 |
555 Real beam_dy = unquanted_y_[RIGHT] - unquanted_y_[LEFT]; | 607 Real beam_dy = unquanted_y_[RIGHT] - unquanted_y_[LEFT]; |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
885 } | 937 } |
886 #endif | 938 #endif |
887 | 939 |
888 junk_pointers (configs); | 940 junk_pointers (configs); |
889 if (consistent_broken_slope_) | 941 if (consistent_broken_slope_) |
890 { | 942 { |
891 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)); |
892 Real y_length = final_positions[RIGHT] - final_positions[LEFT]; | 944 Real y_length = final_positions[RIGHT] - final_positions[LEFT]; |
893 | 945 |
894 final_positions[LEFT] += normalized_endpoints[LEFT] * y_length; | 946 final_positions[LEFT] += normalized_endpoints[LEFT] * y_length; |
895 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
| |
896 } | 948 } |
897 | 949 |
898 return final_positions; | 950 return final_positions; |
899 } | 951 } |
900 | 952 |
901 void | 953 void |
902 Beam_scoring_problem::score_stem_lengths (Beam_configuration *config) const | 954 Beam_scoring_problem::score_stem_lengths (Beam_configuration *config) const |
903 { | 955 { |
904 Real limit_penalty = parameters_.STEM_LENGTH_LIMIT_PENALTY; | 956 Real limit_penalty = parameters_.STEM_LENGTH_LIMIT_PENALTY; |
905 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... | |
1146 Real scale_free | 1198 Real scale_free |
1147 = max (parameters_.COLLISION_PADDING - dist, 0.0) / | 1199 = max (parameters_.COLLISION_PADDING - dist, 0.0) / |
1148 parameters_.COLLISION_PADDING; | 1200 parameters_.COLLISION_PADDING; |
1149 demerits | 1201 demerits |
1150 += collisions_[i].base_penalty_ * | 1202 += collisions_[i].base_penalty_ * |
1151 pow (scale_free, 3) * parameters_.COLLISION_PENALTY; | 1203 pow (scale_free, 3) * parameters_.COLLISION_PENALTY; |
1152 } | 1204 } |
1153 | 1205 |
1154 config->add (demerits, "C"); | 1206 config->add (demerits, "C"); |
1155 } | 1207 } |
LEFT | RIGHT |