Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63590 - in sandbox/geometry/boost/geometry: algorithms/detail/overlay extensions/algorithms extensions/algorithms/buffer strategies strategies/spherical util
From: barend.gehrels_at_[hidden]
Date: 2010-07-04 08:19:58


Author: barendgehrels
Date: 2010-07-04 08:19:55 EDT (Sun, 04 Jul 2010)
New Revision: 63590
URL: http://svn.boost.org/trac/boost/changeset/63590

Log:
Solved abs/std::abs issues
Text files modified:
   sandbox/geometry/boost/geometry/algorithms/detail/overlay/assemble.hpp | 3 ++-
   sandbox/geometry/boost/geometry/algorithms/detail/overlay/ring_properties.hpp | 4 ++--
   sandbox/geometry/boost/geometry/algorithms/detail/overlay/split_rings.hpp | 2 +-
   sandbox/geometry/boost/geometry/extensions/algorithms/buffer/line_line_intersection.hpp | 4 ++--
   sandbox/geometry/boost/geometry/extensions/algorithms/buffer/segmenting_buffer.hpp | 8 ++++----
   sandbox/geometry/boost/geometry/extensions/algorithms/remove_holes_if.hpp | 2 +-
   sandbox/geometry/boost/geometry/extensions/algorithms/remove_spikes.hpp | 4 ++--
   sandbox/geometry/boost/geometry/extensions/algorithms/selected.hpp | 2 +-
   sandbox/geometry/boost/geometry/strategies/buffer.hpp | 14 +++++++-------
   sandbox/geometry/boost/geometry/strategies/buffer_join_round.hpp | 2 +-
   sandbox/geometry/boost/geometry/strategies/spherical/area_huiller.hpp | 4 ++--
   sandbox/geometry/boost/geometry/strategies/spherical/compare_circular.hpp | 2 +-
   sandbox/geometry/boost/geometry/strategies/spherical/distance_cross_track.hpp | 7 ++-----
   sandbox/geometry/boost/geometry/strategies/spherical/side_by_cross_track.hpp | 2 +-
   sandbox/geometry/boost/geometry/strategies/strategy_transform.hpp | 5 ++---
   sandbox/geometry/boost/geometry/util/math.hpp | 12 ++++++++++++
   16 files changed, 43 insertions(+), 34 deletions(-)

Modified: sandbox/geometry/boost/geometry/algorithms/detail/overlay/assemble.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/overlay/assemble.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/overlay/assemble.hpp 2010-07-04 08:19:55 EDT (Sun, 04 Jul 2010)
@@ -448,7 +448,8 @@
             {
                 item_type& item2 = *it2;
                 if (geometry::within(item2.point, item1.box)
- && std::abs(item2.area) < std::abs(item1.area)
+ && geometry::math::abs(item2.area)
+ < geometry::math::abs(item1.area)
                     && contains(item1, item2, geometry1, geometry2, collection)
                     )
                 {

Modified: sandbox/geometry/boost/geometry/algorithms/detail/overlay/ring_properties.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/overlay/ring_properties.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/overlay/ring_properties.hpp 2010-07-04 08:19:55 EDT (Sun, 04 Jul 2010)
@@ -80,7 +80,7 @@
     inline bool operator<(ring_properties<Point> const& other) const
     {
         // Normal sorting: in reverse order
- return std::abs(area) > std::abs(other.area);
+ return geometry::math::abs(area) > geometry::math::abs(other.area);
     }
 
     inline ring_identifier const& id() const
@@ -218,7 +218,7 @@
 
         // If it is the same, sort on size descending
         return left_id == right_id
- ? std::abs(left.area) > std::abs(right.area)
+ ? geometry::math::abs(left.area) > geometry::math::abs(right.area)
             : left_id < right_id;
     }
 };

Modified: sandbox/geometry/boost/geometry/algorithms/detail/overlay/split_rings.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/overlay/split_rings.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/overlay/split_rings.hpp 2010-07-04 08:19:55 EDT (Sun, 04 Jul 2010)
@@ -92,7 +92,7 @@
             first += mn;
 
             typename boost::range_iterator<Range>::type last = first;
