Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84853 - in trunk/libs/geometry: extensions/test/nsphere index/example
From: adam.wulkiewicz_at_[hidden]
Date: 2013-06-20 17:42:23


Author: awulkiew
Date: 2013-06-20 17:42:23 EDT (Thu, 20 Jun 2013)
New Revision: 84853
URL: http://svn.boost.org/trac/boost/changeset/84853

Log:
[geometry]: [extensions] fixed/added tests for nsphere. [index] added nsphere to benchmark_experimental.cpp (for now commented out).

Added:
   trunk/libs/geometry/extensions/test/nsphere/nsphere_in_box.cpp (contents, props changed)
   trunk/libs/geometry/extensions/test/nsphere/point_in_nsphere.cpp (contents, props changed)
Text files modified:
   trunk/libs/geometry/extensions/test/nsphere/Jamfile.v2 | 3 +
   trunk/libs/geometry/extensions/test/nsphere/area.cpp | 9 ++---
   trunk/libs/geometry/extensions/test/nsphere/circle.cpp | 4 -
   trunk/libs/geometry/extensions/test/nsphere/nsphere_in_box.cpp | 63 ++++++++++++++++++++++++++++++++++++++++
   trunk/libs/geometry/extensions/test/nsphere/point_in_nsphere.cpp | 61 ++++++++++++++++++++++++++++++++++++++
   trunk/libs/geometry/extensions/test/nsphere/within.cpp | 8 +---
   trunk/libs/geometry/index/example/benchmark_experimental.cpp | 14 +++++++-
   7 files changed, 147 insertions(+), 15 deletions(-)

Modified: trunk/libs/geometry/extensions/test/nsphere/Jamfile.v2
==============================================================================
--- trunk/libs/geometry/extensions/test/nsphere/Jamfile.v2 Thu Jun 20 17:39:12 2013 (r84852)
+++ trunk/libs/geometry/extensions/test/nsphere/Jamfile.v2 2013-06-20 17:42:23 EDT (Thu, 20 Jun 2013) (r84853)
@@ -18,6 +18,9 @@
     [ run point_type.cpp ]
     [ run within.cpp ]
 
+ [ run nsphere_in_box.cpp ]
+ [ run point_in_nsphere.cpp ]
+
     [ run disjoint.cpp ]
     [ run index_content.cpp ]
     [ run index_margin.cpp ]

Modified: trunk/libs/geometry/extensions/test/nsphere/area.cpp
==============================================================================
--- trunk/libs/geometry/extensions/test/nsphere/area.cpp Thu Jun 20 17:39:12 2013 (r84852)
+++ trunk/libs/geometry/extensions/test/nsphere/area.cpp 2013-06-20 17:42:23 EDT (Thu, 20 Jun 2013) (r84853)
@@ -12,8 +12,7 @@
 #include <boost/geometry/geometries/geometries.hpp>
 #include <boost/geometry/strategies/strategies.hpp>
 
-#include <boost/geometry/extensions/nsphere/algorithms/area.hpp>
-#include <boost/geometry/extensions/nsphere/geometries/nsphere.hpp>
+#include <boost/geometry/extensions/nsphere/nsphere.hpp>
 
 
 template <typename P, typename T>
