/*
- do calculations for breaking problem
-
+ do calculations for breaking problem
*/
#include "break.hh"
-#include "paper.hh"
+#include "paper-def.hh"
#include "linespace.hh"
#include "debug.hh"
#include "scoreline.hh"
/*
return all breakable columns
*/
-svec<PCol *>
+Line_of_cols
Break_algorithm::find_breaks() const
{
- svec<PCol *> retval;
+ Line_of_cols retval;
for (iter_top(pscore_.cols,c); c.ok(); c++)
- if (c->breakable())
-
-
- retval.add(c);
-
+ if (c->breakable_b())
+ retval.push(c);
+ assert(retval.top() == pscore_.cols.bottom().ptr());
return retval;
}
// construct an appropriate Spacing_problem and solve it.
-svec<Real>
+Col_hpositions
Break_algorithm::solve_line(Line_of_cols curline) const
{
Spacing_problem sp;
sp.add_column(curline[0], true, 0.0);
- for (int i=1; i< curline.sz()-1; i++)
+ for (int i=1; i< curline.size()-1; i++)
sp.add_column(curline[i]);
- sp.add_column(curline.last(), true, linelength);
+ sp.add_column(curline.top(), true, linelength);
// misschien moeven uit Spacing_problem?
for (iter_top(pscore_.suz,i); i.ok(); i++) {
sp.add_ideal(i);
}
- svec<Real> the_sol=sp.solve();
- return the_sol;
+ Array<Real> the_sol=sp.solve();
+ Col_hpositions col_hpos;
+ col_hpos.cols = curline;
+ col_hpos.energy = the_sol.pop();
+ col_hpos.config = the_sol;
+ col_hpos.OK();
+ return col_hpos;
}
Break_algorithm::Break_algorithm(PScore&s)
:pscore_(s)
{
- linelength = s.paper_->linewidth;
+ linelength = s.paper_l_->linewidth;
}
bool
Break_algorithm::feasible(Line_of_cols curline) const
{
Real l =0;
- for (int i=0; i < curline.sz(); i++)
+ for (int i=0; i < curline.size(); i++)
l +=curline[i]->width().length();
return l < linelength;
}
iter_top(pscore_.cols,start);
PCursor<PCol *> end (pscore_.cols.bottom());
- assert(start->breakable());
- assert(end->breakable());
-#endif
-}
-
-/****************/
-
-Col_configuration::Col_configuration()
-{
- energy = INFTY;
-}
-
-void
-Col_configuration::add( PCol*c)
-{
- cols.add(c);
-}
-
-void
-Col_configuration::setsol(svec<Real> sol)
-{
- config = sol;
- energy = config.last();
- config.pop();
-}
-
-void
-Col_configuration::print() const
-{
-#ifndef NPRINT
- mtor << "energy : " << energy << '\n';
- mtor << "line of " << config.sz() << " cols\n";
+ assert(start->breakable_b());
+ assert(end->breakable_b());
#endif
}
-void
-Col_configuration::OK()const
-{
- assert(config.sz() == cols.sz());
-}