- last += std::abs(id2.segment_index - id1.segment_index);
+ last += geometry::math::abs(id2.segment_index - id1.segment_index);
 
             // Create splitted ring
             output.push_back(point);

Modified: sandbox/geometry/boost/geometry/extensions/algorithms/buffer/line_line_intersection.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/extensions/algorithms/buffer/line_line_intersection.hpp (original)
+++ sandbox/geometry/boost/geometry/extensions/algorithms/buffer/line_line_intersection.hpp 2010-07-04 08:19:55 EDT (Sun, 04 Jul 2010)
@@ -61,12 +61,12 @@
         set<1>(p, py);
 
 #ifdef BOOST_GEOMETRY_DEBUG_BUFFER
- if (std::abs(denominator) < 1.0e-7)
+ if (geometry::math::abs(denominator) < 1.0e-7)
         {
             std::cout << "small " << denominator << std::endl;
         }
 #endif
- return std::abs(denominator) > 1.0e-7;
+ return geometry::math::abs(denominator) > 1.0e-7;
     }
 };
 

Modified: sandbox/geometry/boost/geometry/extensions/algorithms/buffer/segmenting_buffer.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/extensions/algorithms/buffer/segmenting_buffer.hpp (original)
+++ sandbox/geometry/boost/geometry/extensions/algorithms/buffer/segmenting_buffer.hpp 2010-07-04 08:19:55 EDT (Sun, 04 Jul 2010)
@@ -106,17 +106,17 @@
         coordinate_type ext_y = get<1>(head) - get<1>(tail);
         distance_type segment_length = sqrt(ext_x * ext_x + ext_y * ext_y);
 
- if (buffered_length < std::abs(distance_left))
+ if (buffered_length < geometry::math::abs(distance_left))
         {
             distance_left = buffered_length * distance_left < 0 ? -1.0 : 1.0;
         }
- if (buffered_length < std::abs(distance_right))
+ if (buffered_length < geometry::math::abs(distance_right))
         {
             distance_right = buffered_length * distance_right < 0 ? -1.0 : 1.0;
         }
 
- distance_type prop_left = std::abs(distance_left) / segment_length;
- distance_type prop_right = std::abs(distance_right) / segment_length;
+ distance_type prop_left = geometry::math::abs(distance_left) / segment_length;
+ distance_type prop_right = geometry::math::abs(distance_right) / segment_length;
 
         set<0>(tail_left, get<0>(tail) - ext_x * prop_left);
         set<1>(tail_left, get<1>(tail) - ext_y * prop_left);

Modified: sandbox/geometry/boost/geometry/extensions/algorithms/remove_holes_if.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/extensions/algorithms/remove_holes_if.hpp (original)
+++ sandbox/geometry/boost/geometry/extensions/algorithms/remove_holes_if.hpp 2010-07-04 08:19:55 EDT (Sun, 04 Jul 2010)
@@ -124,7 +124,7 @@
         {
             double a = area(ring);
             double p = perimeter(ring);
- return std::abs(a/p) < m_ratio;
+ return geometry::math::abs(a / p) < m_ratio;
         }
         // Rings with less then 4 points (including closing)
         // are also considered as small and thus removed

Modified: sandbox/geometry/boost/geometry/extensions/algorithms/remove_spikes.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/extensions/algorithms/remove_spikes.hpp (original)
+++ sandbox/geometry/boost/geometry/extensions/algorithms/remove_spikes.hpp 2010-07-04 08:19:55 EDT (Sun, 04 Jul 2010)
@@ -353,8 +353,8 @@
             dy2 /= magnitude2;
 
             // If the directions are opposite, it can be removed
- if (std::abs(dx1 + dx2) < m_limit
- && std::abs(dy1 + dy2) < m_limit)
+ if (geometry::math::abs(dx1 + dx2) < m_limit
+ && geometry::math::abs(dy1 + dy2) < m_limit)
             {
                 return true;
             }

