|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r80437 - in trunk/libs/polygon: benchmark example test
From: sydorchuk.andriy_at_[hidden]
Date: 2012-09-07 18:20:12
Author: asydorchuk
Date: 2012-09-07 18:20:10 EDT (Fri, 07 Sep 2012)
New Revision: 80437
URL: http://svn.boost.org/trac/boost/changeset/80437
Log:
Polygon: running new test headers over c++lint checker.
Text files modified:
trunk/libs/polygon/benchmark/voronoi_benchmark.cpp | 18 +++++++++---
trunk/libs/polygon/benchmark/voronoi_benchmark_points.cpp | 6 +++-
trunk/libs/polygon/benchmark/voronoi_benchmark_segments.cpp | 10 +++++--
trunk/libs/polygon/example/voronoi_advanced_tutorial.cpp | 20 +++++++++------
trunk/libs/polygon/example/voronoi_basic_tutorial.cpp | 53 ++++++++++++++++++++++++---------------
trunk/libs/polygon/example/voronoi_visual_utils.hpp | 11 +++----
trunk/libs/polygon/example/voronoi_visualizer.cpp | 35 ++++++++++++++++---------
trunk/libs/polygon/test/polygon_segment_test.cpp | 9 +++++-
trunk/libs/polygon/test/voronoi_builder_test.cpp | 6 +++
trunk/libs/polygon/test/voronoi_ctypes_test.cpp | 3 +
trunk/libs/polygon/test/voronoi_predicates_test.cpp | 3 +
trunk/libs/polygon/test/voronoi_robust_fpt_test.cpp | 19 ++++++++++++--
trunk/libs/polygon/test/voronoi_structures_test.cpp | 6 +++-
trunk/libs/polygon/test/voronoi_test_helper.hpp | 45 +++++++++++++++++++++------------
14 files changed, 159 insertions(+), 85 deletions(-)
Modified: trunk/libs/polygon/benchmark/voronoi_benchmark.cpp
==============================================================================
--- trunk/libs/polygon/benchmark/voronoi_benchmark.cpp (original)
+++ trunk/libs/polygon/benchmark/voronoi_benchmark.cpp 2012-09-07 18:20:10 EDT (Fri, 07 Sep 2012)
@@ -7,9 +7,11 @@
// See http://www.boost.org for updates, documentation, and revision history.
+#include <algorithm>
#include <iomanip>
#include <iostream>
#include <fstream>
+#include <list>
#include <numeric>
#include <vector>
@@ -21,7 +23,9 @@
#include <boost/polygon/polygon.hpp>
#include <boost/polygon/voronoi.hpp>
-using namespace boost::polygon;
+using boost::polygon::point_data;
+using boost::polygon::segment_data;
+using boost::polygon::voronoi_diagram;
typedef boost::mpl::list<int> test_types;
const char *BENCHMARK_FILE = "voronoi_benchmark.txt";
@@ -98,10 +102,12 @@
}
std::sort(periods.begin(), periods.end());
// Using olympic system to evaluate average time.
- double elapsed_time = std::accumulate(periods.begin() + 2, periods.end() - 2, 0.0);
+ double elapsed_time =
+ std::accumulate(periods.begin() + 2, periods.end() - 2, 0.0);
elapsed_time /= (periods.size() - 4);
- std::ofstream bench_file(BENCHMARK_FILE, std::ios_base::out | std::ios_base::app);
+ std::ofstream bench_file(
+ BENCHMARK_FILE, std::ios_base::out | std::ios_base::app);
bench_file << std::setiosflags(std::ios::right | std::ios::fixed) << std::setprecision(6);
bench_file << "Static test of " << points.size() << " points: " << elapsed_time << std::endl;
bench_file.close();
@@ -138,10 +144,12 @@
}
std::sort(periods.begin(), periods.end());
// Using olympic system to evaluate average time.
- double elapsed_time = std::accumulate(periods.begin() + 2, periods.end() - 2, 0.0);
+ double elapsed_time =
+ std::accumulate(periods.begin() + 2, periods.end() - 2, 0.0);
elapsed_time /= (periods.size() - 4);
- std::ofstream bench_file(BENCHMARK_FILE, std::ios_base::out | std::ios_base::app);
+ std::ofstream bench_file(
+ BENCHMARK_FILE, std::ios_base::out | std::ios_base::app);
bench_file << std::setiosflags(std::ios::right | std::ios::fixed) << std::setprecision(6);
bench_file << "Static test of " << segments.size() << " segments: " << elapsed_time << std::endl;
bench_file.close();
Modified: trunk/libs/polygon/benchmark/voronoi_benchmark_points.cpp
==============================================================================
--- trunk/libs/polygon/benchmark/voronoi_benchmark_points.cpp (original)
+++ trunk/libs/polygon/benchmark/voronoi_benchmark_points.cpp 2012-09-07 18:20:10 EDT (Fri, 07 Sep 2012)
@@ -7,11 +7,13 @@
// See http://www.boost.org for updates, documentation, and revision history.
+#include <algorithm>
#include <iomanip>
#include <iostream>
#include <fstream>
#include <numeric>
#include <vector>
+#include <utility>
#include <boost/random/mersenne_twister.hpp>
#include <boost/timer.hpp>
@@ -44,7 +46,8 @@
const int NUM_TESTS = 6;
const int NUM_POINTS[] = {10, 100, 1000, 10000, 100000, 1000000};
const int NUM_RUNS[] = {100000, 10000, 1000, 100, 10, 1};
-std::ofstream bf("benchmark_points.txt", std::ios_base::out | std::ios_base::app);
+std::ofstream bf("benchmark_points.txt",
+ std::ios_base::out | std::ios_base::app);
boost::timer timer;
void format_line(int num_points, int num_tests, double time_per_test) {
@@ -113,7 +116,6 @@
// Absolutely the same code is used by the Boost.Polygon Voronoi library.
std::sort(upts.begin(), upts.end());
upts.erase(std::unique(upts.begin(), upts.end()), upts.end());
-
for (int k = 0; k < upts.size(); ++k) {
pt.r = koef * upts[k].first;
pt.c = koef * upts[k].second;
Modified: trunk/libs/polygon/benchmark/voronoi_benchmark_segments.cpp
==============================================================================
--- trunk/libs/polygon/benchmark/voronoi_benchmark_segments.cpp (original)
+++ trunk/libs/polygon/benchmark/voronoi_benchmark_segments.cpp 2012-09-07 18:20:10 EDT (Fri, 07 Sep 2012)
@@ -7,11 +7,13 @@
// See http://www.boost.org for updates, documentation, and revision history.
+#include <algorithm>
#include <iomanip>
#include <iostream>
#include <fstream>
#include <numeric>
#include <vector>
+#include <utility>
#include <boost/random/mersenne_twister.hpp>
#include <boost/timer.hpp>
@@ -47,7 +49,8 @@
const int NUM_TESTS = 6;
const int NUM_SEGMENTS[] = {10, 100, 1000, 10000, 100000, 1000000};
const int NUM_RUNS[] = {100000, 10000, 1000, 100, 10, 1};
-std::ofstream bf("benchmark_segments.txt", std::ios_base::out | std::ios_base::app);
+std::ofstream bf("benchmark_segments.txt",
+ std::ios_base::out | std::ios_base::app);
boost::timer timer;
void format_line(int num_points, int num_tests, double time_per_test) {
@@ -66,13 +69,14 @@
std::vector<std::pair<half_edge, segment_id> > half_edges_out;
segment_id id = 0;
half_edges.reserve(data.size());
- for (std::vector<SEGMENT_POLYGON>::iterator it = data.begin(); it != data.end(); ++it) {
+ for (std::vector<SEGMENT_POLYGON>::iterator it = data.begin();
+ it != data.end(); ++it) {
POINT_POLYGON l = it->low();
POINT_POLYGON h = it->high();
half_edges.push_back(std::make_pair(half_edge(l, h), id++));
}
half_edges_out.reserve(half_edges.size());
- //apparently no need to pre-sort data when calling validate_scan
+ // Apparently no need to pre-sort data when calling validate_scan.
boost::polygon::line_intersection<Unit>::validate_scan(
half_edges_out, half_edges.begin(), half_edges.end());
std::vector<SEGMENT_POLYGON> result;
Modified: trunk/libs/polygon/example/voronoi_advanced_tutorial.cpp
==============================================================================
--- trunk/libs/polygon/example/voronoi_advanced_tutorial.cpp (original)
+++ trunk/libs/polygon/example/voronoi_advanced_tutorial.cpp 2012-09-07 18:20:10 EDT (Fri, 07 Sep 2012)
@@ -22,14 +22,15 @@
#include <boost/timer/timer.hpp>
#include <boost/polygon/voronoi.hpp>
-using namespace boost::polygon;
+using boost::polygon::voronoi_builder;
+using boost::polygon::voronoi_diagram;
struct my_ulp_comparison {
enum Result {
LESS = -1,
EQUAL = 0,
MORE = 1
- };
+ };
Result operator()(fpt80 a, fpt80 b, unsigned int maxUlps) const {
if (a == b)
@@ -44,19 +45,23 @@
rhs.d = b;
if (lhs.ieee.negative ^ rhs.ieee.negative)
return lhs.ieee.negative ? LESS : MORE;
- boost::uint64_t le = lhs.ieee.exponent; le = (le << 32) + lhs.ieee.mantissa0;
- boost::uint64_t re = rhs.ieee.exponent; re = (re << 32) + rhs.ieee.mantissa0;
+ boost::uint64_t le = lhs.ieee.exponent; le =
+ (le << 32) + lhs.ieee.mantissa0;
+ boost::uint64_t re = rhs.ieee.exponent; re =
+ (re << 32) + rhs.ieee.mantissa0;
if (lhs.ieee.negative) {
if (le - 1 > re)
return LESS;
- le = (le == re) ? 0 : 1; le = (le << 32) + lhs.ieee.mantissa1;
+ le = (le == re) ? 0 : 1;
+ le = (le << 32) + lhs.ieee.mantissa1;
re = rhs.ieee.mantissa1;
return (re + maxUlps < le) ? LESS : EQUAL;
} else {
if (le + 1 < re)
return LESS;
le = lhs.ieee.mantissa0;
- re = (le == re) ? 0 : 1; re = (re << 32) + rhs.ieee.mantissa1;
+ re = (le == re) ? 0 : 1;
+ re = (re << 32) + rhs.ieee.mantissa1;
return (le + maxUlps < re) ? LESS : EQUAL;
}
}
@@ -121,8 +126,7 @@
const unsigned int GENERATED_POINTS = 100;
const boost::int64_t MAX = 0x1000000000000LL;
-#include <iostream>
-int main () {
+int main() {
boost::mt19937_64 gen(std::time(0));
boost::random::uniform_int_distribution<boost::int64_t> distr(-MAX, MAX-1);
voronoi_builder<boost::int64_t, my_voronoi_ctype_traits> vb;
Modified: trunk/libs/polygon/example/voronoi_basic_tutorial.cpp
==============================================================================
--- trunk/libs/polygon/example/voronoi_basic_tutorial.cpp (original)
+++ trunk/libs/polygon/example/voronoi_basic_tutorial.cpp 2012-09-07 18:20:10 EDT (Fri, 07 Sep 2012)
@@ -11,45 +11,51 @@
#include <vector>
#include <boost/polygon/voronoi.hpp>
-using namespace boost::polygon;
+using boost::polygon::voronoi_builder;
+using boost::polygon::voronoi_diagram;
#include "voronoi_visual_utils.hpp"
struct Point {
int a;
int b;
- Point (int x, int y) : a(x), b(y) {}
+ Point(int x, int y) : a(x), b(y) {}
};
struct Segment {
Point p0;
Point p1;
- Segment (int x1, int y1, int x2, int y2) : p0(x1, y1), p1(x2, y2) {}
+ Segment(int x1, int y1, int x2, int y2) : p0(x1, y1), p1(x2, y2) {}
};
namespace boost {
namespace polygon {
template <>
-struct geometry_concept<Point> { typedef point_concept type; };
-
+struct geometry_concept<Point> {
+ typedef point_concept type;
+};
+
template <>
struct point_traits<Point> {
typedef int coordinate_type;
- static inline coordinate_type get(const Point& point, orientation_2d orient) {
+ static inline coordinate_type get(
+ const Point& point, orientation_2d orient) {
return (orient == HORIZONTAL) ? point.a : point.b;
}
};
template <>
-struct geometry_concept<Segment> { typedef segment_concept type; };
+struct geometry_concept<Segment> {
+ typedef segment_concept type;
+};
template <>
struct segment_traits<Segment> {
typedef int coordinate_type;
typedef Point point_type;
-
+
static inline point_type get(const Segment& segment, direction_1d dir) {
return dir.to_int() ? segment.p1 : segment.p0;
}
@@ -86,13 +92,13 @@
}
// Traversing Voronoi edges using vertex iterator.
-// As opposite to the above two functions this one will not iterate through edges
-// without finite endpoints and will iterate only once through edges with single
-// finite endpoint.
+// As opposite to the above two functions this one will not iterate through
+// edges without finite endpoints and will iterate only once through edges
+// with single finite endpoint.
int iterate_primary_edges3(const voronoi_diagram<double> &vd) {
int result = 0;
- for (voronoi_diagram<double>::const_vertex_iterator it = vd.vertices().begin();
- it != vd.vertices().end(); ++it) {
+ for (voronoi_diagram<double>::const_vertex_iterator it =
+ vd.vertices().begin(); it != vd.vertices().end(); ++it) {
const voronoi_diagram<double>::vertex_type& vertex = *it;
const voronoi_diagram<double>::edge_type* edge = vertex.incident_edge();
// This is convenient way to iterate edges around Voronoi vertex.
@@ -116,21 +122,26 @@
// Construction of the Voronoi Diagram.
voronoi_diagram<double> vd;
- construct_voronoi(points.begin(), points.end(), segments.begin(), segments.end(), &vd);
+ construct_voronoi(points.begin(), points.end(),
+ segments.begin(), segments.end(),
+ &vd);
// Traversing Voronoi Graph.
{
printf("Traversing Voronoi graph.\n");
- printf("Number of visited primary edges using edge iterator: %d\n", iterate_primary_edges1(vd));
- printf("Number of visited primary edges using cell iterator: %d\n", iterate_primary_edges2(vd));
- printf("Number of visited primary edges using vertex iterator: %d\n", iterate_primary_edges3(vd));
+ printf("Number of visited primary edges using edge iterator: %d\n",
+ iterate_primary_edges1(vd));
+ printf("Number of visited primary edges using cell iterator: %d\n",
+ iterate_primary_edges2(vd));
+ printf("Number of visited primary edges using vertex iterator: %d\n",
+ iterate_primary_edges3(vd));
printf("\n");
}
- // Using color member of the Voronoi primitives to store the average number of edges
- // around each cell (including secondary edges).
+ // Using color member of the Voronoi primitives to store the average number
+ // of edges around each cell (including secondary edges).
{
- printf("Number of edges (including secondary edges) around the Voronoi cells:\n");
+ printf("Number of edges (including secondary) around the Voronoi cells:\n");
for (voronoi_diagram<double>::const_edge_iterator it = vd.edges().begin();
it != vd.edges().end(); ++it) {
std::size_t cnt = it->cell()->color();
@@ -142,6 +153,6 @@
}
printf("\n");
printf("\n");
- }
+ }
return 0;
}
Modified: trunk/libs/polygon/example/voronoi_visual_utils.hpp
==============================================================================
--- trunk/libs/polygon/example/voronoi_visual_utils.hpp (original)
+++ trunk/libs/polygon/example/voronoi_visual_utils.hpp 2012-09-07 18:20:10 EDT (Fri, 07 Sep 2012)
@@ -18,13 +18,12 @@
#include <boost/polygon/segment_concept.hpp>
#include <boost/polygon/rectangle_concept.hpp>
-namespace boost{
-namespace polygon{
-
+namespace boost {
+namespace polygon {
// Utilities class, that contains set of routines handful for visualization.
template <typename CT>
class voronoi_visual_utils {
-public:
+ public:
// Discretize parabolic Voronoi edge.
// Parabolic Voronoi edges are always formed by one point and one segment
// from the initial input set.
@@ -39,7 +38,7 @@
// InCT: coordinate type of the input geometries (usually integer).
// Point: point type, should model point concept.
// Segment: segment type, should model segment concept.
- //
+ //
// Important:
// discretization should contain both edge endpoints initially.
template <class InCT1, class InCT2,
@@ -133,7 +132,7 @@
discretization->back() = last_point;
}
-private:
+ private:
// Compute y(x) = ((x - a) * (x - a) + b * b) / (2 * b).
static CT parabola_y(CT x, CT a, CT b) {
return ((x - a) * (x - a) + b * b) / (b + b);
Modified: trunk/libs/polygon/example/voronoi_visualizer.cpp
==============================================================================
--- trunk/libs/polygon/example/voronoi_visualizer.cpp (original)
+++ trunk/libs/polygon/example/voronoi_visualizer.cpp 2012-09-07 18:20:10 EDT (Fri, 07 Sep 2012)
@@ -9,6 +9,7 @@
#include <cassert>
#include <iostream>
+#include <vector>
#include <QtOpenGL/QGLWidget>
#include <QtGui/QtGui>
@@ -23,8 +24,9 @@
class GLWidget : public QGLWidget {
Q_OBJECT
-public:
- GLWidget(QMainWindow* parent = NULL) :
+
+ public:
+ explicit GLWidget(QMainWindow* parent = NULL) :
QGLWidget(QGLFormat(QGL::SampleBuffers), parent),
primary_edges_only_(false),
internal_edges_only_(false) {
@@ -76,7 +78,7 @@
internal_edges_only_ ^= true;
}
-protected:
+ protected:
void initializeGL() {
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -99,11 +101,11 @@
glViewport((width - side) / 2, (height - side) / 2, side, side);
}
- void timerEvent(QTimerEvent*) {
+ void timerEvent(QTimerEvent* e) {
update();
}
-private:
+ private:
typedef double coordinate_type;
typedef point_data<double> point_type;
typedef segment_data<double> segment_type;
@@ -198,7 +200,9 @@
glLoadIdentity();
rect_type view_rect = brect_;
deconvolve(view_rect, shift_);
- glOrtho(xl(view_rect), xh(view_rect), yl(view_rect), yh(view_rect), -1.0, 1.0);
+ glOrtho(xl(view_rect), xh(view_rect),
+ yl(view_rect), yh(view_rect),
+ -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
}
@@ -284,7 +288,8 @@
}
}
- void clip_infinite_edge(const edge_type& edge, std::vector<point_type>* clipped_edge) {
+ void clip_infinite_edge(
+ const edge_type& edge, std::vector<point_type>* clipped_edge) {
const cell_type& cell1 = *edge.cell();
const cell_type& cell2 = *edge.twin()->cell();
point_type origin, direction;
@@ -315,20 +320,23 @@
}
}
coordinate_type side = xh(brect_) - xl(brect_);
- coordinate_type koef = side / (std::max)(fabs(direction.x()), fabs(direction.y()));
+ coordinate_type koef =
+ side / (std::max)(fabs(direction.x()), fabs(direction.y()));
if (edge.vertex0() == NULL) {
clipped_edge->push_back(point_type(
origin.x() - direction.x() * koef,
origin.y() - direction.y() * koef));
} else {
- clipped_edge->push_back(point_type(edge.vertex0()->x(), edge.vertex0()->y()));
+ clipped_edge->push_back(
+ point_type(edge.vertex0()->x(), edge.vertex0()->y()));
}
if (edge.vertex1() == NULL) {
clipped_edge->push_back(point_type(
origin.x() + direction.x() * koef,
origin.y() + direction.y() * koef));
} else {
- clipped_edge->push_back(point_type(edge.vertex1()->x(), edge.vertex1()->y()));
+ clipped_edge->push_back(
+ point_type(edge.vertex1()->x(), edge.vertex1()->y()));
}
}
@@ -378,7 +386,8 @@
class MainWindow : public QWidget {
Q_OBJECT
-public:
+
+ public:
MainWindow() {
glWidget_ = new GLWidget();
file_dir_ = QDir(QDir::currentPath(), tr("*.txt"));
@@ -394,7 +403,7 @@
layout()->setSizeConstraint(QLayout::SetFixedSize);
}
-private slots:
+ private slots:
void primary_edges_only() {
glWidget_->show_primary_edges_only();
}
@@ -431,7 +440,7 @@
}
}
-private:
+ private:
QGridLayout* create_file_layout() {
QGridLayout* file_layout = new QGridLayout;
Modified: trunk/libs/polygon/test/polygon_segment_test.cpp
==============================================================================
--- trunk/libs/polygon/test/polygon_segment_test.cpp (original)
+++ trunk/libs/polygon/test/polygon_segment_test.cpp 2012-09-07 18:20:10 EDT (Fri, 07 Sep 2012)
@@ -7,6 +7,9 @@
// See http://www.boost.org for updates, documentation, and revision history.
+#include <algorithm>
+#include <list>
+
#define BOOST_TEST_MODULE POLYGON_SEGMENT_TEST
#include <boost/mpl/list.hpp>
#include <boost/test/test_case_template.hpp>
@@ -48,7 +51,7 @@
}
BOOST_AUTO_TEST_CASE_TEMPLATE(segment_traits_test, T, test_types) {
- typedef point_data<T> point_type ;
+ typedef point_data<T> point_type;
typedef segment_data<T> segment_type;
point_type point1(1, 2);
@@ -74,7 +77,9 @@
namespace boost {
namespace polygon {
template <typename T>
- struct geometry_concept< Segment<T> > { typedef segment_concept type; };
+ struct geometry_concept< Segment<T> > {
+ typedef segment_concept type;
+ };
template <typename T>
struct segment_traits< Segment<T> > {
Modified: trunk/libs/polygon/test/voronoi_builder_test.cpp
==============================================================================
--- trunk/libs/polygon/test/voronoi_builder_test.cpp (original)
+++ trunk/libs/polygon/test/voronoi_builder_test.cpp 2012-09-07 18:20:10 EDT (Fri, 07 Sep 2012)
@@ -8,6 +8,9 @@
// See http://www.boost.org for updates, documentation, and revision history.
#include <ctime>
+#include <limits>
+#include <list>
+#include <vector>
#define BOOST_TEST_MODULE voronoi_builder_test
#include <boost/mpl/list.hpp>
@@ -16,8 +19,9 @@
#include <boost/polygon/polygon.hpp>
#include <boost/polygon/voronoi.hpp>
-using namespace boost::polygon;
#include "voronoi_test_helper.hpp"
+using boost::polygon::voronoi_builder;
+using boost::polygon::voronoi_diagram;
typedef boost::mpl::list<int> test_types;
typedef voronoi_diagram<double> vd_type;
Modified: trunk/libs/polygon/test/voronoi_ctypes_test.cpp
==============================================================================
--- trunk/libs/polygon/test/voronoi_ctypes_test.cpp (original)
+++ trunk/libs/polygon/test/voronoi_ctypes_test.cpp 2012-09-07 18:20:10 EDT (Fri, 07 Sep 2012)
@@ -8,6 +8,7 @@
// See http://www.boost.org for updates, documentation, and revision history.
#include <ctime>
+#include <vector>
#define BOOST_TEST_MODULE voronoi_ctypes_test
#include <boost/mpl/list.hpp>
@@ -67,7 +68,7 @@
BOOST_AUTO_TEST_CASE(extended_exponent_fpt_test2) {
boost::mt19937_64 gen(static_cast<uint32>(time(NULL)));
fpt64 a = 0.0;
- efpt64 eea(a);
+ efpt64 eea(a);
for (int i = 0; i < 1000; ++i) {
fpt64 b = to_fpt(static_cast<int64>(gen()));
if (b == 0.0)
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-09-07 18:20:10 EDT (Fri, 07 Sep 2012)
@@ -7,6 +7,7 @@
// See http://www.boost.org for updates, documentation, and revision history.
+#include <limits>
#include <map>
#define BOOST_TEST_MODULE voronoi_predicates_test
@@ -338,7 +339,7 @@
BOOST_AUTO_TEST_CASE(node_comparison_test6) {
key_type node(site_type(1, 1).sorted_index(1), site_type(0, 0).sorted_index(0));
- key_type nodes [] = {
+ key_type nodes[] = {
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)),
Modified: trunk/libs/polygon/test/voronoi_robust_fpt_test.cpp
==============================================================================
--- trunk/libs/polygon/test/voronoi_robust_fpt_test.cpp (original)
+++ trunk/libs/polygon/test/voronoi_robust_fpt_test.cpp 2012-09-07 18:20:10 EDT (Fri, 07 Sep 2012)
@@ -9,6 +9,7 @@
#include <cmath>
#include <ctime>
+#include <vector>
#define BOOST_TEST_MODULE voronoi_robust_fpt_test
#include <boost/mpl/list.hpp>
@@ -17,7 +18,19 @@
#include <boost/polygon/detail/voronoi_ctypes.hpp>
#include <boost/polygon/detail/voronoi_robust_fpt.hpp>
-using namespace boost::polygon::detail;
+using boost::polygon::detail::int32;
+using boost::polygon::detail::uint32;
+using boost::polygon::detail::int64;
+using boost::polygon::detail::fpt64;
+using boost::polygon::detail::efpt64;
+using boost::polygon::detail::extended_int;
+using boost::polygon::detail::extended_exponent_fpt;
+using boost::polygon::detail::robust_fpt;
+using boost::polygon::detail::robust_dif;
+using boost::polygon::detail::robust_sqrt_expr;
+using boost::polygon::detail::type_converter_fpt;
+using boost::polygon::detail::type_converter_efpt;
+using boost::polygon::detail::ulp_comparison;
typedef robust_fpt<double> rfpt_type;
typedef type_converter_fpt to_fpt_type;
@@ -291,7 +304,7 @@
template <typename _int, typename _fpt>
class sqrt_expr_tester {
-public:
+ public:
static const std::size_t MX_SQRTS = 4;
bool run() {
@@ -325,7 +338,7 @@
return ret_val;
}
-private:
+ private:
robust_sqrt_expr<_int, _fpt, to_efpt_type> sqrt_expr_;
ulp_comparison<fpt64> ulp_cmp;
_int A[MX_SQRTS];
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-09-07 18:20:10 EDT (Fri, 07 Sep 2012)
@@ -7,8 +7,10 @@
// See http://www.boost.org for updates, documentation, and revision history.
-#define BOOST_TEST_MODULE voronoi_structures_test
+#include <functional>
+#include <vector>
+#define BOOST_TEST_MODULE voronoi_structures_test
#include <boost/test/test_case_template.hpp>
#include <boost/polygon/detail/voronoi_structures.hpp>
using namespace boost::polygon::detail;
@@ -61,7 +63,7 @@
BOOST_CHECK(s.is_segment());
BOOST_CHECK(!s.is_inverse());
BOOST_CHECK(s.source_category() == SOURCE_CATEGORY_INITIAL_SEGMENT);
-
+
s.inverse();
BOOST_CHECK(s.x1(true) == 1 && s.x0() == 1);
BOOST_CHECK(s.y1(true) == 2 && s.y0() == 2);
Modified: trunk/libs/polygon/test/voronoi_test_helper.hpp
==============================================================================
--- trunk/libs/polygon/test/voronoi_test_helper.hpp (original)
+++ trunk/libs/polygon/test/voronoi_test_helper.hpp 2012-09-07 18:20:10 EDT (Fri, 07 Sep 2012)
@@ -1,4 +1,4 @@
-// Boost.Polygon library voronoi_test_helper.hpp file
+// Boost.Polygon library voronoi_test_helper.hpp file
// Copyright Andrii Sydorchuk 2010-2011.
// Distributed under the Boost Software License, Version 1.0.
@@ -10,11 +10,13 @@
#ifndef VORONOI_TEST_HELPER
#define VORONOI_TEST_HELPER
+#include <algorithm>
#include <iostream>
#include <iterator>
#include <fstream>
#include <map>
#include <vector>
+#include <utility>
#include <boost/polygon/polygon.hpp>
using namespace boost::polygon;
@@ -28,7 +30,8 @@
};
template <typename VERTEX>
-kOrientation get_orientation(const VERTEX& v1, const VERTEX& v2, const VERTEX& v3) {
+kOrientation get_orientation(
+ const VERTEX& v1, const VERTEX& v2, const VERTEX& v3) {
typename VERTEX::coordinate_type lhs = (v2.x() - v1.x()) * (v3.y() - v2.y());
typename VERTEX::coordinate_type rhs = (v2.y() - v1.y()) * (v3.x() - v2.x());
if (lhs == rhs) {
@@ -57,12 +60,14 @@
if (edge->vertex0() != NULL &&
edge->vertex1() != NULL &&
edge->next()->vertex1() != NULL) {
- if (get_orientation(*edge->vertex0(), *edge->vertex1(), *edge->next()->vertex1()) != LEFT) {
+ if (get_orientation(*edge->vertex0(),
+ *edge->vertex1(),
+ *edge->next()->vertex1()) != LEFT) {
return false;
}
}
edge = edge->next();
- } while(edge != cell_it->incident_edge());
+ } while (edge != cell_it->incident_edge());
}
return true;
}
@@ -82,7 +87,9 @@
return false;
}
if (edge->vertex1() != NULL && next_edge->vertex1() != NULL &&
- get_orientation(*edge->vertex1(), *edge->vertex0(), *next_edge->vertex1()) == LEFT) {
+ get_orientation(*edge->vertex1(),
+ *edge->vertex0(),
+ *next_edge->vertex1()) == LEFT) {
return false;
}
edge = edge->rot_next();
@@ -94,7 +101,7 @@
template <typename VERTEX>
struct cmp {
bool operator()(const VERTEX& v1, const VERTEX& v2) const {
- if (v1.x() != v2.x())
+ if (v1.x() != v2.x())
return v1.x() < v2.x();
return v1.y() < v2.y();
}
@@ -121,7 +128,8 @@
}
template <typename Point2D>
-bool intersection_check(const std::map< Point2D, std::vector<Point2D>, cmp<Point2D> > &edge_map) {
+bool intersection_check(
+ const std::map< Point2D, std::vector<Point2D>, cmp<Point2D> > &edge_map) {
// Iterate over map of edges and check if there are any intersections.
// All the edges are stored by the low x value. That's why we iterate
// left to right checking for intersections between all pairs of edges
@@ -129,7 +137,7 @@
// Complexity. Approximately N*sqrt(N). Worst case N^2.
typedef Point2D point_type;
typedef typename point_type::coordinate_type coordinate_type;
- typedef typename std::map< point_type, std::vector<point_type>, cmp<Point2D> >::const_iterator
+ typedef typename std::map<point_type, std::vector<point_type>, cmp<Point2D> >::const_iterator
edge_map_iterator;
typedef typename std::vector<point_type>::size_type size_type;
edge_map_iterator edge_map_it1, edge_map_it2, edge_map_it_bound;
@@ -152,8 +160,8 @@
const point_type &point4 = edge_map_it2->second[j];
coordinate_type min_y2 = (std::min)(point3.y(), point4.y());
coordinate_type max_y2 = (std::max)(point3.y(), point4.y());
-
- // In most cases it is enought to make
+
+ // In most cases it is enought to make
// simple intersection check in the y dimension.
if (!(max_y1 > min_y2 && max_y2 > min_y1))
continue;
@@ -192,7 +200,8 @@
}
template <typename PointIterator>
-void save_points(PointIterator first, PointIterator last, const char* file_name) {
+void save_points(
+ PointIterator first, PointIterator last, const char* file_name) {
std::ofstream ofs(file_name);
ofs << std::distance(first, last) << std::endl;
for (PointIterator it = first; it != last; ++it) {
@@ -202,7 +211,8 @@
}
template <typename SegmentIterator>
-void save_segments(SegmentIterator first, SegmentIterator last, const char* file_name) {
+void save_segments(
+ SegmentIterator first, SegmentIterator last, const char* file_name) {
std::ofstream ofs(file_name);
ofs << std::distance(first, last) << std::endl;
for (SegmentIterator it = first; it != last; ++it) {
@@ -222,14 +232,16 @@
std::vector<std::pair<half_edge, segment_id> > half_edges_out;
segment_id id = 0;
half_edges.reserve(data.size());
- for (typename std::vector< segment_data<T> >::iterator it = data.begin(); it != data.end(); ++it) {
+ for (typename std::vector< segment_data<T> >::iterator it = data.begin();
+ it != data.end(); ++it) {
Point l = it->low();
Point h = it->high();
half_edges.push_back(std::make_pair(half_edge(l, h), id++));
}
half_edges_out.reserve(half_edges.size());
- //apparently no need to pre-sort data when calling validate_scan
- line_intersection<Unit>::validate_scan(half_edges_out, half_edges.begin(), half_edges.end());
+ // Apparently no need to pre-sort data when calling validate_scan.
+ line_intersection<Unit>::validate_scan(
+ half_edges_out, half_edges.begin(), half_edges.end());
std::vector< segment_data<T> > result;
result.reserve(half_edges_out.size());
for (std::size_t i = 0; i < half_edges_out.size(); ++i) {
@@ -243,7 +255,6 @@
}
std::swap(result, data);
}
-
-} // voronoi_test_helper
+} // voronoi_test_helper
#endif
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