]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/skyline.cc
Issue 4550 (2/2) Avoid "using namespace std;" in included files
[lilypond.git] / lily / skyline.cc
index ef284e7131265144809fb3b2134ef11dc26d8ac7..88e699a6eb760c2aa8a4a6032c98fba42d70c243 100644 (file)
 #include <deque>
 #include <cstdio>
 
+using std::deque;
+using std::list;
+using std::vector;
+
 /* A skyline is a sequence of non-overlapping buildings: something like
    this:
                    _______
@@ -65,8 +69,6 @@
    Alert to these considerations, we now accept buildings of zero-width.
 */
 
-ADD_SMOB_INIT (Skyline);
-
 static void
 print_buildings (list<Building> const &b)
 {
@@ -129,7 +131,7 @@ Building::precompute (Real start, Real start_height, Real end_height, Real end)
     // too steep to be stored in slope-intercept form, given round-off error
     {
       slope_ = 0.0;
-      y_intercept_ = max (start_height, end_height);
+      y_intercept_ = std::max (start_height, end_height);
     }
   else
     y_intercept_ = start_height - slope_ * start;
@@ -249,7 +251,7 @@ Skyline::internal_merge_skyline (list<Building> *sb, list<Building> *sc,
             }
           /* 'c' continues further, so move it into 'b' for the next pass. */
           b = c;
-          swap (sb, sc);
+          std::swap (sb, sc);
         }
       else /* b.end_ > c.end_ so finish with c */
         {
@@ -454,7 +456,7 @@ Skyline::Skyline (vector<Drul_array<Offset> > const &segments, Axis horizon_axis
       Offset left = seg[LEFT];
       Offset right = seg[RIGHT];
       if (left[horizon_axis] > right[horizon_axis])
-        swap (left, right);
+        std::swap (left, right);
 
       Real x1 = left[horizon_axis];
       Real x2 = right[horizon_axis];
@@ -669,10 +671,10 @@ Skyline::internal_distance (Skyline const &other, Real *touch_point) const
   Real touch = -infinity_f;
   while (i != buildings_.end () && j != other.buildings_.end ())
     {
-      Real end = min (i->end_, j->end_);
+      Real end = std::min (i->end_, j->end_);
       Real start_dist = i->height (start) + j->height (start);
       Real end_dist = i->height (end) + j->height (end);
-      dist = max (dist, max (start_dist, end_dist));
+      dist = std::max (dist, std::max (start_dist, end_dist));
 
       if (end_dist == dist)
         touch = end;
@@ -714,8 +716,8 @@ Skyline::max_height () const
   list<Building>::const_iterator i;
   for (i = buildings_.begin (); i != buildings_.end (); ++i)
     {
-      ret = max (ret, i->height (i->start_));
-      ret = max (ret, i->height (i->end_));
+      ret = std::max (ret, i->height (i->start_));
+      ret = std::max (ret, i->height (i->end_));
     }
 
   return sky_ * ret;
@@ -819,8 +821,8 @@ Skyline::get_touching_point (SCM skyline_scm, SCM other_skyline_scm, SCM horizon
       horizon_padding = scm_to_double (horizon_padding_scm);
     }
 
-  Skyline *skyline = Skyline::unsmob (skyline_scm);
-  Skyline *other_skyline = Skyline::unsmob (other_skyline_scm);
+  Skyline *skyline = unsmob<Skyline> (skyline_scm);
+  Skyline *other_skyline = unsmob<Skyline> (other_skyline_scm);
   return scm_from_double (skyline->touching_point (*other_skyline, horizon_padding));
 }
 
@@ -837,8 +839,8 @@ Skyline::get_distance (SCM skyline_scm, SCM other_skyline_scm, SCM horizon_paddi
       horizon_padding = scm_to_double (horizon_padding_scm);
     }
 
-  Skyline *skyline = Skyline::unsmob (skyline_scm);
-  Skyline *other_skyline = Skyline::unsmob (other_skyline_scm);
+  Skyline *skyline = unsmob<Skyline> (skyline_scm);
+  Skyline *other_skyline = unsmob<Skyline> (other_skyline_scm);
   return scm_from_double (skyline->distance (*other_skyline, horizon_padding));
 }
 
@@ -846,14 +848,14 @@ MAKE_SCHEME_CALLBACK (Skyline, get_max_height, 1)
 SCM
 Skyline::get_max_height (SCM skyline_scm)
 {
-  return scm_from_double (Skyline::unsmob (skyline_scm)->max_height ());
+  return scm_from_double (unsmob<Skyline> (skyline_scm)->max_height ());
 }
 
 MAKE_SCHEME_CALLBACK (Skyline, get_max_height_position, 1)
 SCM
 Skyline::get_max_height_position (SCM skyline_scm)
 {
-  return scm_from_double (Skyline::unsmob (skyline_scm)->max_height_position ());
+  return scm_from_double (unsmob<Skyline> (skyline_scm)->max_height_position ());
 }
 
 MAKE_SCHEME_CALLBACK (Skyline, get_height, 2)
@@ -861,14 +863,14 @@ SCM
 Skyline::get_height (SCM skyline_scm, SCM x_scm)
 {
   Real x = robust_scm2double (x_scm, 0.0);
-  return scm_from_double (Skyline::unsmob (skyline_scm)->height (x));
+  return scm_from_double (unsmob<Skyline> (skyline_scm)->height (x));
 }
 
 LY_DEFINE (ly_skyline_empty_p, "ly:skyline-empty?",
            1, 0, 0, (SCM sky),
            "Return whether @var{sky} is empty.")
 {
-  Skyline *s = Skyline::unsmob (sky);
+  Skyline *s = unsmob<Skyline> (sky);
   LY_ASSERT_SMOB (Skyline, sky, 1);
   return scm_from_bool (s->is_empty ());
 }