+ SCM mol = me->get_uncached_molecule ();
+ return ly_interval2scm (unsmob_molecule (mol)->extent (a));
+}
+
+/*
+ Ugh should have dash-length + dash-period
+ */
+MAKE_SCHEME_CALLBACK (Slur, brew_molecule,1);
+SCM
+Slur::brew_molecule (SCM smob)
+{
+ Grob * me = unsmob_grob (smob);
+ if (!scm_ilength (me->get_grob_property ("note-columns")))
+ {
+ me->suicide ();
+ return SCM_EOL;
+ }
+
+ Real thick = me->paper_l ()->get_var ("stafflinethickness") *
+ gh_scm2double (me->get_grob_property ("thickness"));
+ Bezier one = get_curve (me);
+
+ // get_curve may suicide
+ if (!scm_ilength (me->get_grob_property ("note-columns")))
+ return SCM_EOL;
+
+ Molecule a;
+ SCM d = me->get_grob_property ("dashed");
+ if (gh_number_p (d))
+ a = Lookup::dashed_slur (one, thick, thick * gh_scm2double (d));
+ else
+ a = Lookup::slur (one, Directional_element_interface::get (me) * thick, thick);
+
+ return a.smobbed_copy ();
+}
+
+void
+Slur::set_control_points (Grob*me)
+{
+ Real staff_space = Staff_symbol_referencer::staff_space ((Grob*)me);
+
+ SCM details = me->get_grob_property ("details");
+ SCM h_inf_scm = scm_assq (ly_symbol2scm ("height-limit"), details);
+ SCM r_0_scm = scm_assq (ly_symbol2scm ("ratio"), details);
+
+ Real r_0 = gh_scm2double (gh_cdr (r_0_scm));
+ Real h_inf = staff_space * gh_scm2double (gh_cdr (h_inf_scm));
+
+ Slur_bezier_bow bb (get_encompass_offset_arr (me),
+ Directional_element_interface::get (me),
+ h_inf, r_0);
+
+ if (bb.fit_factor () > 1.0)
+ {
+ Real length = bb.curve_.control_[3][X_AXIS];
+ Real default_height = slur_height (length, h_inf, r_0);
+
+ SCM ssb = me->get_grob_property ("beautiful");
+ Real sb = 0;
+ if (gh_number_p (ssb))
+ sb = gh_scm2double (ssb);
+
+ bb.minimise_enclosed_area (sb, details);
+ SCM sbf = scm_assq (ly_symbol2scm ("force-blowfit"), details);
+ Real bff = 1.0;
+ if (gh_pair_p (sbf) && gh_number_p (gh_cdr (sbf)))
+ bff = gh_scm2double (gh_cdr (sbf));
+
+ bb.curve_.control_[1][Y_AXIS] *= bff;
+ bb.curve_.control_[2][Y_AXIS] *= bff;
+ bb.blow_fit ();
+
+
+ Real beautiful = length * default_height * sb;
+ Real area = bb.enclosed_area_f ();
+
+ /*
+ Slurs that fit beautifully are not ugly
+ */
+ if (area > beautiful)
+ de_uglyfy (me, &bb, default_height);
+ }
+
+ Bezier b = bb.get_bezier ();
+
+
+ SCM controls = SCM_EOL;
+ for (int i= 4; i--;)
+ {
+ controls = gh_cons (ly_offset2scm (b.control_[i]), controls);
+ /*
+ BRRR WHURG.
+ All these null control-points, where do they all come from?
+ */
+ if (i && b.control_[i][X_AXIS] == 0)
+ {
+ me->suicide ();
+ return;
+ }
+ }
+
+ me->set_grob_property ("control-points", controls);
+}
+
+Bezier
+Slur::get_curve (Grob*me)
+{
+ Bezier b;
+ int i = 0;
+
+ if (!Directional_element_interface::get (me)
+ || ! gh_symbol_p (index_cell (me->get_grob_property ("attachment"), LEFT))
+ || ! gh_symbol_p (index_cell (me->get_grob_property ("attachment"), RIGHT)))
+ set_extremities (me);
+
+ if (!gh_pair_p (me->get_grob_property ("control-points")))
+ set_control_points (me);
+
+ // set_control_points may suicide
+ if (!scm_ilength (me->get_grob_property ("note-columns")))
+ return b;
+
+ for (SCM s= me->get_grob_property ("control-points"); s != SCM_EOL; s = gh_cdr (s))
+ {
+ b.control_[i] = ly_scm2offset (gh_car (s));
+ i++;
+ }
+
+ Array<Offset> enc (get_encompass_offset_arr (me));
+ Direction dir = Directional_element_interface::get (me);
+
+ Real x1 = enc[0][X_AXIS];
+ Real x2 = enc.top ()[X_AXIS];
+
+ Real off = 0.0;
+ for (int i=1; i < enc.size ()-1; i++)
+ {
+ Real x = enc[i][X_AXIS];
+ if (x > x1 && x <x2)
+ {
+ Real y = b.get_other_coordinate (X_AXIS, x);
+ off = off >? dir * (enc[i][Y_AXIS] - y);
+ }
+ }
+ b.translate (Offset (0, dir * off));
+ return b;
+}
+
+
+bool
+Slur::has_interface (Grob*me)
+{
+ return me->has_interface (ly_symbol2scm ("slur-interface"));