$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r77926 - in sandbox/gtl: boost/polygon libs/polygon/benchmark libs/polygon/example libs/polygon/test
From: sydorchuk.andriy_at_[hidden]
Date: 2012-04-11 18:20:38
Author: asydorchuk
Date: 2012-04-11 18:20:37 EDT (Wed, 11 Apr 2012)
New Revision: 77926
URL: http://svn.boost.org/trac/boost/changeset/77926
Log:
Integrating library interfaces with Boost.Polygon concepts.
Text files modified: 
   sandbox/gtl/boost/polygon/voronoi.hpp                           |    20 ++++++++------------                    
   sandbox/gtl/boost/polygon/voronoi_builder.hpp                   |    22 +++++++++++++---------                  
   sandbox/gtl/libs/polygon/benchmark/voronoi_benchmark_points.cpp |     6 ++----                                  
   sandbox/gtl/libs/polygon/example/voronoi_advanced_tutorial.cpp  |     2 +-                                      
   sandbox/gtl/libs/polygon/example/voronoi_basic_tutorial.cpp     |     4 ++--                                    
   sandbox/gtl/libs/polygon/example/voronoi_visualizer.cpp         |     4 ++--                                    
   sandbox/gtl/libs/polygon/test/voronoi_benchmark_test.cpp        |     4 ++--                                    
   sandbox/gtl/libs/polygon/test/voronoi_builder_test.cpp          |    22 +++++++++++-----------                  
   8 files changed, 41 insertions(+), 43 deletions(-)
