2 break.cc -- implement Break_algorithm
4 source file of the GNU LilyPond music typesetter
6 (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
11 #include "paper-def.hh"
12 #include "linespace.hh"
14 #include "scoreline.hh"
18 /// return all breakable columns
20 Break_algorithm::find_breaks() const
23 for (iter_top(pscore_.cols,c); c.ok(); c++) {
28 while ( retval.size() >2)
35 Break_algorithm::generate_spacing_problem(Line_of_cols curline, Spacing_problem & sp)const
37 sp.add_column(curline[0], true, 0.0);
38 for (int i=1; i< curline.size()-1; i++)
39 sp.add_column(curline[i]);
42 sp.add_column(curline.top(), true, linelength);
44 sp.add_column(curline.top());
48 Break_algorithm::stupid_solution(Line_of_cols curline)const
51 generate_spacing_problem(curline, sp);
52 Col_hpositions colhpos;
53 colhpos.cols = curline;
54 colhpos.energy = INFTY;
55 colhpos.ugh_b_ = true;
56 colhpos.config = sp.try_initial_solution();
60 /// construct an appropriate Spacing_problem and solve it.
62 Break_algorithm::solve_line(Line_of_cols curline) const
65 generate_spacing_problem(curline, sp);
67 // misschien moeven uit Spacing_problem?
68 for (iter_top(pscore_.suz,i); i.ok(); i++) {
73 Array<Real> the_sol=sp.solve();
74 Col_hpositions col_hpos;
75 col_hpos.cols = curline;
76 col_hpos.energy = the_sol.pop();
77 col_hpos.config = the_sol;
78 col_hpos.error_col_l_arr_ = sp.error_pcol_l_arr();
83 Break_algorithm::Break_algorithm(PScore&s)
86 linelength = s.paper_l_->linewidth_f();
90 Break_algorithm::feasible(Line_of_cols curline) const
96 for (int i=0; i < curline.size(); i++)
97 l +=curline[i]->width().length();
98 return l < linelength;
102 Break_algorithm::problem_OK() const
104 if (!pscore_.cols.size())
105 error("Score does not have any columns");
107 iter_top(pscore_.cols,start);
108 PCursor<PCol *> end (pscore_.cols.bottom());
110 assert(start->breakable_b());
111 assert(end->breakable_b());
115 Array<Col_hpositions>
116 Break_algorithm::solve()const