diff --git a/benchmark/voronoi_benchmark.cpp b/benchmark/voronoi_benchmark.cpp index 98539dc..8b8328c 100644 --- a/benchmark/voronoi_benchmark.cpp +++ b/benchmark/voronoi_benchmark.cpp @@ -7,9 +7,11 @@ // See http://www.boost.org for updates, documentation, and revision history. +#include #include #include #include +#include #include #include @@ -21,7 +23,9 @@ #include #include -using namespace boost::polygon; +using boost::polygon::point_data; +using boost::polygon::segment_data; +using boost::polygon::voronoi_diagram; typedef boost::mpl::list test_types; const char *BENCHMARK_FILE = "voronoi_benchmark.txt"; @@ -98,10 +102,12 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(benchmark_test_points, T, test_types) { } 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 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(benchmark_test_segments, T, test_types) { } 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(); diff --git a/benchmark/voronoi_benchmark_points.cpp b/benchmark/voronoi_benchmark_points.cpp index af37e7b..15e123f 100644 --- a/benchmark/voronoi_benchmark_points.cpp +++ b/benchmark/voronoi_benchmark_points.cpp @@ -7,11 +7,13 @@ // See http://www.boost.org for updates, documentation, and revision history. +#include #include #include #include #include #include +#include #include #include @@ -44,7 +46,8 @@ const int RANDOM_SEED = 27; 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 @@ void run_shull_test() { // 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; diff --git a/benchmark/voronoi_benchmark_segments.cpp b/benchmark/voronoi_benchmark_segments.cpp index ab35d66..3964022 100644 --- a/benchmark/voronoi_benchmark_segments.cpp +++ b/benchmark/voronoi_benchmark_segments.cpp @@ -7,11 +7,13 @@ // See http://www.boost.org for updates, documentation, and revision history. +#include #include #include #include #include #include +#include #include #include @@ -47,7 +49,8 @@ const int RANDOM_SEED = 27; 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 @@ void clean_segment_set(std::vector &data) { std::vector > half_edges_out; segment_id id = 0; half_edges.reserve(data.size()); - for (std::vector::iterator it = data.begin(); it != data.end(); ++it) { + for (std::vector::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::validate_scan( half_edges_out, half_edges.begin(), half_edges.end()); std::vector result; diff --git a/example/voronoi_advanced_tutorial.cpp b/example/voronoi_advanced_tutorial.cpp index 5e0217a..5fdc2b5 100644 --- a/example/voronoi_advanced_tutorial.cpp +++ b/example/voronoi_advanced_tutorial.cpp @@ -22,14 +22,15 @@ typedef long double fpt80; #include #include -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 @@ struct my_ulp_comparison { 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 @@ struct my_voronoi_ctype_traits { const unsigned int GENERATED_POINTS = 100; const boost::int64_t MAX = 0x1000000000000LL; -#include -int main () { +int main() { boost::mt19937_64 gen(std::time(0)); boost::random::uniform_int_distribution distr(-MAX, MAX-1); voronoi_builder vb; diff --git a/example/voronoi_basic_tutorial.cpp b/example/voronoi_basic_tutorial.cpp index 69ebccd..cb145a4 100644 --- a/example/voronoi_basic_tutorial.cpp +++ b/example/voronoi_basic_tutorial.cpp @@ -11,45 +11,51 @@ #include #include -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 { typedef point_concept type; }; - +struct geometry_concept { + typedef point_concept type; +}; + template <> struct point_traits { 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 { typedef segment_concept type; }; +struct geometry_concept { + typedef segment_concept type; +}; template <> struct segment_traits { 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 @@ int iterate_primary_edges2(const voronoi_diagram &vd) { } // 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 &vd) { int result = 0; - for (voronoi_diagram::const_vertex_iterator it = vd.vertices().begin(); - it != vd.vertices().end(); ++it) { + for (voronoi_diagram::const_vertex_iterator it = + vd.vertices().begin(); it != vd.vertices().end(); ++it) { const voronoi_diagram::vertex_type& vertex = *it; const voronoi_diagram::edge_type* edge = vertex.incident_edge(); // This is convenient way to iterate edges around Voronoi vertex. @@ -116,21 +122,26 @@ int main() { // Construction of the Voronoi Diagram. voronoi_diagram 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::const_edge_iterator it = vd.edges().begin(); it != vd.edges().end(); ++it) { std::size_t cnt = it->cell()->color(); @@ -142,6 +153,6 @@ int main() { } printf("\n"); printf("\n"); - } + } return 0; } diff --git a/example/voronoi_visual_utils.hpp b/example/voronoi_visual_utils.hpp index 3afc4d3..4ef2e9d 100644 --- a/example/voronoi_visual_utils.hpp +++ b/example/voronoi_visual_utils.hpp @@ -18,13 +18,12 @@ #include #include -namespace boost{ -namespace polygon{ - +namespace boost { +namespace polygon { // Utilities class, that contains set of routines handful for visualization. template 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 @@ public: // 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 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); diff --git a/example/voronoi_visualizer.cpp b/example/voronoi_visualizer.cpp index 86feeb5..1ed9cd3 100644 --- a/example/voronoi_visualizer.cpp +++ b/example/voronoi_visualizer.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -23,8 +24,9 @@ using namespace boost::polygon; 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 @@ public: 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 @@ protected: 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 point_type; typedef segment_data segment_type; @@ -198,7 +200,9 @@ private: 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 @@ private: } } - void clip_infinite_edge(const edge_type& edge, std::vector* clipped_edge) { + void clip_infinite_edge( + const edge_type& edge, std::vector* clipped_edge) { const cell_type& cell1 = *edge.cell(); const cell_type& cell2 = *edge.twin()->cell(); point_type origin, direction; @@ -315,20 +320,23 @@ private: } } 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 @@ private: class MainWindow : public QWidget { Q_OBJECT -public: + + public: MainWindow() { glWidget_ = new GLWidget(); file_dir_ = QDir(QDir::currentPath(), tr("*.txt")); @@ -394,7 +403,7 @@ public: layout()->setSizeConstraint(QLayout::SetFixedSize); } -private slots: + private slots: void primary_edges_only() { glWidget_->show_primary_edges_only(); } @@ -431,7 +440,7 @@ private slots: } } -private: + private: QGridLayout* create_file_layout() { QGridLayout* file_layout = new QGridLayout; diff --git a/test/polygon_segment_test.cpp b/test/polygon_segment_test.cpp index 0f6884d..665fe4a 100644 --- a/test/polygon_segment_test.cpp +++ b/test/polygon_segment_test.cpp @@ -7,6 +7,9 @@ // See http://www.boost.org for updates, documentation, and revision history. +#include +#include + #define BOOST_TEST_MODULE POLYGON_SEGMENT_TEST #include #include @@ -48,7 +51,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(segment_data_test, T, test_types) { } BOOST_AUTO_TEST_CASE_TEMPLATE(segment_traits_test, T, test_types) { - typedef point_data point_type ; + typedef point_data point_type; typedef segment_data segment_type; point_type point1(1, 2); @@ -74,7 +77,9 @@ struct Segment { namespace boost { namespace polygon { template - struct geometry_concept< Segment > { typedef segment_concept type; }; + struct geometry_concept< Segment > { + typedef segment_concept type; + }; template struct segment_traits< Segment > { diff --git a/test/voronoi_builder_test.cpp b/test/voronoi_builder_test.cpp index 8ec34b7..a7995fb 100644 --- a/test/voronoi_builder_test.cpp +++ b/test/voronoi_builder_test.cpp @@ -8,6 +8,9 @@ // See http://www.boost.org for updates, documentation, and revision history. #include +#include +#include +#include #define BOOST_TEST_MODULE voronoi_builder_test #include @@ -16,8 +19,9 @@ #include #include -using namespace boost::polygon; #include "voronoi_test_helper.hpp" +using boost::polygon::voronoi_builder; +using boost::polygon::voronoi_diagram; typedef boost::mpl::list test_types; typedef voronoi_diagram vd_type; diff --git a/test/voronoi_ctypes_test.cpp b/test/voronoi_ctypes_test.cpp index a0016dd..064f121 100644 --- a/test/voronoi_ctypes_test.cpp +++ b/test/voronoi_ctypes_test.cpp @@ -8,6 +8,7 @@ // See http://www.boost.org for updates, documentation, and revision history. #include +#include #define BOOST_TEST_MODULE voronoi_ctypes_test #include @@ -67,7 +68,7 @@ BOOST_AUTO_TEST_CASE(extended_exponent_fpt_test1) { BOOST_AUTO_TEST_CASE(extended_exponent_fpt_test2) { boost::mt19937_64 gen(static_cast(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(gen())); if (b == 0.0) diff --git a/test/voronoi_predicates_test.cpp b/test/voronoi_predicates_test.cpp index 99f0388..1675c2e 100644 --- a/test/voronoi_predicates_test.cpp +++ b/test/voronoi_predicates_test.cpp @@ -7,6 +7,7 @@ // See http://www.boost.org for updates, documentation, and revision history. +#include #include #define BOOST_TEST_MODULE voronoi_predicates_test @@ -338,7 +339,7 @@ BOOST_AUTO_TEST_CASE(node_comparison_test5) { 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)), diff --git a/test/voronoi_robust_fpt_test.cpp b/test/voronoi_robust_fpt_test.cpp index 3f8f4d9..5b98f88 100644 --- a/test/voronoi_robust_fpt_test.cpp +++ b/test/voronoi_robust_fpt_test.cpp @@ -9,6 +9,7 @@ #include #include +#include #define BOOST_TEST_MODULE voronoi_robust_fpt_test #include @@ -17,7 +18,19 @@ #include #include -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 rfpt_type; typedef type_converter_fpt to_fpt_type; @@ -291,7 +304,7 @@ BOOST_AUTO_TEST_CASE(robust_sqrt_expr_test8) { template class sqrt_expr_tester { -public: + public: static const std::size_t MX_SQRTS = 4; bool run() { @@ -325,7 +338,7 @@ public: return ret_val; } -private: + private: robust_sqrt_expr<_int, _fpt, to_efpt_type> sqrt_expr_; ulp_comparison ulp_cmp; _int A[MX_SQRTS]; diff --git a/test/voronoi_structures_test.cpp b/test/voronoi_structures_test.cpp index 9f9eb2b..5fe35db 100644 --- a/test/voronoi_structures_test.cpp +++ b/test/voronoi_structures_test.cpp @@ -7,8 +7,10 @@ // See http://www.boost.org for updates, documentation, and revision history. -#define BOOST_TEST_MODULE voronoi_structures_test +#include +#include +#define BOOST_TEST_MODULE voronoi_structures_test #include #include using namespace boost::polygon::detail; @@ -61,7 +63,7 @@ BOOST_AUTO_TEST_CASE(site_event_test2) { 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); diff --git a/test/voronoi_test_helper.hpp b/test/voronoi_test_helper.hpp index ca72ded..170aa0b 100644 --- a/test/voronoi_test_helper.hpp +++ b/test/voronoi_test_helper.hpp @@ -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 #include #include #include #include #include +#include #include using namespace boost::polygon; @@ -28,7 +30,8 @@ enum kOrientation { }; template -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 @@ bool verify_cell_convexity(const OUTPUT& output) { 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 @@ bool verify_incident_edges_ccw_order(const OUTPUT& output) { 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 @@ bool verify_incident_edges_ccw_order(const OUTPUT& output) { template 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 @@ bool verfiy_no_line_edge_intersections(const Output &output) { } template -bool intersection_check(const std::map< Point2D, std::vector, cmp > &edge_map) { +bool intersection_check( + const std::map< Point2D, std::vector, cmp > &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 @@ bool intersection_check(const std::map< Point2D, std::vector, cmp, cmp >::const_iterator + typedef typename std::map, cmp >::const_iterator edge_map_iterator; typedef typename std::vector::size_type size_type; edge_map_iterator edge_map_it1, edge_map_it2, edge_map_it_bound; @@ -152,8 +160,8 @@ bool intersection_check(const std::map< Point2D, std::vector, cmpsecond[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 @@ bool verify_output(const Output &output, kVerification mask) { } template -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 @@ void save_points(PointIterator first, PointIterator last, const char* file_name) } template -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 @@ void clean_segment_set(std::vector< segment_data >& data) { std::vector > half_edges_out; segment_id id = 0; half_edges.reserve(data.size()); - for (typename std::vector< segment_data >::iterator it = data.begin(); it != data.end(); ++it) { + for (typename std::vector< segment_data >::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::validate_scan(half_edges_out, half_edges.begin(), half_edges.end()); + // Apparently no need to pre-sort data when calling validate_scan. + line_intersection::validate_scan( + half_edges_out, half_edges.begin(), half_edges.end()); std::vector< segment_data > result; result.reserve(half_edges_out.size()); for (std::size_t i = 0; i < half_edges_out.size(); ++i) { @@ -243,7 +255,6 @@ void clean_segment_set(std::vector< segment_data >& data) { } std::swap(result, data); } - -} // voronoi_test_helper +} // voronoi_test_helper #endif