+ Link_array<Grob> ties =
+ Pointer_group_interface__extract_grobs (me, (Grob*)0, "ties");
+
+ if (!ties.size ())
+ return ;
+
+ ties.sort (tie_compare);
+
+ Direction d = get_grob_direction (me);
+ if (d)
+ {
+ for (int i = ties.size (); i--;)
+ {
+ Grob * t = ties[i];
+ if (!get_grob_direction (t))
+ set_grob_direction (t, d);
+ }
+ return ;
+ }
+
+ if (ties.size () == 1)
+ {
+ Grob * t = ties[0];
+ if (t->live ()
+ && !get_grob_direction (t))
+ set_grob_direction (t,Tie::get_default_dir (t));
+ return ;
+ }
+
+ Real last_down_pos = 10000;
+ if (!get_grob_direction (ties[0]))
+ set_grob_direction (ties[0], DOWN);
+
+ for (int i = ties.size (); i--;)
+ {
+ Grob *t = ties[i];
+
+ Direction d = get_grob_direction (t);
+ Real p = Tie::get_position (t);
+ if (!d)
+ {
+ if (last_down_pos - p > 5)
+ {
+ d = UP;
+ }
+ else
+ {
+ d = DOWN;
+ }
+
+ set_grob_direction (t, d);
+ }
+
+ if (d == DOWN)
+ last_down_pos = p;
+ }
+
+ return ;