+ SCM segments_scm = SCM_EOL;
+
+ for (vsize i = segments.size (); i--;)
+ {
+ segments_scm = scm_cons (scm_list_2 (scm_cons (ly_symbol2scm ("vertical-count"),
+ scm_from_int (segments[i].vertical_count_)),
+ scm_cons (ly_symbol2scm ("horizontal"),
+ ly_interval2scm (segments[i].horizontal_))),
+ segments_scm);
+ }
+
+ return segments_scm;
+}
+
+MAKE_SCHEME_CALLBACK (Beam, calc_x_positions, 1);
+SCM
+Beam::calc_x_positions (SCM smob)
+{
+ Spanner *me = unsmob<Spanner> (smob);
+ SCM segments = me->get_property ("beam-segments");
+ Interval x_positions;
+ x_positions.set_empty ();
+ for (SCM s = segments; scm_is_pair (s); s = scm_cdr (s))
+ x_positions.unite (robust_scm2interval (ly_assoc_get (ly_symbol2scm ("horizontal"),
+ scm_car (s),
+ SCM_EOL),
+ Interval (0.0, 0.0)));
+
+ // Case for beams without segments (i.e. uniting two skips with a beam)
+ // TODO: should issue a warning? warning likely issued downstream, but couldn't hurt...
+ if (x_positions.is_empty ())
+ {
+ extract_grob_set (me, "stems", stems);
+ Grob *common_x = common_refpoint_of_array (stems, me, X_AXIS);
+ for (LEFT_and_RIGHT (d))
+ x_positions[d] = me->relative_coordinate (common_x, X_AXIS);
+ }
+ return ly_interval2scm (x_positions);
+}
+
+vector<Beam_segment>
+Beam::get_beam_segments (Grob *me)
+{
+ SCM segments_scm = me->get_property ("beam-segments");
+ vector<Beam_segment> segments;
+ for (SCM s = segments_scm; scm_is_pair (s); s = scm_cdr (s))
+ {
+ segments.push_back (Beam_segment ());
+ segments.back ().vertical_count_ = robust_scm2int (ly_assoc_get (ly_symbol2scm ("vertical-count"), scm_car (s), SCM_EOL), 0);
+ segments.back ().horizontal_ = robust_scm2interval (ly_assoc_get (ly_symbol2scm ("horizontal"), scm_car (s), SCM_EOL), Interval (0.0, 0.0));
+ }
+