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"
19 Col_stats::str() const {
23 s += String (Real (cols_i_)/count_i_, ", (with an average of %.1f columns)");
29 Col_stats::add (Line_of_cols const& line)
32 cols_i_ += line.size();
36 Col_stats::Col_stats()
42 /* **************************************************************** */
45 Break_algorithm::all_cols() const
48 for (PCursor<Paper_column*> c (pscore_l_->col_p_list_.top());
58 Break_algorithm::find_break_indices() const
60 Line_of_cols all (all_cols());
63 for (int i=0; i < all.size(); i++)
64 if (all[i]->breakable_b_)
68 while (retval.size() >2)
74 /// return all breakable columns
76 Break_algorithm::find_breaks() const
78 Line_of_cols all (all_cols());
81 for (int i=0; i < all.size(); i++)
82 if (all[i]->breakable_b_)
87 while (retval.size() >2)
98 Break_algorithm::generate_spacing_problem (Line_of_cols curline) const
100 Line_spacer * sp= (*get_line_spacer)();
102 sp->paper_l_ = pscore_l_->paper_l_;
103 sp->add_column (curline[0], true, 0.0);
104 for (int i=1; i< curline.size()-1; i++)
105 sp->add_column (curline[i]);
108 sp->add_column (curline.top(), true, linelength);
110 sp->add_column (curline.top());
116 Break_algorithm::Break_algorithm()
124 Break_algorithm::set_pscore (Paper_score*s)
127 linelength = s->paper_l_->linewidth_f();
132 Break_algorithm::feasible (Line_of_cols curline) const
138 for (int i=0; i < curline.size(); i++)
139 l +=curline[i]->width().length ();
140 return l < linelength;
144 Break_algorithm::problem_OK() const
146 if (!pscore_l_->col_p_list_.size())
147 error ("Score does not have any columns");
152 Break_algorithm::OK() const
155 iter_top (pscore_l_->col_p_list_,start);
156 PCursor<Paper_column *> end (pscore_l_->col_p_list_.bottom());
158 assert (start->breakable_b_);
159 assert (end->breakable_b_);
163 Array<Col_hpositions>
164 Break_algorithm::solve() const
170 Break_algorithm::do_set_pscore()
176 Break_algorithm::print_stats() const
178 if (approx_stats_.count_i_)
179 *mlog << "\nApproximated: " << approx_stats_.str() << "\n";
180 if (exact_stats_.count_i_)
181 *mlog << "Calculated exactly: " << exact_stats_.str() << "\n";