@@ -21,9 +20,9 @@
 {
     bg::model::nsphere<P, T> c;
 
- bg::set<0>(c.center(), 0);
- bg::set<1>(c.center(), 0);
- c.radius(2);
+ bg::set<0>(c, 0);
+ bg::set<1>(c, 0);
+ bg::set_radius<0>(c, 2);
 
     double d = bg::area(c);
     BOOST_CHECK_CLOSE(d, 4 * 3.1415926535897932384626433832795, 0.001);

Modified: trunk/libs/geometry/extensions/test/nsphere/circle.cpp
==============================================================================
--- trunk/libs/geometry/extensions/test/nsphere/circle.cpp Thu Jun 20 17:39:12 2013 (r84852)
+++ trunk/libs/geometry/extensions/test/nsphere/circle.cpp 2013-06-20 17:42:23 EDT (Thu, 20 Jun 2013) (r84853)
@@ -10,9 +10,7 @@
 
 #include <geometry_test_common.hpp>
 
-#include <boost/geometry/extensions/nsphere/core/access.hpp>
-#include <boost/geometry/extensions/nsphere/geometries/concepts/nsphere_concept.hpp>
-#include <boost/geometry/extensions/nsphere/geometries/nsphere.hpp>
+#include <boost/geometry/extensions/nsphere/nsphere.hpp>
 
 #include <boost/geometry/algorithms/detail/assign_values.hpp>
 #include <boost/geometry/core/cs.hpp>

Added: trunk/libs/geometry/extensions/test/nsphere/nsphere_in_box.cpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/libs/geometry/extensions/test/nsphere/nsphere_in_box.cpp 2013-06-20 17:42:23 EDT (Thu, 20 Jun 2013) (r84853)
@@ -0,0 +1,63 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// Use, modification and distribution is subject to 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)
+
+#include <geometry_test_common.hpp>
+
+#include <boost/geometry/extensions/nsphere/nsphere.hpp>
+
+#include <boost/geometry/geometries/geometries.hpp>
+#include <boost/geometry/geometries/point_xy.hpp>
+
+#include <boost/geometry/strategies/strategies.hpp>
+
+#include <boost/geometry/io/wkt/read.hpp>
+
+typedef bg::model::d2::point_xy<double> point_type;
+typedef bg::model::nsphere<point_type, double> circle_type;
+typedef bg::model::box<point_type> box_type;
+
+template <typename Geometry>
+void test_circle(std::string const& wkt_geometry, bool expected_within, bool expected_covered_by)
+{
+ circle_type circle(point_type(1.0, 1.0), 3.0);
+ //bg::assign(circle, 1.0, 1.0, 3.0);
+
+ Geometry geometry;
+ bg::read_wkt(wkt_geometry, geometry);
+
+ bool detected = bg::within(circle, geometry);
+
+ BOOST_CHECK_MESSAGE(detected == expected_within,
+ "circle (1,1) with radius 3 within : " << wkt_geometry
+ << " -> Expected: " << expected_within
+ << " detected: " << detected);
+
+ detected = bg::covered_by(circle, geometry);
+
+ BOOST_CHECK_MESSAGE(detected == expected_covered_by,
+ "circle (1,1) with radius 3 covered_by : " << wkt_geometry
+ << " -> Expected: " << expected_covered_by
+ << " detected: " << detected);
+}
+
+void test_circles()
+{
+ test_circle<box_type>("BOX(1 1, 1.1 1.1)", false, false);
+ test_circle<box_type>("BOX(2 1, 4 4)", false, false);
+ test_circle<box_type>("BOX(-2 -2, 4 4)", false, true);
+ test_circle<box_type>("BOX(-2.1 -2.1, 4.1 4.1)", true, true);
+}
+
+
+int test_main( int , char* [] )
+{
+ test_circles();
+
+ return 0;
+}

Added: trunk/libs/geometry/extensions/test/nsphere/point_in_nsphere.cpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/libs/geometry/extensions/test/nsphere/point_in_nsphere.cpp 2013-06-20 17:42:23 EDT (Thu, 20 Jun 2013) (r84853)
@@ -0,0 +1,61 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// Use, modification and distribution is subject to 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)
+
+#include <geometry_test_common.hpp>
+
+#include <boost/geometry/extensions/nsphere/nsphere.hpp>
+
+#include <boost/geometry/geometries/geometries.hpp>
+#include <boost/geometry/geometries/point_xy.hpp>
+
+#include <boost/geometry/strategies/strategies.hpp>
+
+#include <boost/geometry/io/wkt/read.hpp>
+
+typedef bg::model::d2::point_xy<double> point_type;
+typedef bg::model::nsphere<point_type, double> circle_type;
+
+template <typename Geometry>
+void test_circle(std::string const& wkt_geometry, bool expected_within, bool expected_covered_by)
+{
+ circle_type circle(point_type(1.0, 1.0), 3.0);
+
+ Geometry geometry;
+ bg::read_wkt(wkt_geometry, geometry);
+
+ bool detected = bg::within(geometry, circle);
+
+ BOOST_CHECK_MESSAGE(detected == expected_within,
+ "circle (1,1) with radius 3 containing : " << wkt_geometry
+ << " -> Expected: " << expected_within
+ << " detected: " << detected);
+
+ detected = bg::covered_by(geometry, circle);
+
+ BOOST_CHECK_MESSAGE(detected == expected_covered_by,
+ "circle (1,1) with radius 3 covering : " << wkt_geometry
+ << " -> Expected: " << expected_covered_by
+ << " detected: " << detected);
+}
+
+void test_circles()
+{
+ test_circle<point_type>("POINT(1 1)", true, true);
+ test_circle<point_type>("POINT(1 4)", false, true);
+ test_circle<point_type>("POINT(4 1)", false, true);
+ test_circle<point_type>("POINT(4 4)", false, false);
+}
+
+
+int test_main( int , char* [] )
+{
+ test_circles();
+
+ return 0;
+}

Modified: trunk/libs/geometry/extensions/test/nsphere/within.cpp
==============================================================================
--- trunk/libs/geometry/extensions/test/nsphere/within.cpp Thu Jun 20 17:39:12 2013 (r84852)
+++ trunk/libs/geometry/extensions/test/nsphere/within.cpp 2013-06-20 17:42:23 EDT (Thu, 20 Jun 2013) (r84853)
@@ -22,12 +22,11 @@
 {
     typedef bg::model::nsphere<bg::model::d2::point_xy<double>, double> circle_type;
     circle_type circle;
- bg::assign(circle, 1.0, 1.0, 3.0);
+ bg::assign_values(circle, 1.0, 1.0, 3.0);
 
     Geometry geometry;
     bg::read_wkt(wkt_geometry, geometry);
 
- /* todo: fix
     bool detected = bg::within(geometry, circle);
 
     BOOST_CHECK_MESSAGE(detected == expected,
@@ -35,7 +34,6 @@
         << " in circle (1,1) with radius 3"
         << " -> Expected: " << expected
         << " detected: " << detected);
- */
 }
 
 
@@ -47,8 +45,8 @@
     test_circle<P>("POINT(2 1)", true);
     test_circle<P>("POINT(12 1)", false);
 
- test_circle<bg::model::linestring<P> >("LINESTRING(1 1,2 1,2 2)", true);
- test_circle<bg::model::linestring<P> >("LINESTRING(1 1,2 1,2 2,10 10)", false);
+ //test_circle<bg::model::linestring<P> >("LINESTRING(1 1,2 1,2 2)", true);
+ //test_circle<bg::model::linestring<P> >("LINESTRING(1 1,2 1,2 2,10 10)", false);
 }
 
 

