+ Interval iv = internal_height (me, false);
+
+ if (!beam)
+ return iv;
+ if (!to_boolean (me->get_property ("cross-staff")) && calc_beam)
+ {
+ Interval overshoot;
+ Direction dir = get_grob_direction (me);
+ Direction d = DOWN;
+ do
+ overshoot[d] = d == dir ? dir * infinity_f : iv[d];
+ while (flip (&d) != DOWN);
+
+ vector<Interval> heights;
+ vector<Grob *> my_stems;
+ extract_grob_set (beam, "normal-stems", normal_stems);
+ for (vsize i = 0; i < normal_stems.size (); i++)
+ if (normal_stems[i] != me && get_grob_direction (normal_stems[i]) == dir)
+ {
+ heights.push_back (Stem::internal_pure_height (normal_stems[i], false));
+ my_stems.push_back (normal_stems[i]);
+ iv.unite (heights.back ());
+ }
+ for (vsize i = 0; i < my_stems.size (); i++)
+ cache_pure_height (my_stems[i], iv, heights[i]);
+ iv.intersect (overshoot);
+ }
+
+ return iv;
+}
+
+void
+Stem::cache_pure_height (Grob *me, Interval iv, Interval my_iv)
+{
+ Interval overshoot;
+ Direction dir = get_grob_direction (me);
+ Direction d = DOWN;
+ do
+ overshoot[d] = d == dir ? dir * infinity_f : my_iv[d];
+ while (flip (&d) != DOWN);
+
+ iv.intersect (overshoot);
+ dynamic_cast<Item *> (me)->cache_pure_height (iv);
+}
+
+MAKE_SCHEME_CALLBACK (Stem, calc_stem_end_position, 1)
+SCM
+Stem::calc_stem_end_position (SCM smob)
+{
+ Grob *me = unsmob_grob (smob);
+ return scm_from_double (internal_calc_stem_end_position (me, true));
+}