From cd0c8a649eabc1f61a11e76f93dab919aeeab9a1 Mon Sep 17 00:00:00 2001
From: Mike Solomon <mike@apollinemike.com>
Date: Sat, 8 Jan 2011 14:41:37 -0500
Subject: [PATCH 2/4] Fixes formatting problems

---
 lily/beam-collision-engraver.cc |   10 +---
 lily/beam.cc                    |  128 ++++++++++++++++++++-------------------
 2 files changed, 68 insertions(+), 70 deletions(-)

diff --git a/lily/beam-collision-engraver.cc b/lily/beam-collision-engraver.cc
index 7b8ad9c..dfbaa67 100644
--- a/lily/beam-collision-engraver.cc
+++ b/lily/beam-collision-engraver.cc
@@ -45,23 +45,18 @@ public:
 void
 Beam_collision_engraver::stop_translation_timestep() {
   for (vsize i=0; i < note_heads_.size (); i++)
-  {
     for (vsize j=0; j < active_beams_.size (); j++)
       Pointer_group_interface::add_grob (active_beams_.at (j), ly_symbol2scm ("covering-note-heads"), note_heads_.at (i));
-  }
+
   note_heads_.clear ();
 
   for (vsize i=0; i < end_beams_.size (); i++)
-  {
     for (vsize j=0; j < active_beams_.size (); j++)
-    {
       if (end_beams_.at (i) == active_beams_.at (j))
       {
         active_beams_.erase (active_beams_.begin() + j);
         break;
       }
-    }
-  }
   end_beams_.clear ();
 }
 
@@ -80,10 +75,9 @@ void
 Beam_collision_engraver::acknowledge_beam (Grob_info i)
 {
   for (vsize j=0; j < active_beams_.size (); j++)
-  {
     if (i.grob () == active_beams_.at (j))
       return;
-  }
+
   active_beams_.push_back (i.grob ());
 }
 
diff --git a/lily/beam.cc b/lily/beam.cc
index 506e0a0..00f0668 100644
--- a/lily/beam.cc
+++ b/lily/beam.cc
@@ -941,72 +941,76 @@ Beam::move_to_avoid_collisions (SCM smob, SCM posns)
 
 
   if (fd == ld & !is_cross_staff (me))
-  {
-    Interval has_acc(0.5,-0.5);
-    Interval lacks_acc(0.0,0.0);
-    Direction dummy = LEFT;
-    Real offset = 0.0;
-    Drul_array<Real> pos = ly_scm2interval (posns);
-    extract_grob_set (me, "covering-note-heads", covering_note_heads);
-    Real magic = 0.0;
-
-    extract_grob_set (me, "normal-stems", stems);
-    Grob *commonx = common_refpoint_of_array (stems, me, X_AXIS);
-    Grob *commony = common_refpoint_of_array (stems, me, Y_AXIS);
-    Real x0 = first_normal_stem (me)->relative_coordinate (commonx, X_AXIS);
-    Real xlast = last_normal_stem (me)->relative_coordinate (commonx, X_AXIS);
-
-    Real slope = (pos[LEFT] - pos[RIGHT]) / (x0 - xlast);
-
-    if (fd == UP)
     {
-      magic = 2.0;
-      dummy = LEFT;
-    }
-    else {
-      magic = -2.0;
-      dummy = RIGHT;
-    }
-
-    for (vsize i = 0; i < covering_note_heads.size (); i++)
-    {
-      Grob *s = covering_note_heads.at (i);
-      Grob *acc = unsmob_grob (s->get_object ("accidental-grob"));
-      Real acc_offset = acc ? has_acc[dummy] : lacks_acc[dummy];
-
-      Real y_val = s->relative_coordinate (commony, Y_AXIS) + magic + acc_offset - pos[LEFT];
-
-      Real x_val1 = s->relative_coordinate (commonx, X_AXIS) - x0;
-
-      Real x_val2 = 0.0;
-      Stencil *nh_stencil = unsmob_stencil (s->get_property ("stencil"));
-      if (nh_stencil)
-        x_val2 = x_val1 + nh_stencil->extent(X_AXIS)[RIGHT];
-      else
-        x_val2 = x_val1;
-
-      Real beam_y1 = slope * x_val1;
-      Real beam_y2 = slope * x_val2;
+      Interval has_acc(0.5,-0.5);
+      Interval lacks_acc(0.0,0.0);
+      Direction dummy = LEFT;
+      Real offset = 0.0;
+      Drul_array<Real> pos = ly_scm2interval (posns);
+      extract_grob_set (me, "covering-note-heads", covering_note_heads);
+      Real magic = 0.0;
+
+      extract_grob_set (me, "normal-stems", stems);
+      Grob *commonx = common_refpoint_of_array (stems, me, X_AXIS);
+      Grob *commony = common_refpoint_of_array (stems, me, Y_AXIS);
+      Real x0 = first_normal_stem (me)->relative_coordinate (commonx, X_AXIS);
+      Real xlast = last_normal_stem (me)->relative_coordinate (commonx, X_AXIS);
+
+      Real slope = (pos[LEFT] - pos[RIGHT]) / (x0 - xlast);
 
       if (fd == UP)
-      {
-        if (y_val > beam_y1)
-          offset = max (y_val - beam_y1, offset);
-        if (y_val > beam_y2)
-          offset = max (y_val - beam_y2, offset);
-      } else {
-        if (y_val < beam_y1)
-          offset = min(y_val - beam_y1, offset);
-        if (y_val < beam_y2)
-          offset = min(y_val - beam_y2, offset);
-      }
+        {
+          magic = 2.0;
+          dummy = LEFT;
+        }
+      else
+        {
+          magic = -2.0;
+          dummy = RIGHT;
+        }
+
+      for (vsize i = 0; i < covering_note_heads.size (); i++)
+        {
+          Grob *s = covering_note_heads.at (i);
+          Grob *acc = unsmob_grob (s->get_object ("accidental-grob"));
+          Real acc_offset = acc ? has_acc[dummy] : lacks_acc[dummy];
+
+          Real y_val = s->relative_coordinate (commony, Y_AXIS) + magic + acc_offset - pos[LEFT];
+
+          Real x_val1 = s->relative_coordinate (commonx, X_AXIS) - x0;
+
+          Real x_val2 = 0.0;
+          Stencil *nh_stencil = unsmob_stencil (s->get_property ("stencil"));
+          if (nh_stencil)
+            x_val2 = x_val1 + nh_stencil->extent(X_AXIS)[RIGHT];
+          else
+            x_val2 = x_val1;
+
+          Real beam_y1 = slope * x_val1;
+          Real beam_y2 = slope * x_val2;
+
+          if (fd == UP)
+            {
+              if (y_val > beam_y1)
+                offset = max (y_val - beam_y1, offset);
+              if (y_val > beam_y2)
+                offset = max (y_val - beam_y2, offset);
+            }
+          else
+            {
+              if (y_val < beam_y1)
+                offset = min(y_val - beam_y1, offset);
+              if (y_val < beam_y2)
+                offset = min(y_val - beam_y2, offset);
+            }
+        }
+
+      pos[LEFT] += offset;
+      pos[RIGHT] += offset;
+      return ly_interval2scm (pos);
     }
-
-    pos[LEFT] += offset;
-    pos[RIGHT] += offset;
-    return ly_interval2scm (pos);
-  } else
-    return posns;
+    else
+      return posns;
 }
 /*
   Compute a first approximation to the beam slope.
-- 
1.7.3.2

