- if (isinf (desc.hooke_f_))
- {
- desc.active_b_ = false;
- springs_.push (desc);
- }
- else
- {
- desc.block_force_f_ = - desc.hooke_f_ * desc.ideal_f_; // block at distance 0
- springs_.push (desc);
-
- active_count_ ++;
- }
+/****************************************************************/
+
+/*
+ TODO: should a add penalty for widely varying spring forces (caused
+ by constraints, eg.
+
+
+ . =====
+ . | |
+ .o|o|x ##x
+ .
+
+ The ## forces the notes apart; we shouldn't allow the O's to touch
+ this closely.
+*/
+
+struct Rod_description
+{
+ vsize r_;
+ Real dist_;
+
+ bool operator< (const Rod_description r)
+ {
+ return r_ < r.r_;
+ }
+
+ Rod_description ()
+ {
+ r_ = 0;
+ dist_ = 0;
+ }
+
+ Rod_description (vsize r, Real d)
+ {
+ r_ = r;
+ dist_ = d;
+ }
+};
+
+struct Column_description
+{
+ vector<Rod_description> rods_;
+ vector<Rod_description> end_rods_; /* use these if they end at the last column of the line */
+ Real ideal_;
+ Real inverse_hooke_;
+ Real end_ideal_;
+ Real end_inverse_hooke_;
+ SCM break_permission_;
+ Interval keep_inside_line_;
+
+ Column_description ()
+ {
+ ideal_ = 0;
+ inverse_hooke_ = 0;
+ end_ideal_ = 0;
+ end_inverse_hooke_ = 0;
+ break_permission_ = SCM_EOL;
+ }
+};
+
+static bool
+is_loose (Grob *g)
+{
+ return (scm_is_pair (g->get_object ("between-cols")));
+}
+
+static Grob*
+maybe_find_prebroken_piece (Grob *g, Direction d)
+{
+ Grob *ret = dynamic_cast<Item*> (g)->find_prebroken_piece (d);
+ if (ret)
+ return ret;
+ return g;
+}
+
+static Grob*
+next_spaceable_column (vector<Grob*> const &list, vsize starting)
+{
+ for (vsize i = starting+1; i < list.size (); i++)
+ if (!is_loose (list[i]))
+ return list[i];
+ return 0;
+}