2 simple-spacer.hh -- declare Simple_spacer
4 source file of the GNU LilyPond music typesetter
6 (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #ifndef SIMPLE_SPACER_HH
11 #define SIMPLE_SPACER_HH
14 #include "line-spacer.hh"
17 struct Spring_description
25 Real length (Real force) const;
26 Spring_description ();
27 Real energy_f (Real) const;
31 A simple spacing constraint solver. The approach:
33 Stretch the line uniformly until none of the constraints (rods)
34 block. It then is very wide.
37 Compress until the next constraint blocks,
39 Mark the springs over the constrained part to be non-active.
41 Repeat with the smaller set of non-active constraints, until all
42 constraints blocked, or until the line is as short as desired.
44 This is much simpler, and much much faster than full scale
45 Constrained QP. On the other hand, a situation like this will not
46 be typeset as dense as possible, because
49 veryveryverylongsyllable2 veryveryverylongsyllable2
50 " "4 veryveryverylongsyllable2 syllable4
53 can be further compressed to
57 veryveryverylongsyllable2 veryveryverylongsyllable2
58 " "4 veryveryverylongsyllable2 syllable4
61 Perhaps this is not a bad thing, because the 1st looks better anyway. */
62 struct Simple_spacer: public Line_spacer
64 Array<Spring_description> springs_;
69 virtual void solve (Column_x_positions *) const;
70 virtual void lower_bound_solution (Column_x_positions *) const;
71 virtual void add_columns (Link_array<Paper_column>);
73 void my_solve_linelen ();
74 void my_solve_natural_len ();
75 Real active_springs_stiffness () const;
76 Real range_stiffness (int, int) const;
77 void add_rod (int l, int r, Real dist);
78 Real range_ideal_len (int l, int r)const;
79 Real active_blocking_force ()const;
80 Real configuration_length ()const;
81 void set_active_states ();
82 Real energy_f () const;
84 bool active_b () const;
87 #endif /* SIMPLE_SPACER_HH */