Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76675 - in sandbox/gtl: boost/polygon/detail libs/polygon/test
From: sydorchuk.andriy_at_[hidden]
Date: 2012-01-24 17:23:54


Author: asydorchuk
Date: 2012-01-24 17:23:51 EST (Tue, 24 Jan 2012)
New Revision: 76675
URL: http://svn.boost.org/trac/boost/changeset/76675

Log:
voronoi_structures test update.
added initial site direction flag to the site_event data structure (allows to skip circle events outside of the polyline).
Text files modified:
   sandbox/gtl/boost/polygon/detail/voronoi_ctypes.hpp | 4
   sandbox/gtl/boost/polygon/detail/voronoi_predicates.hpp | 8 +-
   sandbox/gtl/boost/polygon/detail/voronoi_structures.hpp | 23 +++++++++-
   sandbox/gtl/libs/polygon/test/voronoi_structures_test.cpp | 84 ++++++++++++++++++++++++---------------
   4 files changed, 77 insertions(+), 42 deletions(-)

Modified: sandbox/gtl/boost/polygon/detail/voronoi_ctypes.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/detail/voronoi_ctypes.hpp (original)
+++ sandbox/gtl/boost/polygon/detail/voronoi_ctypes.hpp 2012-01-24 17:23:51 EST (Tue, 24 Jan 2012)
@@ -469,7 +469,7 @@
             return;
         }
         if ((e1.count() > 0) ^ (e2.count() > 0)) {
- dif(e1.chunks(), e1.size(), e2.chunks(), e2.size());
+ dif(e1.chunks(), e1.size(), e2.chunks(), e2.size());
         } else {
             add(e1.chunks(), e1.size(), e2.chunks(), e2.size());
         }
@@ -502,7 +502,7 @@
             dif(e1.chunks(), e1.size(), e2.chunks(), e2.size());
         }
         if (e1.count() < 0) {
- this->count_ = -this->count_;
+ this->count_ = -this->count_;
         }
     }
 

Modified: sandbox/gtl/boost/polygon/detail/voronoi_predicates.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/detail/voronoi_predicates.hpp (original)
+++ sandbox/gtl/boost/polygon/detail/voronoi_predicates.hpp 2012-01-24 17:23:51 EST (Tue, 24 Jan 2012)
@@ -52,7 +52,7 @@
     // with epsilon relative error equal to 1EPS.
     template <typename T>
     static fpt_type robust_cross_product(T a1_, T b1_, T a2_, T b2_) {
- static to_fpt_converter to_fpt;
+ static to_fpt_converter to_fpt;
         uint_x2_type a1 = static_cast<uint_x2_type>(is_neg(a1_) ? -a1_ : a1_);
         uint_x2_type b1 = static_cast<uint_x2_type>(is_neg(b1_) ? -b1_ : b1_);
         uint_x2_type a2 = static_cast<uint_x2_type>(is_neg(a2_) ? -a2_ : a2_);
@@ -117,12 +117,12 @@
     class point_comparison_predicate {
     public:
         typedef Point point_type;
-
+
         bool operator()(const point_type &lhs, const point_type &rhs) const {
             if (lhs.x() == rhs.x()) {
                 return lhs.y() < rhs.y();
             }
- return lhs.x() < rhs.x();
+ return lhs.x() < rhs.x();
         }
     };
 
@@ -225,7 +225,7 @@
             }
         }
 
- private:
+ private:
         // Represents the result of the epsilon robust predicate. If the
         // result is undefined some further processing is usually required.
         enum kPredicateResult {

Modified: sandbox/gtl/boost/polygon/detail/voronoi_structures.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/detail/voronoi_structures.hpp (original)
+++ sandbox/gtl/boost/polygon/detail/voronoi_structures.hpp 2012-01-24 17:23:51 EST (Tue, 24 Jan 2012)
@@ -77,6 +77,7 @@
     // Variables: point0_ - point site or segment's startpoint;
     // point1_ - segment's endpoint if site is a segment;
     // index_ - the last bit encodes if the site is inverse,
+ // the last-1 bit encodes initial site direction,
     // all the other bits encode site event index among
     // the other site events.
     // Note: for all the sites is_inverse_ flag is equal to false by default.
@@ -170,7 +171,7 @@
         }
 
         site_event& index(int index) {
- site_index_ = index << 1;
+ site_index_ = index << 2;
             return *this;
         }
 
