From 7986f3c60cf32f07637795fd1e7d5a21112a4b4e Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Thu, 6 Feb 1997 02:51:23 +0100 Subject: [PATCH] release: 0.0.28 --- .dstreamrc | 35 +++++---- Documentation/lilygut.pod | 69 +++++++++++++++++ NEWS | 14 ++++ Sources.make | 4 +- TODO | 3 - Variables.make | 2 +- configure | 2 +- deps/Makefile | 9 ++- deps/dummy.dep | 1 + flower/Variables.make | 2 +- flower/matdebug.cc | 2 +- flower/vector.cc | 8 +- flower/vector.hh | 1 + genheader | 9 ++- hdr/break.hh | 26 ++----- hdr/colhpos.hh | 29 ++++++++ hdr/inputscore.hh | 2 +- hdr/inputstaff.hh | 2 +- hdr/leastsquares.hh | 1 + hdr/linespace.hh | 1 + hdr/main.hh | 2 +- hdr/proto.hh | 4 +- hdr/pscore.hh | 4 +- hdr/request.hh | 23 ++++-- hdr/score.hh | 2 +- hdr/sourcefile.hh | 1 + hdr/staffelem.hh | 9 ++- input/Makefile | 3 +- input/scsii-menuetto.ly | 153 ++++++++++++++++++++++++++++++++++++++ input/wohltemperirt.ly | 1 + src/beam.cc | 12 ++- src/break.cc | 56 +++----------- src/calcideal.cc | 6 +- src/colhpos.cc | 35 +++++++++ src/complexwalker.cc | 3 +- src/inputscore.cc | 3 +- src/inputstaff.cc | 6 +- src/leastsquares.cc | 10 +++ src/lexerinit.cc | 2 +- src/localkeyitem.cc | 2 +- src/lookup.cc | 2 +- src/main.cc | 2 +- src/parser.y | 10 +-- src/pcol.cc | 2 +- src/pscore.cc | 4 +- src/request.cc | 21 +++++- src/score.cc | 12 ++- src/script.cc | 7 +- src/slur.cc | 7 +- src/sourcefile.cc | 6 ++ src/spanner.cc | 11 ++- src/staffelem.cc | 59 +++++++++++---- src/stem.cc | 4 +- src/textspanner.cc | 5 +- src/timedescription.cc | 3 +- src/warn.cc | 5 +- src/wordwrap.cc | 54 ++++++++------ 57 files changed, 580 insertions(+), 193 deletions(-) create mode 100644 deps/dummy.dep create mode 100644 hdr/colhpos.hh create mode 100644 input/scsii-menuetto.ly create mode 100644 src/colhpos.cc diff --git a/.dstreamrc b/.dstreamrc index 5ca2fa850c..088fbcc81a 100644 --- a/.dstreamrc +++ b/.dstreamrc @@ -2,11 +2,11 @@ My_flex_lexer 1 yyFlexLexer 1 -PCol 0 -Score_column 0 +PCol 1 +Score_column 1 Ineq_constrained_qp 1 -Spacing_problem 0 -Colinfo 0 +Spacing_problem 1 +Colinfo 1 Mixed_qp 1 PScore 1 Idealspacing 1 @@ -22,20 +22,29 @@ Lexer 1 parse_duration 1 parse_pitchmod 1 Col_configuration 1 -Request 0 -Note_req 0 -Rhythmic_req 0 +Request 1 +Note_req 1 +Rhythmic_req 1 Rest_req 1 delete_identifiers 1 Command 1 Staff_commands 1 Stem 1 -Staff 0 +Staff 1 Score 1 -Voice 0 -Voice_element 0 +Voice 1 +Voice_element 1 Input_cursor 1 -Commands_at 0 -Input_command 0 -Time_description 0 +Commands_at 1 +Input_command 1 +Time_description 1 Melodic_req 1 +Stem_req 1 +Group_change_req 1 +Script_req 1 +Colinfo 1 +Word_wrap 1 +Text_req 1 +Script_def 1 +Text_def 1 +Paperdef 1 diff --git a/Documentation/lilygut.pod b/Documentation/lilygut.pod index eae32d2e01..5633ee211a 100644 --- a/Documentation/lilygut.pod +++ b/Documentation/lilygut.pod @@ -117,6 +117,75 @@ support. =back +=head1 Request_register + +In the previous section the idea of Request has been explained, but +this only solves one half of the problem. The other half is +deciding which requests should be honored, which should merged with +other requests, and which should be ignored. Consider this (pseudo)input + + { % chord + \music { [c() c] } + \music { [e() e] } + } + +Both the c and e are part of a chord (they are in the same +Voice_group), so they should share the beams, and the two [ ] pairs +should be merged. The slurs OTOH are specific for each voice, so they +should not be shared. + +The judge in this "allocation" problem is Staff (actually, it's child +C). It uses the C to do most of the +work class. For each request C queries so-called +Cs if they want to accept a request eg, the +C will accept Cs, and turn down +Cs. If C cannot find a register wants the +request, it is junked (with a warning message). + +After all requests have been either assigned, or junked, the Register +will process the requests (which usually means creating an C or +C). If a C creates something, it tells +C. If all requests have been processed, then each +Register is notified of any created Staff_element. + +=head2 example: + + c4 + +produces: + + note_request (duration 1/4) + stem_request (duration 1/4) + +note_request will be taken by a C, stem_request +will be taken by a C. C creates +a C, C creates a C. Both announce +this to the Staff. Staff will tell C about the +C, which will add the C to the C it just +created. + +To decide on merging, C has grouped several +registers. There are a few groups: + +=item * +Staff wide, contains + Local_key_register + +=item * +Voice group, contains + Stem_beam_register + Script_register + Text_register + +=item * +Voice, contains + Slur_register + Notehead_register + + +=item 1 + + =head1 COMMANDS diff --git a/NEWS b/NEWS index 3362d4ffa6..4592ee36f9 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,17 @@ +pl 28 + +Internal + - idealspacing slightly better for multivoice. +Doc + - Request_register +Bugfix + - Script.cc : float exception + - Request::Request(Request) copying of definition pointer + - cleaned dependencies for broken spanners + - stupid typo in Staff_elem::post_processing() + - init of hpos in PCol::PCol + - Word_wrap::solve() bug + pl 27 - preliminary WIN32 support (JN) Features diff --git a/Sources.make b/Sources.make index 56e9623b54..c40a11e55f 100644 --- a/Sources.make +++ b/Sources.make @@ -2,7 +2,7 @@ # sourcefiles to be shipped. Also for dependencies hdr= bar.hh beam.hh boxes.hh break.hh clef.hh clefitem.hh\ - command.hh complexwalker.hh complexstaff.hh\ + colhpos.hh command.hh complexwalker.hh complexstaff.hh\ const.hh debug.hh dimen.hh directionalspanner.hh\ getcommand.hh glob.hh grouping.hh idealspacing.hh\ identifier.hh identparent.hh inputcommand.hh inputcommands.hh\ @@ -24,7 +24,7 @@ hdr= bar.hh beam.hh boxes.hh break.hh clef.hh clefitem.hh\ voicegroup.hh mycc=bar.cc beam.cc boxes.cc break.cc calcideal.cc clef.cc\ - clefitem.cc command.cc complexstaff.cc complexwalker.cc \ + clefitem.cc colhpos.cc command.cc complexstaff.cc complexwalker.cc \ complexprint.cc debug.cc dimen.cc\ directionalspanner.cc\ getcommands.cc grouping.cc groupregs.cc idealspacing.cc identifier.cc\ diff --git a/TODO b/TODO index 0385d4ae0c..ad7d69049e 100644 --- a/TODO +++ b/TODO @@ -28,8 +28,6 @@ SMALLISH PROJECTS * make spanner for staffsym - * Lyric_req: Text_req, Rhythmic_req - * Lookup::tex_glissando, Lookup::tex_bracket, Lookup::tex_cresc, Lookup::tex_decresc (use texbeam.cc as an example.) @@ -64,7 +62,6 @@ DOC * beam generation. - * Request_register * all errors diff --git a/Variables.make b/Variables.make index 39719441bf..f0a26c0c3d 100644 --- a/Variables.make +++ b/Variables.make @@ -40,7 +40,7 @@ endif # version info MAJVER=0 MINVER=0 -PATCHLEVEL=27 +PATCHLEVEL=28 VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) CXXVER=`$(CXX) --version` diff --git a/configure b/configure index 000f31cdc1..e07c529a01 100755 --- a/configure +++ b/configure @@ -3,7 +3,7 @@ PREFIX=${PREFIX:-.} echo using PREFIX=$PREFIX -NEEDFLOWERVER=1.0.2 +NEEDFLOWERVER=1.0.24 flowertar=flower-$NEEDFLOWERVER here=`pwd` cd .. diff --git a/deps/Makefile b/deps/Makefile index 4a3104af2f..79265b1c0f 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -1,9 +1,12 @@ -DISTFILES=Makefile +DISTFILES=Makefile dummy.dep -default: -dist: +dummy.dep: + touch dummy.dep + + +dist: $(DISTFILES) ln $(DISTFILES) $(DDIR)/$(SUBDIR) clean: diff --git a/deps/dummy.dep b/deps/dummy.dep new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/deps/dummy.dep @@ -0,0 +1 @@ + diff --git a/flower/Variables.make b/flower/Variables.make index 67d1863f27..ea51570ce7 100644 --- a/flower/Variables.make +++ b/flower/Variables.make @@ -1,6 +1,6 @@ MAJVER=1 MINVER=0 -PATCHLEVEL=23 +PATCHLEVEL=24 PACKAGENAME=flower #PROFILEFLAG=-pg diff --git a/flower/matdebug.cc b/flower/matdebug.cc index 1c3df9dda1..7aec81909f 100644 --- a/flower/matdebug.cc +++ b/flower/matdebug.cc @@ -35,7 +35,7 @@ Matrix::print() const Vector::operator String() const { String s("vector ["); -#ifndef NDEBUG +#ifndef NPRINT for (int i=0; i < dim(); i++) { s += String(dat[i], "%6f") + ' '; } diff --git a/flower/vector.cc b/flower/vector.cc index bb3008ee5e..5cc76bfd7b 100644 --- a/flower/vector.cc +++ b/flower/vector.cc @@ -1,7 +1,11 @@ #include "vector.hh" - +Vector::Vector(Array d) + : dat(d) +{ + +} Vector::Vector(const Vector&n) - :dat(n.dat) + : dat(n.dat) { } diff --git a/flower/vector.hh b/flower/vector.hh index 2fdf41482a..c039d5ce89 100644 --- a/flower/vector.hh +++ b/flower/vector.hh @@ -16,6 +16,7 @@ public: void OK() const { dat.OK();} int dim() const { return dat.size(); } Vector() { } + Vector(Array d ); Vector(const Vector&n); Vector(int n) { dat.set_size(n); diff --git a/genheader b/genheader index 203ed196ea..6e5b278ab3 100755 --- a/genheader +++ b/genheader @@ -8,10 +8,15 @@ cat << HERE (c) 1997 $USERNAME <$MAILADRESS> */ +HERE + +if [ $1 != `basename .hh` ] +then +cat < Line_of_cols; - -struct Col_configuration { - Line_of_cols cols; - Array config; - Real energy; - - /****************/ - void OK()const; - void setsol(Array); - Col_configuration() ; - void add( PCol*c); - void print() const; -}; +#include "colhpos.hh" struct Break_algorithm { PScore &pscore_; @@ -30,24 +17,25 @@ struct Break_algorithm { /****************/ Break_algorithm(PScore&); + /// check if the spacing/breaking problem is well-stated void problem_OK()const; + /// search all pcols which are breakable. - Array find_breaks() const; + Line_of_cols find_breaks() const; /// helper: solve for the columns in #curline#. - Array solve_line(Line_of_cols) const; + Col_hpositions solve_line(Line_of_cols) const; - /// does curline fit on the paper? bool feasible(Line_of_cols)const; - virtual Array solve()=0; + virtual Array solve()=0; }; /// wordwrap type algorithm: move to next line if current is optimal. struct Word_wrap : Break_algorithm { - virtual Array solve(); + virtual Array solve(); Word_wrap(PScore&); }; #endif // BREAK_HH diff --git a/hdr/colhpos.hh b/hdr/colhpos.hh new file mode 100644 index 0000000000..d06657485f --- /dev/null +++ b/hdr/colhpos.hh @@ -0,0 +1,29 @@ +/* + colhpos.hh -- part of LilyPond + + (c) 1997 Han-Wen Nienhuys +*/ + +#ifndef COLHPOS_HH +#define COLHPOS_HH +#include "varray.hh" +#include "proto.hh" + +typedef Array Line_of_cols; + +struct Col_hpositions { + Line_of_cols cols; + Array config; + Real energy; + + /****************/ + void OK()const; + + Col_hpositions(); + void add( PCol*c); + void print() const; +}; + + +#endif // COLHPOS_HH + diff --git a/hdr/inputscore.hh b/hdr/inputscore.hh index 1555456778..94ff045814 100644 --- a/hdr/inputscore.hh +++ b/hdr/inputscore.hh @@ -9,7 +9,7 @@ /// the total music def of one movement struct Input_score { /// defined where? - String define_spot_str_; + const char* defined_ch_c_l_; int errorlevel_i_; /// paper_, staffs_ and commands_ form the problem definition. diff --git a/hdr/inputstaff.hh b/hdr/inputstaff.hh index 01062de99c..647ffaf8a5 100644 --- a/hdr/inputstaff.hh +++ b/hdr/inputstaff.hh @@ -15,7 +15,7 @@ struct Input_staff { /// defined where? - String define_spot_str_; + const char * defined_ch_c_l_; String type; IPointerList commands_; IPointerList music_; diff --git a/hdr/leastsquares.hh b/hdr/leastsquares.hh index 4d3931ee94..b9a9241d0d 100644 --- a/hdr/leastsquares.hh +++ b/hdr/leastsquares.hh @@ -12,6 +12,7 @@ struct Least_squares { Array input; void minimise(Real &coef, Real &offset); + void OK() const; }; diff --git a/hdr/linespace.hh b/hdr/linespace.hh index 50f13bd35c..e23d334ca6 100644 --- a/hdr/linespace.hh +++ b/hdr/linespace.hh @@ -40,6 +40,7 @@ class Spacing_problem { /// check if problem is too tight bool check_feasible() const; + /// does #this# contain the column #w#? bool contains(const PCol *w); diff --git a/hdr/main.hh b/hdr/main.hh index 1102833fac..e19b0aff12 100644 --- a/hdr/main.hh +++ b/hdr/main.hh @@ -10,6 +10,6 @@ void set_default_output(String s); Input_score* current_iscore_l(); String find_file(String); const char *get_version(); -extern Source* source_l; +extern Source* source_global_l; #endif diff --git a/hdr/proto.hh b/hdr/proto.hh index 4987a70547..1ef4d8d9f2 100644 --- a/hdr/proto.hh +++ b/hdr/proto.hh @@ -23,7 +23,7 @@ struct CNote_info; struct Chord; struct Clef; struct Clef_item; -struct Col_configuration; +struct Col_hpositions; struct Colinfo; struct Command; struct Commands_at ; @@ -90,8 +90,10 @@ struct Slur; struct Slur_req; class Source; class Source_file; +struct Spacing_req ; struct Span_req; struct Spanner; +struct Blank_req; struct Staff; struct Staff_column; struct Staff_command_req; diff --git a/hdr/pscore.hh b/hdr/pscore.hh index f796247353..3b47c65e44 100644 --- a/hdr/pscore.hh +++ b/hdr/pscore.hh @@ -3,7 +3,7 @@ #ifndef PSCORE_HH #define PSCORE_HH -#include "break.hh" +#include "colhpos.hh" #include "varray.hh" #include "pcol.hh" #include "pstaff.hh" @@ -38,7 +38,7 @@ struct PScore { PScore(Paperdef*); /// add a line to the broken stuff. Positions given in #config# - void set_breaking(Array); + void set_breaking(Array); void add(PStaff *); diff --git a/hdr/request.hh b/hdr/request.hh index 9a01ade3fb..203fc9ab05 100644 --- a/hdr/request.hh +++ b/hdr/request.hh @@ -22,7 +22,9 @@ struct Request { virtual Moment duration() const { return 0; } - /* accessors for children */ + /* accessors for children + maybe checkout RTTI + */ virtual Barcheck_req *barcheck() { return 0; } virtual Note_req *note() {return 0;} virtual Script_req *script() {return 0;} @@ -40,6 +42,8 @@ struct Request { virtual Terminate_voice_req *terminate() {return 0;} virtual Group_change_req * groupchange() { return 0;} virtual Group_feature_req * groupfeature() { return 0; } + virtual Spacing_req * spacing() { return 0; } + virtual Blank_req * blank() { return 0; } protected: virtual void do_print()const ; }; @@ -87,6 +91,18 @@ struct Rhythmic_req : virtual Request { REQUESTMETHODS(Rhythmic_req, rhythmic); }; +struct Spacing_req :virtual Request { + Moment next; + Real distance; + Real strength; + /****************/ + REQUESTMETHODS(Spacing_req, spacing); +}; + +struct Blank_req : Spacing_req, Rhythmic_req { + REQUESTMETHODS(Spacing_req, spacing); + +}; ///Put a text above or below (?) this staff. struct Text_req : virtual Request { @@ -309,11 +325,6 @@ struct Grace_notes { }; -struct Spacing_req { - Moment next; - Real distance; -}; - struct Glissando_req : Span_req { }; diff --git a/hdr/score.hh b/hdr/score.hh index 61868a4719..64e2828614 100644 --- a/hdr/score.hh +++ b/hdr/score.hh @@ -16,7 +16,7 @@ struct Score { IPointerList cols_; PScore *pscore_p_; - String define_spot_str_; + const char *defined_ch_c_l_; int errorlevel_i_; Assoc markers_assoc_; diff --git a/hdr/sourcefile.hh b/hdr/sourcefile.hh index 5e97f31a22..1e1e2a8692 100644 --- a/hdr/sourcefile.hh +++ b/hdr/sourcefile.hh @@ -21,6 +21,7 @@ public: bool in_b( char const* pos_ch_c_l ); int line_i( char const* pos_ch_c_l ); String name_str(); + String file_line_no_str(const char *ch_c_l ); private: void close(); diff --git a/hdr/staffelem.hh b/hdr/staffelem.hh index c7751b6ecc..ba3df695bf 100644 --- a/hdr/staffelem.hh +++ b/hdr/staffelem.hh @@ -15,12 +15,12 @@ struct Staff_elem { enum Status { ORPHAN, // not yet added to pstaff VIRGIN, // added to pstaff + PRECALCING, PRECALCED, // calcs before spacing done + POSTCALCING, POSTCALCED, // after spacing calcs done OUTPUT, // molecule has been output } status; - bool calc_children; - Array dependencies; /// the pstaff it is in PStaff *pstaff_l_; @@ -43,6 +43,8 @@ struct Staff_elem { virtual const char *name() const; // to find out derived classes. virtual Spanner* spanner() { return 0; } virtual Item * item() { return 0; } + void add_depedency(Staff_elem* ); + void substitute_dependency(Staff_elem* old, Staff_elem * newdep); protected: /// do printing of derived info. @@ -57,6 +59,8 @@ protected: /// do calculations after determining horizontal spacing virtual void do_post_processing(); + Array dependants; + private: /// member: the symbols Molecule *output; // should scrap, and use temp var? @@ -67,6 +71,7 @@ private: This is needed, because #output# may still be NULL. */ + Array dependencies; }; /** Both Spanner and Item are Staff_elem's. Most Staff_elem's depend on other Staff_elem's, eg, Beam needs to know and set direction of diff --git a/input/Makefile b/input/Makefile index 61c04f111a..182b105fb0 100644 --- a/input/Makefile +++ b/input/Makefile @@ -4,7 +4,8 @@ DISTFILES=Makefile kortjakje.ly pavane.ly maartje.ly\ cadenza.ly scales.ly standchen.ly twinkle.ly\ wohltemperirt.ly error.ly\ martien.ly mlalt.ly mlvio1.ly mlvio2.ly mlcello.ly\ - standchen.tex pavane.tex scsii-menuetto.tex martien.tex + standchen.tex pavane.tex scsii-menuetto.tex scsii-menuetto.ly\ + martien.tex dist: diff --git a/input/scsii-menuetto.ly b/input/scsii-menuetto.ly new file mode 100644 index 0000000000..8401484811 --- /dev/null +++ b/input/scsii-menuetto.ly @@ -0,0 +1,153 @@ +% scsii-menuetto.ly +% +% Solo Cello Suites +% J. S. Bach +% +% Suite II part v +% Menuetto I +% +% Copyright (c) 1995,1996,1997 Jan Nieuwenhuizen +% +% The purpose of this file is to demonstrate features of LilyPond. +% (there is an accompanying LaTeX file, scsii-menuetto.tex) +% + +% \lefttitle{Menuetto} +% \tempo{Moderato} +% \metron{4=120} +% +% \meter{3/4} +% \key\F % key is F ( f-major ) +% \clef\alto % use alto clef +% \duration8 % default duration is 'eight note +% +% \verb{\nobarnumbers} % issue MusiXTeX command +% \barnumbering0 +% \slope{30} % Fool MusiXTeX into 30 / 10 steeper beam +% \stemlength3 % shorter stemlength +% % because piece is set very tightly +%%1 % double comments are included in .tex file +ii_menuetto = music { + $ + \octave{} + \duration{8} + { a2 f2 d2_"\f" } bes4-. | +%%2 + { [ bes^"1" e c_"2"_"4" } +% (^ ) + a bes-. g-. ] a4-.^"4" | +%%3 +% { d4 `bes4-.\stemup } stemup: 2 voices? + { d4 `bes4-. } g4-. [ f-. e-. ] | +%%4 +% { f `a } (^ e ) d cis-. `b-. `a-. ] +% [ f ( e ) d cis-. `b-. `a-. ] + { [ f `a } e d cis-. `b-. `a-. ] +%%5 + { a2 f2 d2 } bes4-. | % @bes4-. | +%%6 +% { bes( e } ) a + { [ bes e } a bes-. g-. ] + 'c4-. | % ='c4-. | +%%7 + { a4-. f4} +% { 'd4-.-\upbow f4 `bes4\stemdown } + { 'd4-.-\upbow f4 `bes4 } +% { 'e4-.-\downbow g4 `g4\stemdown } | + { 'e4-.-\downbow g4 `g4 } | +%%8 +% { 'cis2.-\upbow e2. `a2.\stemdown } :||: + { 'cis2.-\upbow e2. `a2. } | % :||: +%%9 +% \clef "violin" +% { 'e2 a2_f\stemdown } + { 'e2 a2_"\f" } + [ 'd( 'e16 )'f16 ] | +%%10 +% [ { 'e( g } ) 'd 'cis_{ }_{ }_2 'e + { [ 'e g } 'd 'cis_"2" 'e a( )g ] | +%%11 +% { a4\stemup( f2\stemdown } ) 'd4\stemup +% { 'cis4\stemup-. e4\stemdown } + { \music { a4 'd4 'cis4-. } \music { f2 e4 } } | +%%12 +% { 'g^4 d\stemdown } (^ 'f 'e ) 'f 'd^3(^ ) ='c ] | + { [ 'g^"4" d } 'f 'e 'f 'd^"3"( ) 'c ] | +% %13 +% { bes2\stemup g4\stemdown } ( ) f4 +% { 'c4\stemup e4\stemdown } +% { bes2 g4 } f4 { 'c4 e4 } | % \clef "alto" | + { \music { bes2 'c4 } \music { g4 f4 e4 } } | +%%%14 +%% [ { a( f } ) g a f ] { 'd4-\upbow e4 `bes4\stemdown } | + { [ a f } g a f ] { 'd4-\upbow e4 `bes4 } | +%%%15 +%% { 'c4-\downbow f4 `a4\stemdown } [ bes( )a g a ] | +% { 'c4-\downbow f4 `a4 } [ bes( )a g a ] | +%%%16 + [ f( e )f a-. g-. bes-. ] | +%% \tighten % use one line less +%% \newline % start new line +%% | +%%%17 +%% { a2^0^\tr fis2_3 } bes4 | + { a2^"0" fis2_"3" } bes4 | +%%%18 +%% [ { 'c( es } ) bes 'c a ] fis4^\tr | + { [ 'c es } bes 'c a ] fis4 | +%%%19 +%% { 'd4-\downbow g4 `bes4\stemdown } { 'c4-\upbow g4 c4\stemdown } [ { bes d } a ] | + { 'd4-\downbow g4 `bes4 } { 'c4-\upbow g4 c4 } { [ bes d } a ] | +%%%20 +%% [ { 'c( d `g } bes a ) bes g ( ) bes ] | + { [ 'c d `g } bes a bes g( )bes ] | +%%%21 +%% { 'd4\stemup g2\stemdown } (^ ) 'cis4\stemup { 'd4\stemup =f4\stemdown } | +% { 'd4 g2 } 'cis4 { 'd4 f4 } | + { \music { 'd4 'cis4 'd4 } \music { g2 f4 } } | +%%%22 +%% [ { g( cis } )f g e ] { f4 d4 } | + { [ g cis } f g e ] { f4 d4 } | +%%%23 +%% [ `g g ] { e4.\stemup^\tr `a4.\stemdown } d\stemup-\upbow | + [ `g g ] { e4. `a4. } d-\upbow | +%%%24 +%% { d2.^{fine} `a2. `d2.\stemup_{ }_{ }_{3 mins.}} s4 :|| +%% { \textstyle "italic" d2.^"fine" `a2. \textstyle "roman" `d2._"3 mins."} | % :|| + { d2.^"fine" `a2. `d2._"3 mins."} | % :|| +%% \tighten % use one line less + $ +} + +score { + staff { + melodic + music { ii_menuetto } + commands { + key $bes$ + clef "alto" + skip 8:0 + clef "violin" + skip 5:0 + clef "alto" + skip 12:0 + } + } + commands { + meter 3*4 + skip 8:0 + bar ":|:" +% clef "violin" + skip 5:0 +% \clef "alto" + skip 12:0 + bar ":||" + } + paper { + symboltables { table_sixteen } + width 195mm +% unitspace 12mm % this should do, really + unitspace 8mm % to get lily to use only three lines + output "scsii-menuetto.out" + } +} diff --git a/input/wohltemperirt.ly b/input/wohltemperirt.ly index aac7654458..3163a7bf3c 100644 --- a/input/wohltemperirt.ly +++ b/input/wohltemperirt.ly @@ -55,6 +55,7 @@ score { key $bes es as$ } } + staff { basstaf } commands { meter 4*4 skip 8:0 diff --git a/src/beam.cc b/src/beam.cc index 52080a39ab..02e3d3d94f 100644 --- a/src/beam.cc +++ b/src/beam.cc @@ -34,7 +34,7 @@ Stem_info::Stem_info(const Stem*s) idealy = max(dir*s->top, dir*s->bot); miny = max(dir*s->minnote, dir*s-> maxnote); assert(miny <= idealy); - no_beams = s->flag; + } /****************/ @@ -43,10 +43,6 @@ Offset Beam::center()const { assert(status >= POSTCALCED); - if (calc_children){ // URGGGG!!! - Beam*me_p = (Beam*)this; - me_p->do_post_processing(); - } Real w=(paper()->note_width() + width().length())/2.0; return Offset(w, (left_pos + w* slope)*paper()->interline()); @@ -64,7 +60,7 @@ void Beam::add(Stem*s) { stems.bottom().add(s); - s->dependencies.push(this); + s->add_depedency(this); s->print_flag = false; } @@ -177,7 +173,9 @@ Beam::set_grouping(Rhythmic_grouping def, Rhythmic_grouping cur) Spanner * Beam::do_break_at( PCol *, PCol *) const { - return new Beam(*this); + Beam *beam_p= new Beam(*this); + + return beam_p; } void diff --git a/src/break.cc b/src/break.cc index f3832cf0f6..a138049471 100644 --- a/src/break.cc +++ b/src/break.cc @@ -1,6 +1,5 @@ /* - do calculations for breaking problem - + do calculations for breaking problem */ #include "break.hh" #include "paper.hh" @@ -13,19 +12,19 @@ /* return all breakable columns */ -Array +Line_of_cols Break_algorithm::find_breaks() const { - Array retval; + Line_of_cols retval; for (iter_top(pscore_.cols,c); c.ok(); c++) if (c->breakable()) retval.push(c); - + assert(retval.last() == pscore_.cols.bottom().ptr()); return retval; } // construct an appropriate Spacing_problem and solve it. -Array +Col_hpositions Break_algorithm::solve_line(Line_of_cols curline) const { Spacing_problem sp; @@ -40,7 +39,13 @@ Break_algorithm::solve_line(Line_of_cols curline) const sp.add_ideal(i); } Array the_sol=sp.solve(); - return the_sol; + Col_hpositions col_hpos; + col_hpos.cols = curline; + col_hpos.energy = the_sol.last(); + the_sol.pop(); + col_hpos.config = the_sol; + col_hpos.OK(); + return col_hpos; } Break_algorithm::Break_algorithm(PScore&s) @@ -71,40 +76,3 @@ Break_algorithm::problem_OK() const assert(end->breakable()); #endif } - -/****************/ - -Col_configuration::Col_configuration() -{ - energy = INFTY; -} - -void -Col_configuration::add( PCol*c) -{ - cols.push(c); -} - -void -Col_configuration::setsol(Array sol) -{ - config = sol; - energy = config.last(); - config.pop(); -} - -void -Col_configuration::print() const -{ -#ifndef NPRINT - mtor << "energy : " << energy << '\n'; - mtor << "line of " << config.size() << " cols\n"; -#endif -} -void -Col_configuration::OK()const -{ -#ifndef NDEBUG - assert(config.size() == cols.size()); -#endif -} diff --git a/src/calcideal.cc b/src/calcideal.cc index b6d3411508..7fcf65d762 100644 --- a/src/calcideal.cc +++ b/src/calcideal.cc @@ -31,13 +31,15 @@ Score::calc_idealspacing() while (j->when() < d + i->when()) j++; assert( j->when()== d+i->when()); - + pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist); +#if 0 if (!j->musical_ && (j+1).ok() - && (j+1)->when() == j->when()) { + && ) { j++; pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist); } +#endif } } else if (j.ok()) { diff --git a/src/colhpos.cc b/src/colhpos.cc new file mode 100644 index 0000000000..530e4d4483 --- /dev/null +++ b/src/colhpos.cc @@ -0,0 +1,35 @@ +#include "colhpos.hh" +#include "real.hh" +#include "debug.hh" +#include "const.hh" +#include "vector.hh" + +Col_hpositions::Col_hpositions() +{ + energy = INFTY; +} + +void +Col_hpositions::add( PCol*c) +{ + cols.push(c); +} + +void +Col_hpositions::print() const +{ +#ifndef NPRINT + mtor << "energy : " << energy << '\n'; + mtor << "line of " << config.size() << " cols\n"; + Vector v(config); + mtor << v; +#endif +} + +void +Col_hpositions::OK()const +{ +#ifndef NDEBUG + assert(config.size() == cols.size()); +#endif +} diff --git a/src/complexwalker.cc b/src/complexwalker.cc index f1a73e0200..87e3729a07 100644 --- a/src/complexwalker.cc +++ b/src/complexwalker.cc @@ -205,7 +205,8 @@ Complex_walker::try_request(Request*req) } if (!b) - WARN<< "junking request: " <name() <<"\n"; + warning("junking request: " + String(req->name()), + req->defined_ch_c_l_m); } void diff --git a/src/inputscore.cc b/src/inputscore.cc index a5d4a31007..ef684047c4 100644 --- a/src/inputscore.cc +++ b/src/inputscore.cc @@ -36,7 +36,7 @@ Input_score::parse() { Paperdef* paper_p=new Paperdef(*paper_); Score *s_p = new Score(paper_p); - s_p->define_spot_str_ = define_spot_str_; + s_p->defined_ch_c_l_= defined_ch_c_l_; s_p->errorlevel_i_ = errorlevel_i_; Array parsed_staffs; for (iter_top(staffs_,i); i.ok(); i++) { @@ -60,6 +60,7 @@ Input_score::~Input_score() Input_score::Input_score() { + defined_ch_c_l_=0; paper_= 0; errorlevel_i_ = 0; } diff --git a/src/inputstaff.cc b/src/inputstaff.cc index 6cbed38956..8a56643f5c 100644 --- a/src/inputstaff.cc +++ b/src/inputstaff.cc @@ -23,6 +23,7 @@ Input_staff::add(Array &s) Input_staff::Input_staff(String s) { type= s; + defined_ch_c_l_ = 0; } void @@ -48,7 +49,7 @@ Input_staff::parse(Score*score_l) error("Unknown staff-type `" + type +"\'"); p->score_l_ = score_l; - p->define_spot_str_ = define_spot_str_; + p->define_spot_str_ = ""; // todo for (iter_top(music_,i); i.ok(); i++) { Voice_list vl = i->convert(); @@ -67,11 +68,12 @@ Input_staff::parse(Score*score_l) Input_staff::Input_staff(Input_staff const&s) { + for (iter_top(s.commands_,i); i.ok(); i++) commands_.bottom().add(new Input_command(**i)); for (iter_top(s.music_,i); i.ok(); i++) add(i->clone()); - define_spot_str_ = s.define_spot_str_; + defined_ch_c_l_ = s.defined_ch_c_l_; type = s.type; } diff --git a/src/leastsquares.cc b/src/leastsquares.cc index adbc098219..cf9ec478e4 100644 --- a/src/leastsquares.cc +++ b/src/leastsquares.cc @@ -1,8 +1,18 @@ #include "leastsquares.hh" +void +Least_squares::OK() const +{ + assert( input.size() > 1 ); + Real dx = 0.0; + for (int i=1; i < input.size(); i++) + dx += abs (input[i-1].x - input[i].x); + assert(dx); +} void Least_squares::minimise(Real &coef, Real &offset) { + OK(); Real sx = 0.0; Real sy = 0.0; Real sqx =0.0; diff --git a/src/lexerinit.cc b/src/lexerinit.cc index 508c61e30d..92b52ad8b2 100644 --- a/src/lexerinit.cc +++ b/src/lexerinit.cc @@ -38,7 +38,7 @@ Input_file::Input_file(String s) } else { Source_file* sourcefile_p = new Source_file( pf ); - source_l->add( sourcefile_p ); + source_global_l->add( sourcefile_p ); sourcefile_l_ = sourcefile_p; is = sourcefile_l_->istream_l(); } diff --git a/src/localkeyitem.cc b/src/localkeyitem.cc index 383f875d42..c61f1b91af 100644 --- a/src/localkeyitem.cc +++ b/src/localkeyitem.cc @@ -15,7 +15,7 @@ void Local_key_item::add(Item*head_l) { group.push(head_l); - dependencies.push(head_l); + add_depedency(head_l); } void Local_key_item::add(Melodic_req*m_l) diff --git a/src/lookup.cc b/src/lookup.cc index fe22149d12..77cf12554c 100644 --- a/src/lookup.cc +++ b/src/lookup.cc @@ -103,7 +103,7 @@ Symbol Lookup::dots(int j) { if (j>3) - error("max 3 dots"); + error("max 3 dots"); // todo return (*symtables_)("dots")->lookup(j); } diff --git a/src/main.cc b/src/main.cc index 7e20c89a70..e100ec2884 100644 --- a/src/main.cc +++ b/src/main.cc @@ -12,7 +12,7 @@ #include "source.hh" Source source; -Source* source_l = &source; +Source* source_global_l = &source; extern void parse_file(String,String); diff --git a/src/parser.y b/src/parser.y index 8d6ac75f0c..3f01afb423 100644 --- a/src/parser.y +++ b/src/parser.y @@ -19,7 +19,7 @@ #endif Array pre_reqs, post_reqs; -sstack define_spots; +sstack define_spots; Paperdef*default_paper(); char const* defined_ch_c_l; char const* req_defined_ch_c_l; @@ -195,10 +195,10 @@ notename_tab_body: { SCORE */ score_block: SCORE - { define_spots.push(lexer->spot()); } + { define_spots.push(lexer->here_ch_c_l()); } '{' score_body '}' { $$ = $4; - $$->define_spot_str_ = define_spots.pop(); + $$->defined_ch_c_l_ = define_spots.pop(); if (!$$->paper_) $$->paper_ = default_paper(); @@ -333,10 +333,10 @@ paper_body: STAFFs */ staff_block: - STAFF { define_spots.push(lexer->spot()); } + STAFF { define_spots.push(lexer->here_ch_c_l()); } /*cont*/ '{' staff_body '}' { $$ = $4; - $$->define_spot_str_ = define_spots.pop(); + $$-> defined_ch_c_l_ = define_spots.pop(); } ; diff --git a/src/pcol.cc b/src/pcol.cc index 4c9ef91afc..54e177f486 100644 --- a/src/pcol.cc +++ b/src/pcol.cc @@ -97,7 +97,7 @@ PCol::PCol(PCol *parent) prebreak_p_=0; postbreak_p_=0; line_l_=0; - + hpos = -1.0; pscore_l_ = 0; } diff --git a/src/pscore.cc b/src/pscore.cc index 83f71f440c..89a58be790 100644 --- a/src/pscore.cc +++ b/src/pscore.cc @@ -9,7 +9,7 @@ #include "pscore.hh" #include "tstream.hh" #include "item.hh" - +#include "break.hh" Idealspacing* PScore::get_spacing(PCol*l, PCol*r) @@ -229,7 +229,7 @@ PScore::add_broken(Spanner*s) } void -PScore::set_breaking(Array breaking) +PScore::set_breaking(Array breaking) { for (int j=0; j < breaking.size(); j++) { Array &curline(breaking[j].cols); diff --git a/src/request.cc b/src/request.cc index 3be4f8260e..0a5c8dc3d8 100644 --- a/src/request.cc +++ b/src/request.cc @@ -60,10 +60,27 @@ Request::Request() elt_l_ = 0; defined_ch_c_l_m = 0; } -Request::Request(Request const&) +Request::Request(Request const&src) { elt_l_ = 0; - defined_ch_c_l_m = 0; + defined_ch_c_l_m = src.defined_ch_c_l_m; +} +/****************/ +Spacing_req::Spacing_req() +{ + next = 0; + distance = 0; + strength = 0; +} +void +Spacing_req::do_print()const +{ + mtor << "next " << next << "dist " << distance << "strength\n"; +} +void +Blank_req::do_print()const +{ + Spacing_req::do_print(); } /****************/ Melodic_req::Melodic_req() diff --git a/src/score.cc b/src/score.cc index feb7db93e7..f784f30efa 100644 --- a/src/score.cc +++ b/src/score.cc @@ -5,7 +5,9 @@ #include "staff.hh" #include "debug.hh" #include "paper.hh" - +#include "main.hh" +#include "source.hh" +#include "sourcefile.hh" void Score::process() @@ -14,7 +16,7 @@ Score::process() assert (paper_p_); if (last() == Moment(0)) { - error("Need to have music in a score."); + warning("Need to have music in a score.", defined_ch_c_l_); } // distribute commands to disciples pscore_p_ = new PScore(paper_p_); @@ -161,6 +163,7 @@ Score::Score(Paperdef*p) pscore_p_=0; paper_p_ = p; // ?? safe? errorlevel_i_ = 0; + defined_ch_c_l_ = 0; } Score::~Score() @@ -185,7 +188,10 @@ Score::output(String s) *mlog << "output to " << paper_p_->outfile << "...\n"; Tex_stream the_output(paper_p_->outfile); - the_output << "% outputting Score, defined at: " << define_spot_str_ << "\n"; + + the_output << "% outputting Score, defined at: " << + source_global_l-> + sourcefile_l (defined_ch_c_l_)->file_line_no_str(defined_ch_c_l_) << "\n"; pscore_p_->output(the_output); } diff --git a/src/script.cc b/src/script.cc index f9155ea0c4..4b1ae191d0 100644 --- a/src/script.cc +++ b/src/script.cc @@ -11,14 +11,14 @@ void Script::set_stem(Stem*st_l) { stem_l_ = st_l; - dependencies.push(st_l); + add_depedency(st_l); } void Script::set_support(Item*i) { support.push(i); - dependencies.push(i); + add_depedency(i); } Script::Script(Script_req* rq, int staflen) @@ -68,7 +68,7 @@ Script::set_default_pos() Interval v= support_height(); y = v[dir] -dy[-dir] + 2*dir*inter_f; } else { - Real y = (d > 0) ? staffsize + 2: -2; // ug + y = (d > 0) ? staffsize + 2: -2; // ug y *=inter_f; Interval v= support_height(); @@ -78,6 +78,7 @@ Script::set_default_pos() y = y height(); diff --git a/src/slur.cc b/src/slur.cc index 2cdddfec47..bd1f4c3d1d 100644 --- a/src/slur.cc +++ b/src/slur.cc @@ -1,3 +1,8 @@ +/* + + TODO: + think about crossing stems. + */ #include "slur.hh" #include "scalar.hh" #include "lookup.hh" @@ -31,7 +36,7 @@ void Slur::add(Notehead*n) { encompass.push(n); - dependencies.push(n); + add_depedency(n); } void diff --git a/src/sourcefile.cc b/src/sourcefile.cc index 4792483056..f279fae129 100644 --- a/src/sourcefile.cc +++ b/src/sourcefile.cc @@ -174,3 +174,9 @@ Source_file::unmap() size_off_m = 0; } } +String +Source_file::file_line_no_str(const char *cch_c_l ) +{ + return name_str() + ": " + + String( line_i( cch_c_l ) ); +} diff --git a/src/spanner.cc b/src/spanner.cc index ce3cb49162..ad5b2e2552 100644 --- a/src/spanner.cc +++ b/src/spanner.cc @@ -8,17 +8,16 @@ Spanner::do_print()const { mtor << " (unknown) "; } + Spanner* Spanner::broken_at(PCol*c1, PCol *c2)const { - Spanner *me_p = (Spanner*)this; Spanner *span_p = do_break_at(c1,c2); - me_p->calc_children = true; - me_p->dependencies.push(span_p); - - span_p->calc_children = false; // should handle in ctor - + for (int i=0; i < dependants.size(); i++) { + dependants[i]->substitute_dependency((Staff_elem*)this, span_p); + } + span_p->left = c1; span_p->right = c2; diff --git a/src/staffelem.cc b/src/staffelem.cc index 0ef1900203..341b54e32b 100644 --- a/src/staffelem.cc +++ b/src/staffelem.cc @@ -8,20 +8,19 @@ String Staff_elem::TeXstring() const { - assert(!calc_children); Molecule m(*output); m.translate(offset_); // ugh? return m.TeXstring(); } Staff_elem::Staff_elem(Staff_elem const&s) - : dependencies(s.dependencies) + : dependants(s.dependants), + dependencies(s.dependencies) { status = s.status; assert(!s.output); output = 0; pstaff_l_ = s.pstaff_l_; - calc_children = false; offset_ = Offset(0,0); } @@ -29,6 +28,7 @@ Staff_elem::~Staff_elem() { delete output; } + void Staff_elem::translate(Offset O) { @@ -87,7 +87,6 @@ NAME_METHOD(Staff_elem); Staff_elem::Staff_elem() { - calc_children = false; pstaff_l_=0; offset_ = Offset(0,0); output = 0; @@ -107,9 +106,8 @@ Staff_elem::add_processing() { if (status >= VIRGIN) return; - - do_add_processing(); status = VIRGIN; + do_add_processing(); } void @@ -117,23 +115,29 @@ Staff_elem::pre_processing() { if (status >= PRECALCED ) return; + assert(status != PRECALCING); // cyclic dependency + status = PRECALCING; + for (int i=0; i < dependencies.size(); i++) if (dependencies[i]) dependencies[i]->pre_processing(); - if (!calc_children) - do_pre_processing(); + + + do_pre_processing(); status = PRECALCED; } void Staff_elem::post_processing() { - if (status > POSTCALCED) + if (status >= POSTCALCED) return; + assert(status != POSTCALCING);// cyclic dependency + status=POSTCALCING; + for (int i=0; i < dependencies.size(); i++) if (dependencies[i]) dependencies[i]->post_processing(); - if (!calc_children) - do_post_processing(); + do_post_processing(); status=POSTCALCED; } @@ -142,12 +146,12 @@ Staff_elem::molecule_processing() { if (status >= OUTPUT) return; + status = OUTPUT; // do it only once. for (int i=0; i < dependencies.size(); i++) if (dependencies[i]) dependencies[i]->molecule_processing(); - if (!calc_children) - output= brew_molecule_p(); - status = OUTPUT; + + output= brew_molecule_p(); } void @@ -164,3 +168,30 @@ void Staff_elem::do_add_processing() { } + +void +Staff_elem::substitute_dependency(Staff_elem * old, Staff_elem * newdep) +{ + bool hebbes_b=false; + for (int i=0; i < dependencies.size(); i++) { + if (dependencies[i] == old){ + dependencies[i] = newdep; + hebbes_b = true; + } else if (dependencies[i] == newdep) { + hebbes_b = true; + } + } + if (!hebbes_b) + dependencies.push(newdep); +} + +void +Staff_elem::add_depedency(Staff_elem * p) +{ + for (int i=0; i < dependencies.size(); i ++) + if (dependencies[i] == p) + return; + + dependencies.push(p); + p->dependants.push(p); +} diff --git a/src/stem.cc b/src/stem.cc index 2e0d55474e..fc5f9accb4 100644 --- a/src/stem.cc +++ b/src/stem.cc @@ -60,7 +60,7 @@ Stem::add(Notehead *n) if ( p> maxnote) maxnote = p; heads.push(n); - n->dependencies.push(this); + n->add_depedency(this); } @@ -72,11 +72,13 @@ Stem::get_default_dir() Real mean = (minnote+maxnote)/2; return (mean > staff_center) ? -1: 1; } + void Stem::set_default_dir() { dir = get_default_dir(); } + void Stem::set_default_stemlen() { diff --git a/src/textspanner.cc b/src/textspanner.cc index d4de8fb824..021b81fbbb 100644 --- a/src/textspanner.cc +++ b/src/textspanner.cc @@ -10,8 +10,9 @@ void Text_spanner::set_support(Directional_spanner*d) { support = d; - dependencies.push(d); -} + add_depedency(d); +} + Text_spanner::Text_spanner() { support = 0; diff --git a/src/timedescription.cc b/src/timedescription.cc index cabaeb00cf..1a66b44a44 100644 --- a/src/timedescription.cc +++ b/src/timedescription.cc @@ -1,5 +1,6 @@ #include "timedescription.hh" #include "debug.hh" + String Time_description::str()const { @@ -57,7 +58,7 @@ Time_description::Time_description(Moment dt, Time_description const *prev) } else { // default 4/4 whole_per_measure = 1; whole_in_measure =0; - one_beat = 0.25; + one_beat = Moment(1,4); when = 0.0; bars = 0; cadenza_b_ = false; diff --git a/src/warn.cc b/src/warn.cc index 8328f64fb7..f8688d7227 100644 --- a/src/warn.cc +++ b/src/warn.cc @@ -48,10 +48,9 @@ void message( String message_str, char const* context_ch_c_l ) { String str = "lilypond: "; - Source_file* sourcefile_l = source_l->sourcefile_l( context_ch_c_l ); + Source_file* sourcefile_l = source_global_l->sourcefile_l( context_ch_c_l ); if ( sourcefile_l ) { - str += sourcefile_l->name_str() + ": "; - str += String( sourcefile_l->line_i( context_ch_c_l ) ) + ": "; + str += sourcefile_l->file_line_no_str(context_ch_c_l); } str += message_str; if ( sourcefile_l ) { diff --git a/src/wordwrap.cc b/src/wordwrap.cc index e390500d82..cc114e9e52 100644 --- a/src/wordwrap.cc +++ b/src/wordwrap.cc @@ -9,56 +9,62 @@ */ -Array +Array Word_wrap::solve() { problem_OK(); iter_top(pscore_.cols,curcol); - Array breaking; - Array breakpoints(find_breaks()); + Array breaking; + Line_of_cols breakpoints(find_breaks()); assert(breakpoints.size()>=2); - for (int i=0 ; i < breakpoints.size() -1; ) { - Col_configuration minimum; - Col_configuration current; + + int break_idx_i=0; + while ( break_idx_i < breakpoints.size() -1) { + Col_hpositions minimum; + Col_hpositions current; // do another line - PCol *post = breakpoints[i]->postbreak_p_; + PCol *post = breakpoints[break_idx_i]->postbreak_p_; current.add( post); curcol++; // skip the breakable. - i++; + break_idx_i++; - while (i < breakpoints.size()) { + while (break_idx_i < breakpoints.size()) { // add another measure. - while (breakpoints[i] != curcol.ptr()){ - + while (breakpoints[break_idx_i] != curcol.ptr()){ current.add(curcol); curcol++; } - current.add(breakpoints[i]->prebreak_p_ ); + current.add(breakpoints[break_idx_i]->prebreak_p_ ); + + // try to solve if (!feasible(current.cols)) { if (!minimum.cols.size()) error("sorry, this measure is too long"); - break; + current.energy = INFTY; // make sure we go back + } else { + current = solve_line(current.cols); + current.print(); } - current.setsol(solve_line(current.cols)); - current.print(); - + + // update minimum, or backup. if (current.energy < minimum.energy) { minimum = current; } else { // we're one col too far. - i--; - while (curcol.ptr() != breakpoints[i]) + break_idx_i--; + while (curcol.ptr() != breakpoints[break_idx_i]) curcol --; - - break; + break; // do the next line. } - - current.cols.last()=breakpoints[i]; + + + // add nobreak version of breakable column + current.cols.last()=breakpoints[break_idx_i]; curcol ++; - i++; + break_idx_i++; } - mtor << "Adding cols~, next breakpoint " << i << '\n'; + mtor << "Adding cols~, next breakpoint " << break_idx_i << '\n'; breaking.push(minimum); } -- 2.39.5