+ */
+
+ return 0;
+ }
+
+ return mincol;
+}
+
+/**
+ Correct for optical illusions. See [Wanske] p. 138. The combination
+ up-stem + down-stem should get extra space, the combination
+ down-stem + up-stem less.
+
+ TODO: have to check wether the stems are in the same staff.
+
+*/
+void
+Note_spacing::stem_dir_correction (Grob*me, Item * rcolumn,
+ Real increment,
+ Real * space, Real *fixed)
+{
+ Drul_array<Direction> stem_dirs(CENTER,CENTER);
+ Drul_array<Interval> stem_posns;
+ Drul_array<Interval> head_posns;
+ Drul_array<SCM> props(me->get_grob_property ("left-items"),
+ me->get_grob_property ("right-items"));
+
+ Drul_array<Grob*> beams_drul(0,0);
+
+ stem_dirs[LEFT] = stem_dirs[RIGHT] = CENTER;
+ Interval intersect;
+ Interval bar_xextent;
+ Interval bar_yextent;
+
+ bool correct_stem_dirs = true;
+ Direction d = LEFT;
+ bool acc_right = false;
+
+ do
+ {
+ for (SCM s = props[d]; gh_pair_p (s); s = gh_cdr (s))
+ {
+ Item * it= dynamic_cast<Item*> (unsmob_grob (gh_car(s)));
+
+ if (d == RIGHT)
+ acc_right = acc_right || Note_column::accidentals (it);
+
+ Grob *stem = Note_column::get_stem (it);
+
+ if (!stem || !stem->live ())
+ {
+ if (d == RIGHT && Separation_item::has_interface (it))
+ {
+ if (it->get_column () != rcolumn)
+ {
+ it = it->find_prebroken_piece (rcolumn->break_status_dir ());
+ }
+
+ Grob *last = Staff_spacing::extremal_break_aligned_grob (it, LEFT, &bar_xextent);
+
+ if (last)
+ bar_yextent = Staff_spacing::bar_y_positions (last);
+
+ break;
+ }
+
+ return ;
+ }
+
+ if(Stem::invisible_b (stem))
+ {
+ correct_stem_dirs = false;
+ continue;
+ }
+
+ beams_drul[d] = Stem::get_beam (stem);
+
+
+ Direction sd = Stem::get_direction (stem);
+ if (stem_dirs[d] && stem_dirs[d] != sd)
+ {
+ correct_stem_dirs = false;
+ continue;
+ }
+ stem_dirs[d] = sd;
+
+ /*
+ Correction doesn't seem appropriate when there is a large flag
+ hanging from the note.
+ */
+ if (d == LEFT
+ && Stem::duration_log (stem) > 2 && !Stem::get_beam (stem))
+ {
+ correct_stem_dirs = false;
+ }
+
+
+
+ Interval hp = Stem::head_positions (stem);
+ Real chord_start = hp[sd];
+ Real stem_end = Stem::stem_end_position (stem);
+
+ stem_posns[d] = Interval(chord_start<?stem_end, chord_start>? stem_end);
+ head_posns[d].unite (hp);
+ }