+ if (!covered[i]->is_live())
+ continue;
+
+ Box b;
+ for (Axis a = X_AXIS; a < NO_AXES; incr (a))
+ b[a] = covered[i]->extent (common[a], a);
+
+ if (b[X_AXIS].is_empty () || b[Y_AXIS].is_empty ())
+ continue;
+
+ if (intersection (b[X_AXIS], x_span).is_empty ())
+ continue;
+
+ filtered.push_back (covered[i]);
+ Grob *head_stem = Rhythmic_head::get_stem (covered[i]);
+ if (head_stem && Stem::is_normal_stem (head_stem)
+ && Note_head::has_interface (covered[i]))
+ {
+ if (Stem::get_beam (head_stem))
+ {
+ /*
+ We must assume that stems are infinitely long in this
+ case, as asking for the length of the stem typically
+ leads to circular dependencies.
+
+ This strategy assumes that we don't want to handle the
+ collision of beams in opposite non-forced directions
+ with this code, where shortening the stems of both
+ would resolve the problem, eg.
+
+ x x
+ | |
+ =====
+
+ =====
+ | |
+ x x
+
+ Such beams would need a coordinating grob to resolve
+ the collision, since both will likely want to occupy
+ the centerline.
+ */
+ Direction stemdir = get_grob_direction (head_stem);
+ b[Y_AXIS][stemdir] = stemdir * infinity_f;
+ }
+ else
+ {
+ // TODO - should we include the extent of the stem here?
+ }
+ }
+
+ if (b[Y_AXIS].length () < min_y_size)
+ continue;
+
+ Direction d = LEFT;
+ do
+ {
+ Real x = b[X_AXIS][d] - x_span[LEFT];
+ Real dy = slope * x;
+
+ Direction yd = DOWN;
+ do
+ {
+ Real left_y = b[Y_AXIS][yd];
+
+ if (left_y == yd * infinity_f)
+ {
+ collision_free[yd].set_empty ();
+ continue;
+ }
+
+ left_y -= dy;
+
+ // Translate back to beam as ref point.
+ left_y -= me->relative_coordinate (common[Y_AXIS], Y_AXIS);
+
+ Interval allowed;
+ allowed.set_full ();
+
+ allowed[-yd] = left_y;
+ collision_free[yd].intersect (allowed);
+ }
+ while (flip (&yd) != DOWN);
+ }
+ while (flip (&d) != LEFT);
+ }
+
+ Grob_array *arr =
+ Pointer_group_interface::get_grob_array (me,
+ ly_symbol2scm ("covered-grobs"));
+ arr->set_array (filtered);
+
+ if (collision_free[DOWN].contains (beam_left_y)
+ || collision_free[UP].contains (beam_left_y))
+ {
+ // We're good to go. Do nothing.