+ Grob *this_stem = stems[i];
+ SCM this_beaming = this_stem->get_grob_property ("beaming");
+
+ Direction this_dir = get_grob_direction (this_stem);
+ if (gh_pair_p (last_beaming) && gh_pair_p (this_beaming))
+ {
+ int start_point = position_with_maximal_common_beams
+ (last_beaming, this_beaming,
+ last_dir, this_dir);
+
+ Direction d = LEFT;
+ Slice new_slice ;
+ do
+ {
+ if (d == RIGHT && i == stems.size()-1)
+ continue;
+
+ new_slice.set_empty();
+ SCM s = index_get_cell (this_beaming, d);
+ for (; gh_pair_p (s); s = gh_cdr (s))
+ {
+ int new_beam_pos =
+ start_point - this_dir * gh_scm2int (gh_car (s));
+
+ new_slice.add_point (new_beam_pos);
+ gh_set_car_x (s, scm_int2num (new_beam_pos));
+ }
+
+
+ }
+ while (flip (&d) != LEFT);
+
+ if (!new_slice.is_empty ())
+ last_int = new_slice;
+ }
+ else
+ {
+ gh_set_car_x ( this_beaming, SCM_EOL);
+ SCM s = gh_cdr (this_beaming);
+ for (; gh_pair_p (s); s = gh_cdr (s))
+ {
+ int np = - this_dir * gh_scm2int (gh_car(s));
+ gh_set_car_x (s, scm_int2num (np));
+ last_int.add_point (np);
+ }
+ }
+
+ if (i == stems.size () -1)
+ {
+ gh_set_cdr_x (this_beaming, SCM_EOL);
+ }
+
+ if (scm_ilength (gh_cdr (this_beaming)) > 0)
+ {
+ last_beaming = this_beaming;
+ last_dir = this_dir;
+ }