Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76399 - in sandbox/gtl/boost/polygon: . detail
From: sydorchuk.andriy_at_[hidden]
Date: 2012-01-10 18:01:03


Author: asydorchuk
Date: 2012-01-10 18:01:02 EST (Tue, 10 Jan 2012)
New Revision: 76399
URL: http://svn.boost.org/trac/boost/changeset/76399

Log:
Preparing code before coordinate traits refactoring.
Performance boost 15% while switching default coordinate type to integer instead of double.
Text files modified:
   sandbox/gtl/boost/polygon/detail/voronoi_calc_utils.hpp | 17 +++++++++--------
   sandbox/gtl/boost/polygon/detail/voronoi_robust_fpt.hpp | 10 ----------
   sandbox/gtl/boost/polygon/voronoi_builder.hpp | 33 ++++++++++++++-------------------
   3 files changed, 23 insertions(+), 37 deletions(-)

Modified: sandbox/gtl/boost/polygon/detail/voronoi_calc_utils.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/detail/voronoi_calc_utils.hpp (original)
+++ sandbox/gtl/boost/polygon/detail/voronoi_calc_utils.hpp 2012-01-10 18:01:02 EST (Tue, 10 Jan 2012)
@@ -24,6 +24,7 @@
 template <>
 class voronoi_calc_utils<int32> {
 public:
+ typedef int32 int_type;
     typedef fpt64 fpt_type;
 
     static const uint32 ULPS;
@@ -91,14 +92,14 @@
     static kOrientation get_orientation(const Point &point1,
                                         const Point &point2,
                                         const Point &point3) {
- fpt_type dx1 = static_cast<fpt_type>(point1.x()) -
- static_cast<fpt_type>(point2.x());
- fpt_type dx2 = static_cast<fpt_type>(point2.x()) -
- static_cast<fpt_type>(point3.x());
- fpt_type dy1 = static_cast<fpt_type>(point1.y()) -
- static_cast<fpt_type>(point2.y());
- fpt_type dy2 = static_cast<fpt_type>(point2.y()) -
- static_cast<fpt_type>(point3.y());
+ int64 dx1 = static_cast<int64>(point1.x()) -
+ static_cast<int64>(point2.x());
+ int64 dx2 = static_cast<int64>(point2.x()) -
+ static_cast<int64>(point3.x());
+ int64 dy1 = static_cast<int64>(point1.y()) -
+ static_cast<int64>(point2.y());
+ int64 dy2 = static_cast<int64>(point2.y()) -
+ static_cast<int64>(point3.y());
         return get_orientation(robust_cross_product(dx1, dy1, dx2, dy2));
     }
 

Modified: sandbox/gtl/boost/polygon/detail/voronoi_robust_fpt.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/detail/voronoi_robust_fpt.hpp (original)
+++ sandbox/gtl/boost/polygon/detail/voronoi_robust_fpt.hpp 2012-01-10 18:01:02 EST (Tue, 10 Jan 2012)
@@ -129,7 +129,6 @@
         static const relative_error_type ROUNDING_ERROR;
 
         robust_fpt() : fpv_(0.0), re_(0.0) {}
- explicit robust_fpt(int32 fpv) : fpv_(fpv), re_(0.0) {}
         explicit robust_fpt(floating_point_type fpv,
                             bool rounded = true) : fpv_(fpv) {
             re_ = rounded ? ROUNDING_ERROR : 0;
@@ -545,14 +544,6 @@
             return value_ == 0;
         }
 
- extended_exponent_fpt abs() const {
- if (value_ >= 0) {
- return *this;
- } else {
- return extended_exponent_fpt(-value_, exponent_);
- }
- }
-
         extended_exponent_fpt operator-() const {
             return extended_exponent_fpt(-value_, exponent_);
         }
@@ -1133,7 +1124,6 @@
         return !that.count();
     }
 
-
     template <typename typeA, typename typeB>
     struct type_converter {
         static typeB convert(const typeA& that) {

Modified: sandbox/gtl/boost/polygon/voronoi_builder.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/voronoi_builder.hpp (original)
+++ sandbox/gtl/boost/polygon/voronoi_builder.hpp 2012-01-10 18:01:02 EST (Tue, 10 Jan 2012)
@@ -11,11 +11,7 @@
 #define BOOST_POLYGON_VORONOI_BUILDER
 
 #include <algorithm>
-#include <cmath>
-#include <cstring>
-#include <list>
 #include <map>
-#include <queue>
 #include <vector>
 
 #include "polygon.hpp"
@@ -76,9 +72,7 @@
         void insert_points(PointIterator first_point, PointIterator last_point) {
             // Create a site event from each input point.
             for (PointIterator it = first_point; it != last_point; ++it) {
- site_events_.push_back(detail::site_event<coordinate_type>(
- static_cast<coordinate_type>(it->x()),
- static_cast<coordinate_type>(it->y())));
+ site_events_.push_back(site_event_type(it->x(), it->y()));
             }
         }
 
@@ -90,18 +84,18 @@
             // 3) the segment itself.
             point_comparison_predicate point_comparison;
             for (SegmentIterator it = first_segment; it != last_segment; ++it) {
- coordinate_type x1 = static_cast<coordinate_type>(it->low().x());
- coordinate_type y1 = static_cast<coordinate_type>(it->low().y());
- coordinate_type x2 = static_cast<coordinate_type>(it->high().x());
- coordinate_type y2 = static_cast<coordinate_type>(it->high().y());
+ int_type x1 = it->low().x();
+ int_type y1 = it->low().y();
+ int_type x2 = it->high().x();
+ int_type y2 = it->high().y();
                 point_type p1(x1, y1);
                 point_type p2(x2, y2);
- site_events_.push_back(detail::site_event<coordinate_type>(p1));
- site_events_.push_back(detail::site_event<coordinate_type>(p2));
+ site_events_.push_back(site_event_type(p1));
+ site_events_.push_back(site_event_type(p2));
                 if (point_comparison(p1, p2)) {
- site_events_.push_back(detail::site_event<coordinate_type>(p1, p2));
+ site_events_.push_back(site_event_type(p1, p2));
                 } else {
- site_events_.push_back(detail::site_event<coordinate_type>(p2, p1));
+ site_events_.push_back(site_event_type(p2, p1));
                 }
             }
         }
@@ -156,13 +150,14 @@
 
     private:
         typedef detail::voronoi_calc_utils<T> VCU;
- typedef typename VCU::fpt_type coordinate_type;
+ typedef typename VCU::int_type int_type;
+ typedef typename VCU::fpt_type fpt_type;
 
- typedef detail::point_2d<coordinate_type> point_type;
- typedef detail::site_event<coordinate_type> site_event_type;
+ typedef detail::point_2d<int_type> point_type;
+ typedef detail::site_event<int_type> site_event_type;
         typedef typename std::vector<site_event_type>::const_iterator
             site_event_iterator_type;
- typedef detail::circle_event<coordinate_type> circle_event_type;
+ typedef detail::circle_event<fpt_type> circle_event_type;
         typedef typename VCU::template point_comparison_predicate<point_type>
             point_comparison_predicate;
         typedef typename VCU::


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