]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.5.21
authorfred <fred>
Wed, 27 Mar 2002 02:04:06 +0000 (02:04 +0000)
committerfred <fred>
Wed, 27 Mar 2002 02:04:06 +0000 (02:04 +0000)
lily/gourlay-breaking.cc
lily/include/lily-guile.hh
lily/unfolded-repeat-iterator.cc

index 78e5c2fa04d5b9132c05b47bee55128833e97882..86914fcd0eab394751b69378dad3e74a73fa4e7d 100644 (file)
@@ -59,16 +59,12 @@ Gourlay_breaking::do_solve () const
   
   Array<int> breaks = find_break_indices ();
   
-  optimal_paths.set_size (breaks.size ());
-
   Break_node first_node ;
-  
-  optimal_paths[0] = first_node; 
-  int break_idx=1;
+  optimal_paths.push (first_node);
 
   Real worst_force = 0.0;
   
-  for (; break_idx< breaks.size (); break_idx++) 
+  for (  int break_idx=1; break_idx< breaks.size (); break_idx++) 
     {
       /*
        start with a short line, add measures. At some point 
@@ -96,24 +92,15 @@ Gourlay_breaking::do_solve () const
          sp->solve (&cp);
          delete sp;
 
-         if (cp.force_f_ > worst_force)
-           worst_force = cp.force_f_;
+         if (fabs (cp.force_f_) > worst_force)
+           worst_force = fabs (cp.force_f_);
 
          /*
            We remember this solution as a "should always work
            solution", in case everything fucks up.  */
          if (start_idx == break_idx - 1)
            backup_sol = cp;
-         if (!cp.satisfies_constraints_b_)
-           {
-             /*
-               If it doesn't satisfy constraints, we make this one
-               really unattractive.
-             */
-             cp.force_f_ += worst_force;
-             cp.force_f_ *= 10;        
-           }
-         
+                 
          Real this_demerits;
 
          if (optimal_paths[start_idx].demerits_f_ >= infinity_f)
@@ -137,28 +124,30 @@ Gourlay_breaking::do_solve () const
            break ; 
        }
 
-      int prev =break_idx - 1;
+
+      Break_node bnod;
       if (minimal_start_idx < 0) 
        {
-         optimal_paths[break_idx].demerits_f_ = infinity_f;
-         optimal_paths[break_idx].line_config_ = backup_sol;     
+         bnod.demerits_f_ = infinity_f;
+         bnod.line_config_ = backup_sol;
+         bnod.prev_break_i_ = break_idx - 1;     
        }
       else 
        {
-         prev = minimal_start_idx;
-         optimal_paths[break_idx].line_config_ = minimal_sol;
-         optimal_paths[break_idx].demerits_f_ = minimal_demerits;
+         bnod.prev_break_i_ = minimal_start_idx;
+         bnod.demerits_f_ = minimal_demerits;
+         bnod.line_config_ = minimal_sol;
        }
-      optimal_paths[break_idx].prev_break_i_ = prev;
-      optimal_paths[break_idx].line_i_ = optimal_paths[prev].line_i_ + 1;
-
+      bnod.line_i_ = optimal_paths[bnod.prev_break_i_].line_i_ + 1;
+      optimal_paths.push (bnod);
+      
       if (! (break_idx % HAPPY_DOTS_I))
        progress_indication (String ("[") + to_str (break_idx) + "]");
     }
 
   /* do the last one */
-  if (break_idx % HAPPY_DOTS_I)
-    progress_indication (String ("[") + to_str (break_idx) + "]");    
+  if (breaks.size () % HAPPY_DOTS_I)
+    progress_indication (String ("[") + to_str (breaks.size()) + "]");    
 
 
   progress_indication ("\n");
@@ -214,7 +203,20 @@ Gourlay_breaking::combine_demerits (Column_x_positions const &prev,
        }
     }
 
-  return abs (this_one.force_f_) + abs (prev.force_f_ - this_one.force_f_)
+  Real demerit = abs (this_one.force_f_) + abs (prev.force_f_ - this_one.force_f_)
     + break_penalties;
+
+
+   if (!this_one.satisfies_constraints_b_)
+     {
+       /*
+        If it doesn't satisfy constraints, we make this one
+        really unattractive.
+       */
+       demerit += 10;
+       demerit *= 100;
+     }
+
+   return demerit;
 }
 
index e67293e06f89c3c4897097722899b1e692e53f41..e2a74c779f17a1c2b2835c7b5ab3d9914a590558 100644 (file)
@@ -91,6 +91,12 @@ SCM ly_truncate_list (int k, SCM l );
 #define CACHE_SYMBOLS
 #ifdef CACHE_SYMBOLS
 
+
+/*
+  We don't use gh_symbol2scm directly, since it has const-correctness
+  problems in GUILE 1.3.4
+  
+ */
 SCM my_gh_symbol2scm (const char* x);
 
 // #warning: CACHE_SYMBOLS
@@ -108,12 +114,12 @@ SCM my_gh_symbol2scm (const char* x);
  SCM value = cached;  /* We store this one locally, since G++ -O2 fucks up else */   \
  if ( __builtin_constant_p ((x)))\
  {  if (!cached)\
-     value = cached =  scm_gc_protect_object (my_gh_symbol2scm((char*) (x)));\
+     value = cached =  scm_gc_protect_object (my_gh_symbol2scm((x)));\
  } else\
   value = gh_symbol2scm ((char*) (x)); \
   value; })
 #else
-inline SCM ly_symbol2scm(char const* x) { return gh_symbol2scm((char*)x); }
+inline SCM ly_symbol2scm(char const* x) { return gh_symbol2scm((x)); }
 #endif 
 
 
index 7dd93bd1dcfa8ad4950ff6c8d93da9eb02c979f7..7e8b12fbcd03f7b1a93a66bfb13c8ae8874e8bb6 100644 (file)
@@ -289,7 +289,7 @@ void
 Unfolded_repeat_iterator::add_repeat_command (SCM what)
 {
   SCM reps = ly_symbol2scm ("repeatCommands");
-  SCM current_reps = report_to_l ()->get_property (reps);
+  SCM current_reps = report_to_l ()->internal_get_property (reps);
 
   Translator_group * where = report_to_l ()->where_defined (reps);
   if (where