- for (int i = dir == LEFT ? 0 : mother->broken_into_l_arr_.size () - 1;
- dir == LEFT ? i < mother->broken_into_l_arr_.size () : i > 0;
- dir == LEFT ? i++ : i--)
- {
- if (mother->broken_into_l_arr_[i - dir] == me)
- {
- Score_element *neighbour = mother->broken_into_l_arr_[i];
- if (dir == RIGHT)
- neighbour->set_elt_property ("direction",
- me->get_elt_property ("direction"));
- Real neighbour_y = get_first_notecolumn_y (neighbour, dir);
- Real y = get_first_notecolumn_y (me, -dir);
- int neighbour_cols = scm_ilength (neighbour->get_elt_property ("note-columns"));
- int cols = scm_ilength (me->get_elt_property ("note-columns"));
- o = Offset (0, (y*neighbour_cols + neighbour_y*cols) /
- (cols + neighbour_cols));
- break;
- }
- }
+ int k = broken_spanner_index (dynamic_cast<Spanner*> (me));
+ int j = k + dir;
+ if (j < 0 || j >= mother->broken_intos_.size ())
+ return o;
+
+ Grob *neighbour = mother->broken_intos_[j];
+ if (dir == RIGHT)
+ neighbour->set_property ("direction",
+ me->get_property ("direction"));
+ Real neighbour_y = get_boundary_notecolumn_y (neighbour, dir);
+ Real y = get_boundary_notecolumn_y (me, -dir);
+ int neighbour_cols = scm_ilength (neighbour->get_property ("note-columns"));
+ int cols = scm_ilength (me->get_property ("note-columns"));
+ o = Offset (0, (y*neighbour_cols + neighbour_y*cols) /
+ (cols + neighbour_cols));