- rename sys_ -> system_spec_index_
- rename last() -> is_last()
- make breaks_ private; add last_break_position() method.
- /* our index in the all_ list */
- vsize sys_;
+ vsize system_spec_index_;
- /* if sys_ is a score, then we start at the score_brk_'th possible
+ /* if system_spec_index_ is a score, then we start at the score_brk_'th possible
page-break in the score */
vsize score_break_;
page-break in the score */
vsize score_break_;
- /* if sys_ is a score, this points to the broken column */
+ /* if system_spec_index_ is a score, this points to the broken column */
Grob *col_;
bool score_ender_;
Break_position (vsize s=VPOS, vsize brk=VPOS, Grob *g=NULL, bool end=false)
{
Grob *col_;
bool score_ender_;
Break_position (vsize s=VPOS, vsize brk=VPOS, Grob *g=NULL, bool end=false)
{
+ system_spec_index_ = s;
score_break_ = brk;
col_ = g;
score_ender_ = end;
}
/*
score_break_ = brk;
col_ = g;
score_ender_ = end;
}
/*
- lexicographic in (sys_, score_break_)
+ lexicographic in (system_spec_index_, score_break_)
*/
bool operator< (const Break_position &other)
{
*/
bool operator< (const Break_position &other)
{
- return (sys_ == VPOS && other.sys_ != VPOS)
- || (sys_ < other.sys_)
- || (sys_ == other.sys_ && score_break_ < other.score_break_);
+ return (system_spec_index_ == VPOS && other.system_spec_index_ != VPOS)
+ || (system_spec_index_ < other.system_spec_index_)
+ || (system_spec_index_ == other.system_spec_index_ && score_break_ < other.score_break_);
}
bool operator<= (const Break_position &other)
{
}
bool operator<= (const Break_position &other)
{
- return (sys_ == VPOS)
- || (sys_ < other.sys_ && other.sys_ != VPOS)
- || (sys_ == other.sys_ && score_break_ <= other.score_break_);
+ return (system_spec_index_ == VPOS)
+ || (system_spec_index_ < other.system_spec_index_ && other.system_spec_index_ != VPOS)
+ || (system_spec_index_ == other.system_spec_index_ && score_break_ <= other.score_break_);
bool ragged () const;
bool ragged_last () const;
bool ragged () const;
bool ragged_last () const;
Real page_height (int page_number, bool last) const;
protected:
Real page_height (int page_number, bool last) const;
protected:
SCM breakpoint_property (vsize breakpoint, char const *str);
SCM breakpoint_property (vsize breakpoint, char const *str);
-
-protected:
- vector<Break_position> breaks_;
-
+ vsize last_break_position () const;
+ vector<Break_position> breaks_;
vector<Break_position> chunks_;
vector<System_spec> system_specs_;
vector<Constrained_breaking> line_breaking_;
vector<Break_position> chunks_;
vector<System_spec> system_specs_;
vector<Constrained_breaking> line_breaking_;
SCM
Optimal_page_breaking::solve ()
{
SCM
Optimal_page_breaking::solve ()
{
- vsize end = breaks_.size () - 1;
+ vsize end = last_break_position ();
vsize min_sys_count = 0;
vsize ideal_sys_count = 0;
vsize max_sys_count = max_system_count (0, end);
vsize min_sys_count = 0;
vsize ideal_sys_count = 0;
vsize max_sys_count = max_system_count (0, end);
vsize
Page_breaking::next_system (Break_position const &break_pos) const
{
vsize
Page_breaking::next_system (Break_position const &break_pos) const
{
- vsize sys = break_pos.sys_;
+ vsize sys = break_pos.system_spec_index_;
if (sys == VPOS) /* beginning of the book */
return 0;
if (sys == VPOS) /* beginning of the book */
return 0;
vsize *line_breaker_end)
{
assert (system_specs_[sys].pscore_);
vsize *line_breaker_end)
{
assert (system_specs_[sys].pscore_);
- assert (next_system (start) <= sys && sys <= end.sys_);
+ assert (next_system (start) <= sys && sys <= end.system_spec_index_);
+ if (start.system_spec_index_ == sys)
*line_breaker_start = start.score_break_;
else
*line_breaker_start = 0;
*line_breaker_start = start.score_break_;
else
*line_breaker_start = 0;
+ if (end.system_spec_index_ == sys)
*line_breaker_end = end.score_break_;
else
*line_breaker_end = VPOS;
*line_breaker_end = end.score_break_;
else
*line_breaker_end = VPOS;
{
Break_position const &pos = breaks_[breakpoint];
{
Break_position const &pos = breaks_[breakpoint];
+ if (pos.system_spec_index_ == VPOS)
- if (system_specs_[pos.sys_].pscore_)
+ if (system_specs_[pos.system_spec_index_].pscore_)
return pos.col_->get_property (str);
return pos.col_->get_property (str);
- return system_specs_[pos.sys_].prob_->get_property (str);
+ return system_specs_[pos.system_spec_index_].prob_->get_property (str);
return Spacing_result ();
if (n == 1)
ret = space_systems_on_1_page (cached_line_details_,
return Spacing_result ();
if (n == 1)
ret = space_systems_on_1_page (cached_line_details_,
- page_height (first_page_num, last ()),
- ragged () || (last () && ragged_last ()));
+ page_height (first_page_num, is_last ()),
+ ragged () || (is_last () && ragged_last ()));
else if (n == 2)
ret = space_systems_on_2_pages (configuration, first_page_num);
else
else if (n == 2)
ret = space_systems_on_2_pages (configuration, first_page_num);
else
Real
Page_breaking::blank_page_penalty () const
{
Real
Page_breaking::blank_page_penalty () const
{
- SCM penalty_sym = last () ? ly_symbol2scm ("blank-last-page-force") : ly_symbol2scm ("blank-page-force");
+ SCM penalty_sym = is_last () ? ly_symbol2scm ("blank-last-page-force") : ly_symbol2scm ("blank-page-force");
return robust_scm2double (book_->paper_->lookup_variable (penalty_sym), 0.0);
}
return robust_scm2double (book_->paper_->lookup_variable (penalty_sym), 0.0);
}
Page_breaking::space_systems_on_2_pages (vsize configuration, vsize first_page_num)
{
Real page1_height = page_height (first_page_num, false);
Page_breaking::space_systems_on_2_pages (vsize configuration, vsize first_page_num)
{
Real page1_height = page_height (first_page_num, false);
- Real page2_height = page_height (first_page_num+1, last ());
+ Real page2_height = page_height (first_page_num + 1, is_last ());
bool ragged1 = ragged ();
bool ragged1 = ragged ();
- bool ragged2 = ragged () || (last () && ragged_last ());
+ bool ragged2 = ragged () || (is_last () && ragged_last ());
/* if there is a forced break, this reduces to 2 1-page problems */
cache_line_details (configuration);
/* if there is a forced break, this reduces to 2 1-page problems */
cache_line_details (configuration);
return current_configurations_[configuration_index];
}
return current_configurations_[configuration_index];
}
-bool Page_breaking::last () const
+bool
+Page_breaking::is_last () const
+{
+ return current_end_breakpoint_ == last_break_position ();
+}
+
+vsize
+Page_breaking::last_break_position () const
- return current_end_breakpoint_ == breaks_.size () - 1;
+ return breaks_.size () - 1;
breaker_ = breaker;
max_page_count_ = 0;
ragged_ = breaker->ragged ();
breaker_ = breaker;
max_page_count_ = 0;
ragged_ = breaker->ragged ();
- ragged_last_ = breaker->last () && breaker->ragged_last ();
+ ragged_last_ = breaker->is_last () && breaker->ragged_last ();
{
state_.clear ();
message (_f ("Calculating page and line breaks (%d possible page breaks)...",
{
state_.clear ();
message (_f ("Calculating page and line breaks (%d possible page breaks)...",
- (int)breaks_.size () - 1) + " ");
- for (vsize i = 0; i + 1 < breaks_.size (); i++)
+ (int) last_break_position ()));
+ for (vsize i = 0; i < last_break_position (); i++)
{
calc_subproblem (i);
progress_indication (string ("[") + to_string (i + 1) + "]");
{
calc_subproblem (i);
progress_indication (string ("[") + to_string (i + 1) + "]");