Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77319 - sandbox/gtl/boost/polygon
From: sydorchuk.andriy_at_[hidden]
Date: 2012-03-12 17:32:46


Author: asydorchuk
Date: 2012-03-12 17:32:45 EDT (Mon, 12 Mar 2012)
New Revision: 77319
URL: http://svn.boost.org/trac/boost/changeset/77319

Log:
Updating bouding_rectangle sturcture
Text files modified:
   sandbox/gtl/boost/polygon/voronoi_diagram.hpp | 48 +++------------------------------------
   sandbox/gtl/boost/polygon/voronoi_utils.hpp | 15 ++++++++++-
   2 files changed, 17 insertions(+), 46 deletions(-)

Modified: sandbox/gtl/boost/polygon/voronoi_diagram.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/voronoi_diagram.hpp (original)
+++ sandbox/gtl/boost/polygon/voronoi_diagram.hpp 2012-03-12 17:32:45 EDT (Mon, 12 Mar 2012)
@@ -10,7 +10,6 @@
 #ifndef BOOST_POLYGON_VORONOI_DIAGRAM
 #define BOOST_POLYGON_VORONOI_DIAGRAM
 
-#include <list>
 #include <vector>
 
 #include "detail/voronoi_ctypes.hpp"
@@ -38,13 +37,6 @@
       x_max_(x),
       y_max_(y) {}
 
- template <typename P>
- bounding_rectangle(const P &p) :
- x_min_(p.x()),
- y_min_(p.y()),
- x_max_(p.x()),
- y_max_(p.y()) {}
-
   bounding_rectangle(T x1, T y1, T x2, T y2) {
     x_min_ = (std::min)(x1, x2);
     y_min_ = (std::min)(y1, y2);
@@ -52,14 +44,6 @@
     y_max_ = (std::max)(y1, y2);
   }
 
- template <typename P>
- bounding_rectangle(const P &p1, const P &p2) {
- x_min_ = (std::min)(p1.x(), p2.x());
- y_min_ = (std::min)(p1.y(), p2.y());
- x_max_ = (std::max)(p1.x(), p2.x());
- y_max_ = (std::max)(p1.y(), p2.y());
- }
-
   void update(T x, T y) {
     x_min_ = (std::min)(x_min_, x);
     y_min_ = (std::min)(y_min_, y);
@@ -67,27 +51,11 @@
     y_max_ = (std::max)(y_max_, y);
   }
 
- // Extend the rectangle with a new point.
- template <typename P>
- void update(const P &p) {
- x_min_ = (std::min)(x_min_, p.x());
- y_min_ = (std::min)(y_min_, p.y());
- x_max_ = (std::max)(x_max_, p.x());
- y_max_ = (std::max)(y_max_, p.y());
- }
-
   bool contains(T x, T y) const {
     return x >= x_min_ && x <= x_max_ &&
            y >= y_min_ && y <= y_max_;
   }
 
- // Check whether a point is situated inside the bounding rectangle.
- template <typename P>
- bool contains(const P &p) const {
- return p.x() >= x_min_ && p.x() <= x_max_ &&
- p.y() >= y_min_ && p.y() <= y_max_;
- }
-
   // Return the x-coordinate of the bottom left point of the rectangle.
   coordinate_type x_min() const {
     return x_min_;
@@ -108,14 +76,6 @@
     return y_max_;
   }
 
- coordinate_type min_len() const {
- return (std::min)(x_max_ - x_min_, y_max_ - y_min_);
- }
-
- coordinate_type max_len() const {
- return (std::max)(x_max_ - x_min_, y_max_ - y_min_);
- }
-
 private:
   coordinate_type x_min_;
   coordinate_type y_min_;
@@ -189,8 +149,7 @@
   typedef detail::point_2d<T> point_type;
   typedef voronoi_edge<coordinate_type> voronoi_edge_type;
 
- voronoi_vertex(const point_type &vertex,
- voronoi_edge_type *edge) :
+ voronoi_vertex(const point_type &vertex, voronoi_edge_type *edge) :
       vertex_(vertex),
       incident_edge_(edge),
       data_(NULL) {}
@@ -448,7 +407,7 @@
 
     // Update bounding rectangle.
     point_type p = prepare_point(site.point0());
- vrect_ = brect_type(p);
+ vrect_ = brect_type(p.x(), p.y());
 
     // Update cell records.
     cells_.push_back(cell_type(p, NULL));
@@ -480,7 +439,8 @@
     }
 
     // Update the bounding rectangle.
- vrect_.update(prepare_point(site2.point0()));
+ point_type p = prepare_point(site2.point0());
+ vrect_.update(p.x(), p.y());
 
     // The second site represents a new site during site event
     // processing. Add a new cell to the cell records.

Modified: sandbox/gtl/boost/polygon/voronoi_utils.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/voronoi_utils.hpp (original)
+++ sandbox/gtl/boost/polygon/voronoi_utils.hpp 2012-03-12 17:32:45 EDT (Mon, 12 Mar 2012)
@@ -105,7 +105,7 @@
         point_type direction(site1.y() - site2.y(), site2.x() - site1.x());
 
         // Find intersection points.
- intersect(origin, direction, LINE, brect, discretization);
+ intersect(origin, direction, LINE, get_brect(brect), discretization);
 
         // Update endpoints in case edge is a ray.
         if (edge.vertex1() != NULL)
@@ -130,7 +130,9 @@
         // Edge is a segment or parabolic arc.
         discretization.push_back(get_point(edge.vertex0()->vertex()));
         discretization.push_back(get_point(edge.vertex1()->vertex()));
- coordinate_type max_dist = max_error * brect.min_len();
+ coordinate_type x_len = to_fpt(brect.x_max()) - to_fpt(brect.x_min());
+ coordinate_type y_len = to_fpt(brect.y_max()) - to_fpt(brect.y_min());
+ coordinate_type max_dist = max_error * (std::min)(x_len, y_len);
         fill_intermediate_points(point1, point2, point3,
                                  discretization, max_dist);
       } else {
@@ -230,6 +232,15 @@
     return point_type(x, y);
   }
 
+ template <typename CT>
+ static brect_type get_brect(const bounding_rectangle<CT> &rect) {
+ coordinate_type x1 = to_fpt(rect.x_min());
+ coordinate_type y1 = to_fpt(rect.y_min());
+ coordinate_type x2 = to_fpt(rect.x_max());
+ coordinate_type y2 = to_fpt(rect.y_max());
+ return brect_type(x1, y1, x2, y2);
+ }
+
   // Find intermediate points of the parabola.
   // Parabola is a locus of points equidistant from the point and segment
   // sites. intermediate_points should contain two initial endpoints


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