Modified: sandbox/gtl/boost/polygon/voronoi.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/voronoi.hpp	(original)
+++ sandbox/gtl/boost/polygon/voronoi.hpp	2012-04-11 18:20:37 EDT (Wed, 11 Apr 2012)
@@ -29,31 +29,27 @@
 namespace polygon {
 
 template <typename PC, typename VD>
-static inline void construct_voronoi_points(
-    const PC &points, VD *output) {
+static inline void construct_voronoi(const PC &points, VD *output,
+    typename enable_if<typename gtl_if<typename is_point_concept<typename geometry_concept<typename std::iterator_traits<typename PC::iterator>::value_type>::type>::type>::type>::type * = 0) {
   default_voronoi_builder builder;
-  builder.insert_points(points.begin(), points.end());
+  builder.insert(points.begin(), points.end());
   builder.construct(output);
-  builder.clear();
 }
 
 template <typename SC, typename VD>
-static inline void construct_voronoi_segments(
-    const SC &segments, VD *output) {
+static inline void construct_voronoi_segments(const SC &segments, VD *output) {
   default_voronoi_builder builder;
   builder.insert_segments(segments.begin(), segments.end());
   builder.construct(output);
-  builder.clear();
 }
 
 template <typename PC, typename SC, typename VD>
-static inline void construct_voronoi(
-    const PC &points, const SC &segments, VD *output) {
+static inline void construct_voronoi(const PC &points, const SC &segments, VD *output,
+    typename enable_if<typename gtl_if<typename is_point_concept<typename geometry_concept<typename std::iterator_traits<typename PC::iterator>::value_type>::type>::type>::type>::type * = 0) {
   default_voronoi_builder builder;
-  builder.insert_sites(points.begin(), points.end(),
-                       segments.begin(), segments.end());
+  builder.insert_sites(
+    points.begin(), points.end(), segments.begin(), segments.end());
   builder.construct(output);
-  builder.clear();
 }
 }  // polygon
 }  // boost
Modified: sandbox/gtl/boost/polygon/voronoi_builder.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/voronoi_builder.hpp	(original)
+++ sandbox/gtl/boost/polygon/voronoi_builder.hpp	2012-04-11 18:20:37 EDT (Wed, 11 Apr 2012)
@@ -14,6 +14,8 @@
 #include <map>
 #include <vector>
 
+#include "isotropy.hpp"
+#include "point_concept.hpp"
 #include "detail/voronoi_ctypes.hpp"
 #include "detail/voronoi_predicates.hpp"
 #include "detail/voronoi_structures.hpp"
@@ -47,20 +49,22 @@
 
   voronoi_builder() {}
 
-  void insert_point(const int_type& x, const int_type& y) {
+  void insert(const int_type& x, const int_type& y) {
     site_events_.push_back(site_event_type(x, y));
   }
 
   template <typename PointType>
-  void insert_point(const PointType& point) {
-    insert_point(point.x(), point.y());
+  void insert(const PointType& point,
+  typename enable_if<typename gtl_if<typename is_point_concept<typename geometry_concept<PointType>::type>::type>::type>::type * = 0) {
+    insert(x(point), y(point));
   }
 
   template <typename PointIterator>
-  void insert_points(PointIterator first_point, PointIterator last_point) {
+  void insert(PointIterator first_point, PointIterator last_point,
+  typename enable_if<typename gtl_if<typename is_point_concept<typename geometry_concept<typename std::iterator_traits<PointIterator>::value_type>::type>::type>::type>::type * = 0) {
     // Create a site event from each input point.
     for (PointIterator it = first_point; it != last_point; ++it) {
-      insert_point(*it);
+      insert(*it);
     }
   }
 
@@ -68,8 +72,8 @@
   //   1) the start point of the segment;
   //   2) the end point of the segment;
   //   3) the segment itself defined by its start point.
-  void insert_segment(const int_type& x1, const int_type& y1,
-                      const int_type& x2, const int_type& y2) {
+  void insert(const int_type& x1, const int_type& y1,
+              const int_type& x2, const int_type& y2) {
     point_type p1(x1, y1);
     point_type p2(x2, y2);
     site_events_.push_back(site_event_type(p1));
@@ -83,7 +87,7 @@
 
   template <typename PointType>
   void insert_segment(const PointType& point1, const PointType& point2) {
-    insert_segment(point1.x(), point1.y(), point2.x(), point2.y());  
+    insert(point1.x(), point1.y(), point2.x(), point2.y());  
   }
 
   template <typename SegmentType>
@@ -103,7 +107,7 @@
   void insert_sites(
       PointIterator first_point, PointIterator last_point,
       SegmentIterator first_segment, SegmentIterator last_segment) {
-    insert_points(first_point, last_point);
+    insert(first_point, last_point);
     insert_segments(first_segment, last_segment);
   }
 
Modified: sandbox/gtl/libs/polygon/benchmark/voronoi_benchmark_points.cpp
==============================================================================
--- sandbox/gtl/libs/polygon/benchmark/voronoi_benchmark_points.cpp	(original)
+++ sandbox/gtl/libs/polygon/benchmark/voronoi_benchmark_points.cpp	2012-04-11 18:20:37 EDT (Wed, 11 Apr 2012)
@@ -59,10 +59,8 @@
     for (int j = 0; j < NUM_RUNS[i]; ++j) {
       VB_BOOST vb;
       VD_BOOST vd;
-      for (int k = 0; k < NUM_POINTS[i]; ++k) {
-        vb.insert_point(static_cast<int32>(gen()),
-                        static_cast<int32>(gen()));
-      }
+      for (int k = 0; k < NUM_POINTS[i]; ++k)
+        vb.insert(static_cast<int32>(gen()), static_cast<int32>(gen()));
       vb.construct(&vd);
     }
     double time_per_test = timer.elapsed() / NUM_RUNS[i];
Modified: sandbox/gtl/libs/polygon/example/voronoi_advanced_tutorial.cpp
==============================================================================
--- sandbox/gtl/libs/polygon/example/voronoi_advanced_tutorial.cpp	(original)
+++ sandbox/gtl/libs/polygon/example/voronoi_advanced_tutorial.cpp	2012-04-11 18:20:37 EDT (Wed, 11 Apr 2012)
@@ -129,7 +129,7 @@
   for (size_t i = 0; i < GENERATED_POINTS; ++i) {
     boost::int64_t x = distr(gen);
     boost::int64_t y = distr(gen);
-    vb.insert_point(x, y);
+    vb.insert(x, y);
   }
 
   printf("Constructing Voronoi diagram of %d points...\n", GENERATED_POINTS);
Modified: sandbox/gtl/libs/polygon/example/voronoi_basic_tutorial.cpp
==============================================================================
--- sandbox/gtl/libs/polygon/example/voronoi_basic_tutorial.cpp	(original)
+++ sandbox/gtl/libs/polygon/example/voronoi_basic_tutorial.cpp	2012-04-11 18:20:37 EDT (Wed, 11 Apr 2012)
@@ -118,9 +118,9 @@
   voronoi_builder<int> vb;
   voronoi_diagram<double> vd;
   for (std::vector<Point>::iterator it = points.begin(); it != points.end(); ++it)
-    vb.insert_point(it->a, it->b);
+    vb.insert(it->a, it->b);
   for (std::vector<Segment>::iterator it = segments.begin(); it != segments.end(); ++it)
-    vb.insert_segment(it->p0.a, it->p0.b, it->p1.a, it->p1.b);
+    vb.insert(it->p0.a, it->p0.b, it->p1.a, it->p1.b);
   vb.construct(&vd);
 
   // Traversing Voronoi Graph.
Modified: sandbox/gtl/libs/polygon/example/voronoi_visualizer.cpp
==============================================================================
--- sandbox/gtl/libs/polygon/example/voronoi_visualizer.cpp	(original)
+++ sandbox/gtl/libs/polygon/example/voronoi_visualizer.cpp	2012-04-11 18:20:37 EDT (Wed, 11 Apr 2012)
@@ -50,13 +50,13 @@
     in_stream >> num_point_sites;
     for (int i = 0; i < num_point_sites; ++i) {
       in_stream >> x1 >> y1;
-      vb_.insert_point(x1, y1);
+      vb_.insert(x1, y1);
       brect_.update(x1, y1);
     }
     in_stream >> num_edge_sites;
     for (int i = 0; i < num_edge_sites; ++i) {
       in_stream >> x1 >> y1 >> x2 >> y2;
-      vb_.insert_segment(x1, y1, x2, y2);
+      vb_.insert(x1, y1, x2, y2);
       brect_.update(x1, y1);
       brect_.update(x2, y2);
     }
Modified: sandbox/gtl/libs/polygon/test/voronoi_benchmark_test.cpp
==============================================================================
--- sandbox/gtl/libs/polygon/test/voronoi_benchmark_test.cpp	(original)
+++ sandbox/gtl/libs/polygon/test/voronoi_benchmark_test.cpp	2012-04-11 18:20:37 EDT (Wed, 11 Apr 2012)
@@ -62,7 +62,7 @@
                 y = static_cast<coordinate_type>(gen());
                 points[cur_point] = point_type(x, y);
             }
-            construct_voronoi_points(points, &test_output);
+            construct_voronoi(points, &test_output);
         }
         double elapsed_time = timer.elapsed();
         double time_per_test = elapsed_time / num_tests;
@@ -99,7 +99,7 @@
         for (int i = 0; i < POINT_RUNS; ++i) {
             voronoi_diagram<double> test_output;
             timer.restart();
-            construct_voronoi_points(points, &test_output);
+            construct_voronoi(points, &test_output);
             periods.push_back(timer.elapsed());
         }
     }
Modified: sandbox/gtl/libs/polygon/test/voronoi_builder_test.cpp
==============================================================================
--- sandbox/gtl/libs/polygon/test/voronoi_builder_test.cpp	(original)
+++ sandbox/gtl/libs/polygon/test/voronoi_builder_test.cpp	2012-04-11 18:20:37 EDT (Wed, 11 Apr 2012)
@@ -54,7 +54,7 @@
     std::vector< point_data<T> > points;
     points.push_back(point_data<T>(0, 0));
     vd_type test_output;
-    construct_voronoi_points(points, &test_output);
+    construct_voronoi(points, &test_output);
     VERIFY_OUTPUT(test_output);
 
     BOOST_CHECK(test_output.cells().size() == 1);
@@ -70,7 +70,7 @@
     points.push_back(point_data<T>(0, 0));
     points.push_back(point_data<T>(0, 1));
     vd_type test_output;
-    construct_voronoi_points(points, &test_output);
+    construct_voronoi(points, &test_output);
     VERIFY_OUTPUT(test_output);
     CHECK_OUTPUT_SIZE(test_output, 2, 0, 1);
 
@@ -101,7 +101,7 @@
     points.push_back(point_data<T>(1, 1));
     points.push_back(point_data<T>(2, 2));
     vd_type test_output;
-    construct_voronoi_points(points, &test_output);
+    construct_voronoi(points, &test_output);
     VERIFY_OUTPUT(test_output);
     CHECK_OUTPUT_SIZE(test_output, 3, 0, 2);
 
@@ -137,7 +137,7 @@
     points.push_back(point2);
     points.push_back(point3);
     vd_type test_output;
-    construct_voronoi_points(points, &test_output);
+    construct_voronoi(points, &test_output);
     VERIFY_OUTPUT(test_output);
     CHECK_OUTPUT_SIZE(test_output, 3, 1, 3);
 
@@ -187,7 +187,7 @@
     points.push_back(point2);
     points.push_back(point3);
     vd_type test_output;
-    construct_voronoi_points(points, &test_output);
+    construct_voronoi(points, &test_output);
     VERIFY_OUTPUT(test_output);
     CHECK_OUTPUT_SIZE(test_output, 3, 1, 3);
 
@@ -239,7 +239,7 @@
     points.push_back(point3);
     points.push_back(point4);
     vd_type test_output;
-    construct_voronoi_points(points, &test_output);
+    construct_voronoi(points, &test_output);
     VERIFY_OUTPUT(test_output);
     CHECK_OUTPUT_SIZE(test_output, 4, 1, 4);
 
@@ -308,8 +308,8 @@
                 point_vec_small.push_back(point_data<T>(i, j));
                 point_vec_large.push_back(point_data<T>(koef * i, koef * j));
             }
-        construct_voronoi_points(point_vec_small, &test_output_small);
-        construct_voronoi_points(point_vec_large, &test_output_large);
+        construct_voronoi(point_vec_small, &test_output_small);
+        construct_voronoi(point_vec_large, &test_output_large);
         VERIFY_OUTPUT(test_output_small);
         VERIFY_OUTPUT(test_output_large);
         unsigned int num_cells = grid_size[k] * grid_size[k];
@@ -344,8 +344,8 @@
                 point_vec_small.push_back(point_data<T>(x, y));
                 point_vec_large.push_back(point_data<T>(koef * x, koef * y));
             }
-            construct_voronoi_points(point_vec_small, &test_output_small);
-            construct_voronoi_points(point_vec_large, &test_output_large);
+            construct_voronoi(point_vec_small, &test_output_small);
+            construct_voronoi(point_vec_large, &test_output_large);
             VERIFY_OUTPUT(test_output_small);
             VERIFY_OUTPUT(test_output_large);
             BOOST_CHECK_EQUAL(test_output_small.num_cells(),
@@ -366,7 +366,7 @@
     std::vector< point_data<T> > point_vec;
     for (int i = 0; i < 1000000; i++)
         point_vec.push_back(point_data<T>(gen() % 10000 - 5000, gen() % 10000 - 5000));
-    construct_voronoi_points(point_vec, &test_output);
+    construct_voronoi(point_vec, &test_output);
     BOOST_CHECK_EQUAL(voronoi_test_helper::verify_output(test_output,
         voronoi_test_helper::FAST_VERIFICATION), true);
 }