+static void
+set_ape_skylines (Accidental_placement_entry *ape,
+ Grob **common)
+{
+ for (vsize j = ape->grobs_.size (); j--;)
+ {
+ Grob *a = ape->grobs_[j];
+ vector<Box> boxes = Accidental_interface::accurate_boxes (a, common);
+ ape->extents_.insert (ape->extents_.end (), boxes.begin (), boxes.end ());
+ }
+ ape->left_skyline_ = Skyline (ape->extents_, 0, Y_AXIS, LEFT);
+ ape->right_skyline_ = Skyline (ape->extents_, 0, Y_AXIS, RIGHT);
+}
+
+static vector<Grob*>
+extract_heads_and_stems (vector<Accidental_placement_entry*> const &apes)
+{
+ vector<Grob*> note_cols;
+ vector<Grob*> ret;
+
+ for (vsize i = apes.size (); i--;)
+ {
+ Accidental_placement_entry *ape = apes[i];
+ for (vsize j = ape->grobs_.size (); j--;)
+ {
+ Grob *acc = ape->grobs_[j];
+ Grob *head = acc->get_parent (Y_AXIS);
+ Grob *col = head->get_parent (X_AXIS);
+
+ if (Note_column::has_interface (col))
+ note_cols.push_back (col);
+ else
+ ret.push_back (head);
+ }
+ }
+
+ /*
+ This is a little kludgy: in case there are note columns without
+ accidentals, we get them from the Note_collision objects.
+ */
+ for (vsize i = note_cols.size (); i--;)
+ {
+ Grob *c = note_cols[i]->get_parent (X_AXIS);
+ if (Note_collision_interface::has_interface (c))
+ {
+ extract_grob_set (c, "elements", columns);
+ concat (note_cols, columns);
+ }
+ }
+
+ /* Now that we have all of the columns, grab all of the note-heads */
+ for (vsize i = note_cols.size (); i--;)
+ concat (ret, extract_grob_array (note_cols[i], "note-heads"));
+
+ /* Now that we have all of the heads, grab all of the stems */
+ for (vsize i = ret.size (); i--;)
+ if (Grob *s = Rhythmic_head::get_stem (ret[i]))
+ ret.push_back (s);
+
+
+ vector_sort (ret, less<Grob*> ());
+ uniq (ret);
+ return ret;
+}
+
+static Grob*
+common_refpoint_of_accidentals (vector<Accidental_placement_entry*> const &apes, Axis a)
+{
+ Grob *ret = 0;
+
+ for (vsize i = apes.size (); i--;)
+ for (vsize j = apes[i]->grobs_.size (); j--;)
+ {
+ if (!ret)
+ ret = apes[i]->grobs_[j];
+ else
+ ret = ret->common_refpoint (apes[i]->grobs_[j], a);
+ }
+
+ return ret;
+}
+
+