+SCM
+finish_offset (Grob *me, Direction dir, Real total_off, Real *current_offset)
+{
+ Real ss = Staff_symbol_referencer::staff_space (me);
+ Real minimum_space = ss * robust_scm2double (me->get_property ("minimum-space"), -1);
+ total_off += dir * ss * robust_scm2double (me->get_property ("padding"), 0);
+
+ if (minimum_space >= 0
+ && dir
+ && total_off * dir < minimum_space)
+ total_off = minimum_space * dir;
+
+ if (current_offset)
+ total_off = dir * max (dir * total_off,
+ dir * (*current_offset));
+
+ /* FIXME: 1000 should relate to paper size. */
+ if (fabs (total_off) > 1000)
+ {
+ string msg
+ = String_convert::form_string ("Improbable offset for grob %s: %f",
+ me->name ().c_str (), total_off);
+
+ programming_error (msg);
+ if (strict_infinity_checking)
+ scm_misc_error (__FUNCTION__, "Improbable offset.", SCM_EOL);
+ }
+
+ return scm_from_double (total_off);
+}
+
+set<Grob *>
+get_support_set (Grob *me)
+{
+ // Only slightly kludgy heuristic...
+ // We want to make sure that all AccidentalPlacements'
+ // accidentals make it into the side support
+ extract_grob_set (me, "side-support-elements", proto_support);
+ set<Grob *> support;
+
+ for (vsize i = 0; i < proto_support.size (); i++)
+ {
+ if (Accidental_placement::has_interface (proto_support[i]))
+ {
+ Grob *accs = proto_support[i];
+ for (SCM acs = accs->get_object ("accidental-grobs"); scm_is_pair (acs);
+ acs = scm_cdr (acs))
+ for (SCM s = scm_cdar (acs); scm_is_pair (s); s = scm_cdr (s))
+ {
+ Grob *a = unsmob_grob (scm_car (s));
+ support.insert (a);
+ }
+ }
+ else
+ support.insert (proto_support[i]);
+ }
+ return support;
+}
+