Modified: sandbox/geometry/boost/geometry/extensions/algorithms/selected.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/extensions/algorithms/selected.hpp (original)
+++ sandbox/geometry/boost/geometry/extensions/algorithms/selected.hpp 2010-07-04 08:19:55 EDT (Sun, 04 Jul 2010)
@@ -61,7 +61,7 @@
         coordinate_type const c1 = boost::numeric_cast<coordinate_type>(get<D>(p1));
         coordinate_type const c2 = boost::numeric_cast<coordinate_type>(get<D>(p2));
 
- T const d = std::abs(c1 - c2);
+ T const d = geometry::math::abs(c1 - c2);
         if (d > distance)
         {
             return false;

Modified: sandbox/geometry/boost/geometry/strategies/buffer.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/buffer.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/buffer.hpp 2010-07-04 08:19:55 EDT (Sun, 04 Jul 2010)
@@ -121,9 +121,9 @@
     {
         coordinate_type zero = 0;
         int signum = buffer_distance > zero
- ? 1
- : buffer_distance < zero
- ? -1
+ ? 1
+ : buffer_distance < zero
+ ? -1
                 : 0;
 
         if (side::apply(perp1, ip, perp2) == signum)
@@ -157,7 +157,7 @@
             coordinate_type ten = 10.0;
             coordinate_type zero_seven = 0.7;
 
- coordinate_type max = ten * std::abs(buffer_distance);
+ coordinate_type max = ten * geometry::math::abs(buffer_distance);
 
             if (length > max)
             {
@@ -297,8 +297,8 @@
         coordinate_type zero = 0;
         int signum = buffer_distance > zero
             ? 1
- : buffer_distance < zero
- ? -1
+ : buffer_distance < zero
+ ? -1
                 : 0;
 
         if (side::apply(perp1, ip, perp2) == signum)
@@ -320,7 +320,7 @@
             coordinate_type length_i = sqrt(vix * vix + viy * viy);
 
 
- coordinate_type const bd = std::abs(buffer_distance);
+ coordinate_type const bd = geometry::math::abs(buffer_distance);
             coordinate_type prop = bd / length_i;
 
             PointIn bp;

Modified: sandbox/geometry/boost/geometry/strategies/buffer_join_round.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/buffer_join_round.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/buffer_join_round.hpp 2010-07-04 08:19:55 EDT (Sun, 04 Jul 2010)
@@ -78,7 +78,7 @@
 
         coordinate_type between_length = sqrt(v_x * v_x + v_y * v_y);
 
- coordinate_type const positive_buffer_distance = std::abs(buffer_distance);
+ coordinate_type const positive_buffer_distance = geometry::math::abs(buffer_distance);
         coordinate_type prop = positive_buffer_distance / between_length;
 
         PointOut mid_point;

Modified: sandbox/geometry/boost/geometry/strategies/spherical/area_huiller.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/spherical/area_huiller.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/spherical/area_huiller.hpp 2010-07-04 08:19:55 EDT (Sun, 04 Jul 2010)
@@ -94,12 +94,12 @@
 
             // E: spherical excess, using l'Huiller's formula
             // [tg(e / 4)]2 = tg[s / 2] tg[(s-a) / 2] tg[(s-b) / 2] tg[(s-c) / 2]
- double E = 4.0 * atan(sqrt(std::abs(tan(s / 2)
+ double E = 4.0 * atan(sqrt(geometry::math::abs(tan(s / 2)
                     * tan((s - a) / 2)
                     * tan((s - b) / 2)
                     * tan((s - c) / 2))));
 
- E = std::abs(E);
+ E = geometry::math::abs(E);
 
             // In right direction: positive, add area. In left direction: negative, subtract area.
             // Longitude comparisons are not so obvious. If one is negative, other is positive,

Modified: sandbox/geometry/boost/geometry/strategies/spherical/compare_circular.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/spherical/compare_circular.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/spherical/compare_circular.hpp 2010-07-04 08:19:55 EDT (Sun, 04 Jul 2010)
@@ -91,7 +91,7 @@
         // Two coordinates on a circle are
         // at max <= half a circle away from each other.
         // So if it is more, shift origin.
- CoordinateType diff = std::abs(v1 - v2);
+ CoordinateType diff = geometry::math::abs(v1 - v2);
         if (diff > half)
         {
             v1 = put_in_range(v1, 0, full);

Modified: sandbox/geometry/boost/geometry/strategies/spherical/distance_cross_track.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/spherical/distance_cross_track.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/spherical/distance_cross_track.hpp 2010-07-04 08:19:55 EDT (Sun, 04 Jul 2010)
@@ -22,9 +22,8 @@
 
 #include <boost/geometry/util/promote_floating_point.hpp>
 #include <boost/geometry/util/math.hpp>
-//#include <boost/geometry/util/write_dsv.hpp>
-
 
+//#include <boost/geometry/util/write_dsv.hpp>
 
 
 namespace boost { namespace geometry
@@ -87,8 +86,6 @@
     inline return_type apply(Point const& p,
                 PointOfSegment const& sp1, PointOfSegment const& sp2) const
     {
- using std::abs; // to support ADL, and forces std::abs
-
         // http://williams.best.vwh.net/avform.htm#XTE
         return_type d1 = m_strategy.apply(sp1, p);
 
@@ -97,7 +94,7 @@
 
         return_type crs_AD = course(sp1, p);
         return_type crs_AB = course(sp1, sp2);
- return_type XTD = abs(asin(sin(d1) * sin(crs_AD - crs_AB)));
+ return_type XTD = geometry::math::abs(asin(sin(d1) * sin(crs_AD - crs_AB)));
 
 //std::cout << "Course " << dsv(sp1) << " to " << dsv(p) << " " << crs_AD * geometry::math::r2d << std::endl;
 //std::cout << "Course " << dsv(sp1) << " to " << dsv(sp2) << " " << crs_AB * geometry::math::r2d << std::endl;

Modified: sandbox/geometry/boost/geometry/strategies/spherical/side_by_cross_track.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/spherical/side_by_cross_track.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/spherical/side_by_cross_track.hpp 2010-07-04 08:19:55 EDT (Sun, 04 Jul 2010)
@@ -79,7 +79,7 @@
         double d1 = 0.001; // m_strategy.apply(sp1, p);
         double crs_AD = course(p1, p);
         double crs_AB = course(p1, p2);
- double XTD = std::abs(asin(sin(d1) * sin(crs_AD - crs_AB)));
+ double XTD = geometry::math::abs(asin(sin(d1) * sin(crs_AD - crs_AB)));
 
         return math::equals(XTD, 0) ? 0 : XTD > 0 ? 1 : -1;
         //return s > 0 ? 1 : s < 0 ? -1 : 0;

Modified: sandbox/geometry/boost/geometry/strategies/strategy_transform.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/strategy_transform.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/strategy_transform.hpp 2010-07-04 08:19:55 EDT (Sun, 04 Jul 2010)
@@ -171,9 +171,8 @@
         // TODO: MAYBE ONLY IF TO BE CHECKED?
         double const r = std::sqrt(x * x + y * y + z * z);
 
- // Unit sphere, r should be 1
- typedef typename coordinate_type<P>::type coordinate_type;
- if (std::abs(r - 1.0) > std::numeric_limits<coordinate_type>::epsilon())
+ // Unit sphere, so r should be 1
+ if (! geometry::math::equals(r, 1))
         {
             return false;
         }

Modified: sandbox/geometry/boost/geometry/util/math.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/util/math.hpp (original)
+++ sandbox/geometry/boost/geometry/util/math.hpp 2010-07-04 08:19:55 EDT (Sun, 04 Jul 2010)
@@ -125,6 +125,18 @@
     return value * value;
 }
 
+
+/*!
+\brief Short utility to workaround gcc/clang problem that abs is converting to integer
+\ingroup utility
+*/
+template<typename T>
+inline T abs(const T& t)
+{
+ using std::abs;
+ return abs(t);
+}
+
 } // namespace math
 
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk