]> git.donarmstrong.com Git - lilypond.git/blob - hdr/break.hh
partial: 0.0.24.jcn
[lilypond.git] / hdr / break.hh
1 /*
2   break.hh -- part of LilyPond
3
4   (c) 1996,97 Han-Wen Nienhuys
5 */
6
7 #ifndef BREAK_HH
8 #define BREAK_HH
9 #include "varray.hh"
10 #include "proto.hh"
11 typedef Array<PCol*>  Line_of_cols;
12
13 struct Col_configuration {
14     Line_of_cols cols;
15     Array<Real> config;
16     Real energy;
17
18     /****************/
19     void OK()const;
20     void setsol(Array<Real>);
21     Col_configuration() ;
22     void add( PCol*c);
23     void print() const;
24 };
25
26 struct Break_algorithm {
27     PScore &pscore_;
28     Real linelength;
29
30     /****************/
31
32     Break_algorithm(PScore&);
33     /// check if the spacing/breaking problem is well-stated
34     void problem_OK()const;
35     /// search all pcols which are breakable.
36     Array<PCol *> find_breaks() const;
37
38      /// helper: solve for the columns in #curline#.
39     Array<Real> solve_line(Line_of_cols) const;
40
41     
42     /// does curline fit on the paper?    
43     bool feasible(Line_of_cols)const;
44     
45     virtual Array<Col_configuration> solve()=0;
46 };
47
48 /// wordwrap type algorithm: move to next line if current is optimal.
49 struct Word_wrap : Break_algorithm {
50     virtual Array<Col_configuration> solve();
51     Word_wrap(PScore&);
52 };
53 #endif // BREAK_HH
54