+ if (Stem::is_normal_stem (stem))
+ {
+ Interval x;
+ x.add_point (stem->relative_coordinate (x_refpoint_, X_AXIS));
+ x.widen (staff_space / 20); // ugh.
+ Interval y;
+
+ Real stem_end_position = 0.0;
+ if (Stem::is_cross_staff (stem))
+ stem_end_position = get_grob_direction (stem) * infinity_f;
+ else
+ {
+ if (use_horizontal_spacing_ || !Stem::get_beam (stem))
+ stem_end_position = stem->extent (stem, Y_AXIS)[get_grob_direction (stem)];
+ else
+ // May want to change this to the stem's pure height...
+ stem_end_position = Stem::note_head_positions (stem)[get_grob_direction (stem)]
+ * staff_space * .5;
+ }
+
+ y.add_point (stem_end_position);
+
+ Direction stemdir = get_grob_direction (stem);
+ y.add_point (Stem::head_positions (stem)[-stemdir]
+ * staff_space * .5);
+
+ /*
+ add extents of stem.
+ */
+ boxes.push_back (Box (x, y));
+
+ stem_extents_[key].unite (Box (x, y));
+
+ if (dir == LEFT)
+ {
+ Grob *flag = Stem::flag (stem);
+ if (flag)
+ {
+ Grob *commony = stem->common_refpoint (flag, Y_AXIS);
+ boxes.push_back (Box (flag->extent (x_refpoint_, X_AXIS),
+ flag->extent (commony, Y_AXIS)));
+ }
+ }
+ }
+ else
+ {
+ Grob *head = Stem::support_head (stem);
+
+ /*
+ In case of invisible stem, don't pass x-center of heads.
+ */
+ Real x_center = head->extent (x_refpoint_, X_AXIS).center ();
+ Interval x_ext;
+ x_ext[-dir] = x_center;
+ x_ext[dir] = infinity_f * dir;
+ Interval y_ext;
+ for (vsize j = 0; j < head_boxes.size (); j++)
+ y_ext.unite (head_boxes[j][Y_AXIS]);
+
+ boxes.push_back (Box (x_ext, y_ext));
+ }
+
+ extract_grob_set (stem, "note-heads", heads);
+ for (vsize i = 0; i < heads.size (); i++)
+ {
+ if (find (bounds.begin (), bounds.end (), dynamic_cast<Item *> (heads[i])) == bounds.end ())
+ {
+ /*
+ other untied notes in the same chord.
+ */
+
+ Interval y = Staff_symbol_referencer::extent_in_staff (heads[i]);
+ Interval x = heads[i]->extent (x_refpoint_, X_AXIS);
+ boxes.push_back (Box (x, y));
+ }
+
+ Grob *acc = unsmob_grob (heads[i]->get_object ("accidental-grob"));
+ if (acc)
+ acc->get_property ("stencil"); /* trigger tie-related suicide */
+
+ if (acc && acc->is_live () && dir == RIGHT)
+ {
+ boxes.push_back (Box (acc->extent (x_refpoint_, X_AXIS),
+ Staff_symbol_referencer::extent_in_staff (acc)));
+ }
+
+ head_positions_[column_rank].add_point (int (Staff_symbol_referencer::get_position (heads[i])));
+ }