|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r78759 - in trunk: boost/polygon boost/polygon/detail libs/polygon/test
From: sydorchuk.andriy_at_[hidden]
Date: 2012-05-29 17:22:41
Author: asydorchuk
Date: 2012-05-29 17:22:40 EDT (Tue, 29 May 2012)
New Revision: 78759
URL: http://svn.boost.org/trac/boost/changeset/78759
Log:
Polygon: moving from index to sorted_index for the site events.
Text files modified:
trunk/boost/polygon/detail/voronoi_predicates.hpp | 11 ++--
trunk/boost/polygon/detail/voronoi_structures.hpp | 32 +++++++-------
trunk/boost/polygon/segment_concept.hpp | 2
trunk/boost/polygon/voronoi_builder.hpp | 2
trunk/boost/polygon/voronoi_diagram.hpp | 8 +-
trunk/libs/polygon/test/voronoi_predicates_test.cpp | 88 ++++++++++++++++++++--------------------
trunk/libs/polygon/test/voronoi_structures_test.cpp | 16 +++---
7 files changed, 80 insertions(+), 79 deletions(-)
Modified: trunk/boost/polygon/detail/voronoi_predicates.hpp
==============================================================================
--- trunk/boost/polygon/detail/voronoi_predicates.hpp (original)
+++ trunk/boost/polygon/detail/voronoi_predicates.hpp 2012-05-29 17:22:40 EDT (Tue, 29 May 2012)
@@ -406,10 +406,10 @@
return !predicate_(node2.left_site(), node2.right_site(), site1);
} else {
// This checks were evaluated experimentally.
- if (site1.index() == site2.index()) {
+ if (site1.sorted_index() == site2.sorted_index()) {
// Both nodes are new (inserted during same site event processing).
return get_comparison_y(node1) < get_comparison_y(node2);
- } else if (site1.index() < site2.index()) {
+ } else if (site1.sorted_index() < site2.sorted_index()) {
std::pair<coordinate_type, int> y1 = get_comparison_y(node1, false);
std::pair<coordinate_type, int> y2 = get_comparison_y(node2, true);
if (y1.first != y2.first) return y1.first < y2.first;
@@ -426,7 +426,7 @@
private:
// Get the newer site.
const site_type &get_comparison_site(const node_type &node) const {
- if (node.left_site().index() > node.right_site().index()) {
+ if (node.left_site().sorted_index() > node.right_site().sorted_index()) {
return node.left_site();
}
return node.right_site();
@@ -435,10 +435,11 @@
// Get comparison pair: y coordinate and direction of the newer site.
std::pair<coordinate_type, int> get_comparison_y(
const node_type &node, bool is_new_node = true) const {
- if (node.left_site().index() == node.right_site().index()) {
+ if (node.left_site().sorted_index() ==
+ node.right_site().sorted_index()) {
return std::make_pair(node.left_site().y(), 0);
}
- if (node.left_site().index() > node.right_site().index()) {
+ if (node.left_site().sorted_index() > node.right_site().sorted_index()) {
if (!is_new_node &&
node.left_site().is_segment() &&
is_vertical(node.left_site())) {
Modified: trunk/boost/polygon/detail/voronoi_structures.hpp
==============================================================================
--- trunk/boost/polygon/detail/voronoi_structures.hpp (original)
+++ trunk/boost/polygon/detail/voronoi_structures.hpp 2012-05-29 17:22:40 EDT (Tue, 29 May 2012)
@@ -91,39 +91,39 @@
site_event() :
point0_(0, 0),
point1_(0, 0),
- site_index_(0) {}
+ sorted_index_(0) {}
site_event(coordinate_type x, coordinate_type y) :
point0_(x, y),
point1_(x, y),
- site_index_(0) {}
+ sorted_index_(0) {}
site_event(const point_type &point) :
point0_(point),
point1_(point),
- site_index_(0) {}
+ sorted_index_(0) {}
site_event(coordinate_type x1, coordinate_type y1,
coordinate_type x2, coordinate_type y2):
point0_(x1, y1),
point1_(x2, y2),
- site_index_(0) {}
+ sorted_index_(0) {}
site_event(const point_type &point1, const point_type &point2) :
point0_(point1),
point1_(point2),
- site_index_(0) {}
+ sorted_index_(0) {}
bool operator==(const site_event &that) const {
return (this->point0_ == that.point0_) &&
(this->point1_ == that.point1_) &&
- (this->site_index_ == that.site_index_);
+ (this->sorted_index_ == that.sorted_index_);
}
bool operator!=(const site_event &that) const {
return (this->point0_ != that.point0_) ||
(this->point1_ != that.point1_) ||
- (this->site_index_ != that.site_index_);
+ (this->sorted_index_ != that.sorted_index_);
}
coordinate_type x(bool oriented = false) const {
@@ -170,23 +170,23 @@
return is_inverse() ? point0_ : point1_;
}
- site_event& index(int index) {
- site_index_ = (index << 2) + (site_index_ & 3);
+ site_event& sorted_index(std::size_t index) {
+ sorted_index_ = (index << 2) + (sorted_index_ & 3);
return *this;
}
site_event& inverse() {
- site_index_ ^= IS_INVERSE;
+ sorted_index_ ^= IS_INVERSE;
return *this;
}
site_event& change_initial_direction() {
- site_index_ ^= HAS_INITIAL_DIRECTION;
+ sorted_index_ ^= HAS_INITIAL_DIRECTION;
return *this;
}
- std::size_t index() const {
- return site_index_ >> 2;
+ std::size_t sorted_index() const {
+ return sorted_index_ >> 2;
}
bool is_point() const {
@@ -198,11 +198,11 @@
}
bool is_inverse() const {
- return (site_index_ & IS_INVERSE) ? true : false;
+ return (sorted_index_ & IS_INVERSE) ? true : false;
}
bool is_initial() const {
- return (site_index_ & HAS_INITIAL_DIRECTION) ? false : true;
+ return (sorted_index_ & HAS_INITIAL_DIRECTION) ? false : true;
}
bool has_initial_direction() const {
@@ -217,7 +217,7 @@
point_type point0_;
point_type point1_;
- unsigned int site_index_;
+ std::size_t sorted_index_;
};
// Circle event type.
Modified: trunk/boost/polygon/segment_concept.hpp
==============================================================================
--- trunk/boost/polygon/segment_concept.hpp (original)
+++ trunk/boost/polygon/segment_concept.hpp 2012-05-29 17:22:40 EDT (Tue, 29 May 2012)
@@ -639,7 +639,7 @@
int or2_2 = orientation(segment2, high(segment1));
if (or2_1 * or2_2 > 0)
return false;
- if (consider_touch || or1_1 && or1_2 || or2_1 && or2_2)
+ if (consider_touch || (or1_1 && or1_2) || (or2_1 && or2_2))
return true;
if (or1_1 || or1_2)
return false;
Modified: trunk/boost/polygon/voronoi_builder.hpp
==============================================================================
--- trunk/boost/polygon/voronoi_builder.hpp (original)
+++ trunk/boost/polygon/voronoi_builder.hpp 2012-05-29 17:22:40 EDT (Tue, 29 May 2012)
@@ -162,7 +162,7 @@
// Index sites.
for (std::size_t cur = 0; cur < site_events_.size(); ++cur)
- site_events_[cur].index(cur);
+ site_events_[cur].sorted_index(cur);
// Init site iterator.
site_event_iterator_ = site_events_.begin();
Modified: trunk/boost/polygon/voronoi_diagram.hpp
==============================================================================
--- trunk/boost/polygon/voronoi_diagram.hpp (original)
+++ trunk/boost/polygon/voronoi_diagram.hpp 2012-05-29 17:22:40 EDT (Tue, 29 May 2012)
@@ -396,8 +396,8 @@
std::pair<void*, void*> insert_new_edge(
const SEvent &site1, const SEvent &site2) {
// Get sites' indexes.
- int site_index1 = site1.index();
- int site_index2 = site2.index();
+ int site_index1 = site1.sorted_index();
+ int site_index2 = site2.sorted_index();
// Create a new half-edge that belongs to the first site.
edges_.push_back(edge_type());
@@ -454,12 +454,12 @@
// Add a new half-edge.
edges_.push_back(edge_type());
edge_type &new_edge1 = edges_.back();
- new_edge1.cell(&cells_[site1.index()]);
+ new_edge1.cell(&cells_[site1.sorted_index()]);
// Add a new half-edge.
edges_.push_back(edge_type());
edge_type &new_edge2 = edges_.back();
- new_edge2.cell(&cells_[site3.index()]);
+ new_edge2.cell(&cells_[site3.sorted_index()]);
// Update twin pointers.
new_edge1.twin(&new_edge2);
Modified: trunk/libs/polygon/test/voronoi_predicates_test.cpp
==============================================================================
--- trunk/libs/polygon/test/voronoi_predicates_test.cpp (original)
+++ trunk/libs/polygon/test/voronoi_predicates_test.cpp 2012-05-29 17:22:40 EDT (Tue, 29 May 2012)
@@ -257,11 +257,11 @@
BOOST_AUTO_TEST_CASE(node_comparison_test1) {
beach_line_type beach_line;
site_type site1(0, 0);
- site1.index(0);
+ site1.sorted_index(0);
site_type site2(0, 2);
- site2.index(1);
+ site2.sorted_index(1);
site_type site3(1, 0);
- site3.index(2);
+ site3.sorted_index(2);
beach_line[key_type(site1, site2)] = 2;
beach_line[key_type(site1, site3)] = 0;
beach_line[key_type(site3, site1)] = 1;
@@ -275,11 +275,11 @@
BOOST_AUTO_TEST_CASE(node_comparison_test2) {
beach_line_type beach_line;
site_type site1(0, 1);
- site1.index(0);
+ site1.sorted_index(0);
site_type site2(2, 0);
- site2.index(1);
+ site2.sorted_index(1);
site_type site3(2, 4);
- site3.index(2);
+ site3.sorted_index(2);
beach_line[key_type(site1, site2)] = 0;
beach_line[key_type(site2, site1)] = 1;
beach_line[key_type(site1, site3)] = 2;
@@ -292,80 +292,80 @@
}
BOOST_AUTO_TEST_CASE(node_comparison_test3) {
- key_type node(site_type(1, 0).index(1), site_type(0, 2).index(0));
+ key_type node(site_type(1, 0).sorted_index(1), site_type(0, 2).sorted_index(0));
key_type nodes[] = {
- key_type(site_type(2, -10).index(2)),
- key_type(site_type(2, -1).index(2)),
- key_type(site_type(2, 0).index(2)),
- key_type(site_type(2, 1).index(2)),
- key_type(site_type(2, 2).index(2)),
- key_type(site_type(2, 3).index(2)),
+ key_type(site_type(2, -10).sorted_index(2)),
+ key_type(site_type(2, -1).sorted_index(2)),
+ key_type(site_type(2, 0).sorted_index(2)),
+ key_type(site_type(2, 1).sorted_index(2)),
+ key_type(site_type(2, 2).sorted_index(2)),
+ key_type(site_type(2, 3).sorted_index(2)),
};
bool res[] = {false, false, false, false, true, true};
CHECK_NODE_COMPARISON(node, nodes, res, 6);
}
BOOST_AUTO_TEST_CASE(node_comparison_test4) {
- key_type node(site_type(0, 1).index(0), site_type(1, 0).index(1));
+ key_type node(site_type(0, 1).sorted_index(0), site_type(1, 0).sorted_index(1));
key_type nodes[] = {
- key_type(site_type(2, -3).index(2)),
- key_type(site_type(2, -2).index(2)),
- key_type(site_type(2, -1).index(2)),
- key_type(site_type(2, 0).index(2)),
- key_type(site_type(2, 1).index(2)),
- key_type(site_type(2, 3).index(2)),
+ key_type(site_type(2, -3).sorted_index(2)),
+ key_type(site_type(2, -2).sorted_index(2)),
+ key_type(site_type(2, -1).sorted_index(2)),
+ key_type(site_type(2, 0).sorted_index(2)),
+ key_type(site_type(2, 1).sorted_index(2)),
+ key_type(site_type(2, 3).sorted_index(2)),
};
bool res[] = {false, true, true, true, true, true};
CHECK_NODE_COMPARISON(node, nodes, res, 6);
}
BOOST_AUTO_TEST_CASE(node_comparison_test5) {
- key_type node(site_type(0, 0).index(0), site_type(1, 2).index(1));
+ key_type node(site_type(0, 0).sorted_index(0), site_type(1, 2).sorted_index(1));
key_type nodes[] = {
- key_type(site_type(2, -10).index(2)),
- key_type(site_type(2, 0).index(2)),
- key_type(site_type(2, 1).index(2)),
- key_type(site_type(2, 2).index(2)),
- key_type(site_type(2, 5).index(2)),
- key_type(site_type(2, 20).index(2)),
+ key_type(site_type(2, -10).sorted_index(2)),
+ key_type(site_type(2, 0).sorted_index(2)),
+ key_type(site_type(2, 1).sorted_index(2)),
+ key_type(site_type(2, 2).sorted_index(2)),
+ key_type(site_type(2, 5).sorted_index(2)),
+ key_type(site_type(2, 20).sorted_index(2)),
};
bool res[] = {false, false, true, true, true, true};
CHECK_NODE_COMPARISON(node, nodes, res, 6);
}
BOOST_AUTO_TEST_CASE(node_comparison_test6) {
- key_type node(site_type(1, 1).index(1), site_type(0, 0).index(0));
+ key_type node(site_type(1, 1).sorted_index(1), site_type(0, 0).sorted_index(0));
key_type nodes [] = {
- key_type(site_type(2, -3).index(2)),
- key_type(site_type(2, -2).index(2)),
- key_type(site_type(2, 0).index(2)),
- key_type(site_type(2, 1).index(2)),
- key_type(site_type(2, 2).index(2)),
- key_type(site_type(2, 3).index(2)),
- key_type(site_type(2, 5).index(2)),
+ key_type(site_type(2, -3).sorted_index(2)),
+ key_type(site_type(2, -2).sorted_index(2)),
+ key_type(site_type(2, 0).sorted_index(2)),
+ key_type(site_type(2, 1).sorted_index(2)),
+ key_type(site_type(2, 2).sorted_index(2)),
+ key_type(site_type(2, 3).sorted_index(2)),
+ key_type(site_type(2, 5).sorted_index(2)),
};
bool res[] = {false, false, false, false, false, false, true};
CHECK_NODE_COMPARISON(node, nodes, res, 7);
}
BOOST_AUTO_TEST_CASE(node_comparison_test7) {
- key_type node(site_type(0, 0).index(0), site_type(0, 2).index(1));
+ key_type node(site_type(0, 0).sorted_index(0), site_type(0, 2).sorted_index(1));
key_type nodes[] = {
- key_type(site_type(1, 0).index(2)),
- key_type(site_type(1, 1).index(2)),
- key_type(site_type(1, 2).index(2)),
+ key_type(site_type(1, 0).sorted_index(2)),
+ key_type(site_type(1, 1).sorted_index(2)),
+ key_type(site_type(1, 2).sorted_index(2)),
};
bool res[] = {false, false, true};
CHECK_NODE_COMPARISON(node, nodes, res, 3);
}
BOOST_AUTO_TEST_CASE(node_comparison_test8) {
- key_type node(site_type(0, 0).index(0), site_type(1, 1).index(2));
+ key_type node(site_type(0, 0).sorted_index(0), site_type(1, 1).sorted_index(2));
key_type nodes[] = {
- key_type(site_type(1, 0).index(1)),
- key_type(site_type(1, 1).index(2)),
- key_type(site_type(1, 2).index(3)),
- key_type(site_type(1, 1).index(2), site_type(0, 0).index(0)),
+ key_type(site_type(1, 0).sorted_index(1)),
+ key_type(site_type(1, 1).sorted_index(2)),
+ key_type(site_type(1, 2).sorted_index(3)),
+ key_type(site_type(1, 1).sorted_index(2), site_type(0, 0).sorted_index(0)),
};
bool res[] = {false, true, true, true};
CHECK_NODE_COMPARISON(node, nodes, res, 4);
Modified: trunk/libs/polygon/test/voronoi_structures_test.cpp
==============================================================================
--- trunk/libs/polygon/test/voronoi_structures_test.cpp (original)
+++ trunk/libs/polygon/test/voronoi_structures_test.cpp 2012-05-29 17:22:40 EDT (Tue, 29 May 2012)
@@ -34,11 +34,11 @@
site_type s(1, 2);
BOOST_CHECK(s.x0() == s.x1() && s.x1() == 1);
BOOST_CHECK(s.y0() == s.y1() && s.y1() == 2);
- BOOST_CHECK(s.index() == 0);
+ BOOST_CHECK(s.sorted_index() == 0);
BOOST_CHECK(!s.is_segment());
BOOST_CHECK(!s.is_inverse());
- s.index(1);
- BOOST_CHECK(s.index() == 1);
+ s.sorted_index(1);
+ BOOST_CHECK(s.sorted_index() == 1);
BOOST_CHECK(!s.is_inverse());
}
@@ -48,7 +48,7 @@
BOOST_CHECK(s.y0(true) == 2 && s.y0() == 2);
BOOST_CHECK(s.x1(true) == 3 && s.x1() == 3);
BOOST_CHECK(s.y1(true) == 4 && s.y1() == 4);
- BOOST_CHECK(s.index() == 0);
+ BOOST_CHECK(s.sorted_index() == 0);
BOOST_CHECK(s.is_segment());
BOOST_CHECK(!s.is_inverse());
s.inverse();
@@ -61,18 +61,18 @@
BOOST_AUTO_TEST_CASE(site_event_test4) {
site_type s(1, 2, 3, 4);
- s.index(27);
+ s.sorted_index(27);
BOOST_CHECK(s.is_initial());
BOOST_CHECK(s.has_initial_direction());
- BOOST_CHECK(s.index() == 27);
+ BOOST_CHECK(s.sorted_index() == 27);
s.inverse();
BOOST_CHECK(!s.has_initial_direction());
BOOST_CHECK(s.is_initial());
- BOOST_CHECK(s.index() == 27);
+ BOOST_CHECK(s.sorted_index() == 27);
s.change_initial_direction();
BOOST_CHECK(s.has_initial_direction());
BOOST_CHECK(!s.is_initial());
- BOOST_CHECK(s.index() == 27);
+ BOOST_CHECK(s.sorted_index() == 27);
}
BOOST_AUTO_TEST_CASE(circle_event_test) {
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