Modified: trunk/libs/geometry/index/example/benchmark_experimental.cpp
==============================================================================
--- trunk/libs/geometry/index/example/benchmark_experimental.cpp Thu Jun 20 17:39:12 2013 (r84852)
+++ trunk/libs/geometry/index/example/benchmark_experimental.cpp 2013-06-20 17:42:23 EDT (Thu, 20 Jun 2013) (r84853)
@@ -45,6 +45,16 @@
     static inline P apply(float x, float y) { return P(x, y); }
 };
 
+//#include <boost/geometry/extensions/nsphere/nsphere.hpp>
+//typedef bg::model::nsphere<P, double> NS;
+//typedef NS V;
+//
+//template <>
+//struct generate_value<NS>
+//{
+// static inline NS apply(float x, float y) { return NS(P(x, y), 0.5); }
+//};
+
 template <typename I1, typename I2, typename O>
 void mycopy(I1 first, I2 last, O o)
 {
@@ -101,9 +111,9 @@
         std::cout << "randomized\n";
     }
 
- //typedef bgi::rtree<V, bgi::linear<16, 4> > RT;
+ typedef bgi::rtree<V, bgi::linear<16, 4> > RT;
     //typedef bgi::rtree<V, bgi::quadratic<16, 4> > RT;
- typedef bgi::rtree<V, bgi::rstar<16, 4> > RT;
+ //typedef bgi::rtree<V, bgi::rstar<16, 4> > RT;
 
     std::cout << "sizeof rtree: " << sizeof(RT) << std::endl;
 


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