@@ -179,8 +180,13 @@
             return *this;
         }
 
+ site_event& change_initial_direction() {
+ site_index_ ^= IS_INITIAL_DIRECTION;
+ return *this;
+ }
+
         size_t index() const {
- return site_index_ >> 1;
+ return site_index_ >> 2;
         }
 
         bool is_point() const {
@@ -192,12 +198,21 @@
         }
 
         bool is_inverse() const {
- return site_index_ & IS_INVERSE;
+ return (site_index_ & IS_INVERSE) ? true : false;
+ }
+
+ bool is_initial() const {
+ return (site_index_ & IS_INITIAL_DIRECTION) ? false : true;
+ }
+
+ bool has_initial_direction() const {
+ return is_inverse() ^ is_initial();
         }
 
     private:
         enum kBits {
- IS_INVERSE = 1
+ IS_INVERSE = 1,
+ IS_INITIAL_DIRECTION = 2,
         };
 
         point_type point0_;

Modified: sandbox/gtl/libs/polygon/test/voronoi_structures_test.cpp
==============================================================================
--- sandbox/gtl/libs/polygon/test/voronoi_structures_test.cpp (original)
+++ sandbox/gtl/libs/polygon/test/voronoi_structures_test.cpp 2012-01-24 17:23:51 EST (Tue, 24 Jan 2012)
@@ -1,6 +1,6 @@
 // Boost.Polygon library voronoi_structures_test.cpp file
 
-// Copyright Andrii Sydorchuk 2010-2011.
+// Copyright Andrii Sydorchuk 2010-2012.
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
@@ -20,7 +20,7 @@
 typedef beach_line_node_key<int> node_key_type;
 typedef beach_line_node_data<int, int> node_data_type;
 
