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 "line-spacer.hh"
14 #include "scoreline.hh"
18 /// return all breakable columns
20 Break_algorithm::find_breaks() const
23 for (iter_top(pscore_l_->col_p_list_,c); c.ok(); c++) {
28 while ( retval.size() >2)
35 Break_algorithm::generate_spacing_problem(Line_of_cols curline)const
37 Line_spacer * sp= (*get_line_spacer)();
38 sp->paper_l_ = pscore_l_->paper_l_;
39 sp->add_column(curline[0], true, 0.0);
40 for (int i=1; i< curline.size()-1; i++)
41 sp->add_column(curline[i]);
44 sp->add_column(curline.top(), true, linelength);
46 sp->add_column(curline.top());
51 Break_algorithm::stupid_solution(Line_of_cols curline)const
53 Line_spacer *sp =generate_spacing_problem(curline);
54 Col_hpositions colhpos;
55 colhpos.cols = curline;
56 colhpos.energy = INFTY_f;
57 colhpos.ugh_b_ = true;
58 colhpos.config = sp->default_solution();
63 /// construct an appropriate Spacing_problem and solve it.
65 Break_algorithm::solve_line(Line_of_cols curline) const
67 Line_spacer *sp = generate_spacing_problem(curline);
70 Array<Real> the_sol=sp->solve();
71 Col_hpositions col_hpos;
72 col_hpos.cols = curline;
73 col_hpos.energy = the_sol.pop();
74 col_hpos.config = the_sol;
75 col_hpos.error_col_l_arr_ = sp->error_pcol_l_arr();
82 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_l_->col_p_list_.size())
105 error("Score does not have any columns");
110 Break_algorithm::OK()const
113 iter_top(pscore_l_->col_p_list_,start);
114 PCursor<PCol *> end (pscore_l_->col_p_list_.bottom());
116 assert(start->breakable_b());
117 assert(end->breakable_b());
121 Array<Col_hpositions>
122 Break_algorithm::solve()const