-BOOST_AUTO_TEST_CASE(point_2d_test) {
+BOOST_AUTO_TEST_CASE(point_2d_test1) {
     point_type p(1, 2);
     BOOST_CHECK_EQUAL(p.x(), 1);
     BOOST_CHECK_EQUAL(p.y(), 2);
@@ -30,30 +30,49 @@
     BOOST_CHECK_EQUAL(p.y(), 4);
 }
 
-BOOST_AUTO_TEST_CASE(site_event_test1) {
+BOOST_AUTO_TEST_CASE(site_event_test2) {
     site_type s(1, 2);
- BOOST_CHECK_EQUAL(s.x0() == s.x1() && s.x1() == 1, true);
- BOOST_CHECK_EQUAL(s.y0() == s.y1() && s.y1() == 2, true);
- BOOST_CHECK_EQUAL(s.index() == 0, true);
- BOOST_CHECK_EQUAL(s.is_segment(), false);
- BOOST_CHECK_EQUAL(s.is_inverse(), false);
+ 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.is_segment());
+ BOOST_CHECK(!s.is_inverse());
+ s.index(1);
+ BOOST_CHECK(s.index() == 1);
+ BOOST_CHECK(!s.is_inverse());
 }
 
-BOOST_AUTO_TEST_CASE(site_event_test2) {
+BOOST_AUTO_TEST_CASE(site_event_test3) {
+ site_type s(1, 2, 3, 4);
+ BOOST_CHECK(s.x0(true) == 1 && s.x0() == 1);
+ 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.is_segment());
+ BOOST_CHECK(!s.is_inverse());
+ s.inverse();
+ BOOST_CHECK(s.x1(true) == 1 && s.x0() == 1);
+ BOOST_CHECK(s.y1(true) == 2 && s.y0() == 2);
+ BOOST_CHECK(s.x0(true) == 3 && s.x1() == 3);
+ BOOST_CHECK(s.y0(true) == 4 && s.y1() == 4);
+ BOOST_CHECK(s.is_inverse());
+}
+
+BOOST_AUTO_TEST_CASE(site_event_test4) {
     site_type s(1, 2, 3, 4);
- BOOST_CHECK_EQUAL(s.x0(true) == 1 && s.x0() == 1, true);
- BOOST_CHECK_EQUAL(s.y0(true) == 2 && s.y0() == 2, true);
- BOOST_CHECK_EQUAL(s.x1(true) == 3 && s.x1() == 3, true);
- BOOST_CHECK_EQUAL(s.y1(true) == 4 && s.y1() == 4, true);
- BOOST_CHECK_EQUAL(s.index() == 0, true);
- BOOST_CHECK_EQUAL(s.is_segment(), true);
- BOOST_CHECK_EQUAL(s.is_inverse(), false);
+ s.index(27);
+ BOOST_CHECK(s.is_initial());
+ BOOST_CHECK(s.has_initial_direction());
+ BOOST_CHECK_EQUAL(s.index(), 27);
     s.inverse();
- BOOST_CHECK_EQUAL(s.x1(true) == 1 && s.x0() == 1, true);
- BOOST_CHECK_EQUAL(s.y1(true) == 2 && s.y0() == 2, true);
- BOOST_CHECK_EQUAL(s.x0(true) == 3 && s.x1() == 3, true);
- BOOST_CHECK_EQUAL(s.y0(true) == 4 && s.y1() == 4, true);
- BOOST_CHECK_EQUAL(s.is_inverse(), true);
+ BOOST_CHECK(!s.has_initial_direction());
+ BOOST_CHECK(s.is_initial());
+ BOOST_CHECK_EQUAL(s.index(), 27);
+ s.change_initial_direction();
+ BOOST_CHECK(s.has_initial_direction());
+ BOOST_CHECK(!s.is_initial());
+ BOOST_CHECK_EQUAL(s.index(), 27);
 }
 
 BOOST_AUTO_TEST_CASE(circle_event_test) {
@@ -62,29 +81,30 @@
     BOOST_CHECK_EQUAL(c.y(), 1);
     BOOST_CHECK_EQUAL(c.lower_x(), 2);
     BOOST_CHECK_EQUAL(c.lower_y(), 1);
- BOOST_CHECK_EQUAL(c.is_active(), true);
+ BOOST_CHECK(c.is_active());
     c.x(3);
- BOOST_CHECK_EQUAL(c.x(), 3);
     c.y(4);
- BOOST_CHECK_EQUAL(c.y(), 4);
     c.lower_x(5);
+ BOOST_CHECK_EQUAL(c.x(), 3);
+ BOOST_CHECK_EQUAL(c.y(), 4);
     BOOST_CHECK_EQUAL(c.lower_x(), 5);
+ BOOST_CHECK_EQUAL(c.lower_y(), 4);
     c.deactivate();
- BOOST_CHECK_EQUAL(c.is_active(), false);
+ BOOST_CHECK(!c.is_active());
 }
 
 BOOST_AUTO_TEST_CASE(ordered_queue_test) {
     ordered_queue_type q;
- BOOST_CHECK_EQUAL(q.empty(), true);
+ BOOST_CHECK(q.empty());
     std::vector<int*> vi;
     for (int i = 0; i < 20; ++i)
         vi.push_back(&q.push(i));
     for (int i = 0; i < 20; ++i)
         *vi[i] <<= 1;
- BOOST_CHECK_EQUAL(q.empty(), false);
+ BOOST_CHECK(!q.empty());
     for (int i = 0; i < 20; ++i, q.pop())
         BOOST_CHECK_EQUAL(q.top(), i << 1);
- BOOST_CHECK_EQUAL(q.empty(), true);
+ BOOST_CHECK(q.empty());
 }
 
 BOOST_AUTO_TEST_CASE(beach_line_node_key_test) {
@@ -92,11 +112,11 @@
     BOOST_CHECK_EQUAL(key.left_site(), 1);
     BOOST_CHECK_EQUAL(key.right_site(), 1);
     key.left_site(2);
- BOOST_CHECK_EQUAL(key.left_site() == 2, true);
- BOOST_CHECK_EQUAL(key.right_site() == 1, true);
+ BOOST_CHECK_EQUAL(key.left_site(), 2);
+ BOOST_CHECK_EQUAL(key.right_site(), 1);
     key.right_site(3);
- BOOST_CHECK_EQUAL(key.left_site() == 2, true);
- BOOST_CHECK_EQUAL(key.right_site() == 3, true);
+ BOOST_CHECK_EQUAL(key.left_site(), 2);
+ BOOST_CHECK_EQUAL(key.right_site(), 3);
 }
 
 BOOST_AUTO_TEST_CASE(beach_line_node_data_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