Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84852 - in trunk/boost/geometry/extensions/nsphere: . algorithms core strategies/cartesian
From: adam.wulkiewicz_at_[hidden]
Date: 2013-06-20 17:39:12


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

Log:
[geometry][extensions]: added cartesian strategy point_in_nsphere, added base classes of nsphere_tag, used strategy in within(pt,sph).

Added:
   trunk/boost/geometry/extensions/nsphere/strategies/cartesian/point_in_nsphere.hpp (contents, props changed)
Text files modified:
   trunk/boost/geometry/extensions/nsphere/algorithms/within.hpp | 6 +
   trunk/boost/geometry/extensions/nsphere/core/tags.hpp | 2
   trunk/boost/geometry/extensions/nsphere/nsphere.hpp | 1
   trunk/boost/geometry/extensions/nsphere/strategies/cartesian/point_in_nsphere.hpp | 121 ++++++++++++++++++++++++++++++++++++++++
   4 files changed, 127 insertions(+), 3 deletions(-)

Modified: trunk/boost/geometry/extensions/nsphere/algorithms/within.hpp
==============================================================================
--- trunk/boost/geometry/extensions/nsphere/algorithms/within.hpp Thu Jun 20 17:32:42 2013 (r84851)
+++ trunk/boost/geometry/extensions/nsphere/algorithms/within.hpp 2013-06-20 17:39:12 EDT (Thu, 20 Jun 2013) (r84852)
@@ -151,9 +151,11 @@
 struct within<P, Circle, point_tag, nsphere_tag>
 {
     template <typename Strategy>
- static inline bool apply(P const& p, Circle const& c, Strategy const&)
+ static inline bool apply(P const& p, Circle const& c, Strategy const& strategy)
     {
- return detail::within::point_in_circle(p, c);
+ ::boost::ignore_unused_variable_warning(strategy);
+ return strategy.apply(p, c);
+ //return detail::within::point_in_circle(p, c);
     }
 };
 

Modified: trunk/boost/geometry/extensions/nsphere/core/tags.hpp
==============================================================================
--- trunk/boost/geometry/extensions/nsphere/core/tags.hpp Thu Jun 20 17:32:42 2013 (r84851)
+++ trunk/boost/geometry/extensions/nsphere/core/tags.hpp 2013-06-20 17:39:12 EDT (Thu, 20 Jun 2013) (r84852)
@@ -20,7 +20,7 @@
 
 
 /// Convenience 2D (circle) or 3D (sphere) n-sphere identifying tag
-struct nsphere_tag {};
+struct nsphere_tag : single_tag, areal_tag{};
 
 
 

Modified: trunk/boost/geometry/extensions/nsphere/nsphere.hpp
==============================================================================
--- trunk/boost/geometry/extensions/nsphere/nsphere.hpp Thu Jun 20 17:32:42 2013 (r84851)
+++ trunk/boost/geometry/extensions/nsphere/nsphere.hpp 2013-06-20 17:39:12 EDT (Thu, 20 Jun 2013) (r84852)
@@ -34,6 +34,7 @@
 #include <boost/geometry/extensions/nsphere/algorithms/num_points.hpp>
 #include <boost/geometry/extensions/nsphere/algorithms/disjoint.hpp>
 #include <boost/geometry/extensions/nsphere/strategies/cartesian/nsphere_in_box.hpp>
+#include <boost/geometry/extensions/nsphere/strategies/cartesian/point_in_nsphere.hpp>
 #include <boost/geometry/extensions/nsphere/algorithms/within.hpp>
 #include <boost/geometry/extensions/nsphere/algorithms/covered_by.hpp>
 #include <boost/geometry/extensions/nsphere/algorithms/expand.hpp>

Added: trunk/boost/geometry/extensions/nsphere/strategies/cartesian/point_in_nsphere.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/boost/geometry/extensions/nsphere/strategies/cartesian/point_in_nsphere.hpp 2013-06-20 17:39:12 EDT (Thu, 20 Jun 2013) (r84852)
@@ -0,0 +1,121 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+// Copyright (c) 2013 Adam Wulkiewicz, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// 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)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_STRATEGIES_CARTESIAN_POINT_IN_NSPHERE_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_STRATEGIES_CARTESIAN_POINT_IN_NSPHERE_HPP
+
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/strategies/covered_by.hpp>
+#include <boost/geometry/strategies/within.hpp>
+
+#include <boost/geometry/extensions/nsphere/views/center_view.hpp>
+
+namespace boost { namespace geometry { namespace strategy
+{
+
+namespace within
+{
+
+struct point_nsphere_within_comparable_distance
+{
+ template <typename ComparableDistance, typename Radius>
+ static inline bool apply(ComparableDistance const& ed_comp_dist
+ , Radius const& ing_radius)
+ {
+ return ed_comp_dist < ing_radius * ing_radius;
+ }
+};
+
+
+struct point_nsphere_covered_by_comparable_distance
+{
+ template <typename ComparableDistance, typename Radius>
+ static inline bool apply(ComparableDistance const& ed_comp_dist
+ , Radius const& ing_radius)
+ {
+ return ed_comp_dist <= ing_radius * ing_radius;
+ }
+};
+
+template
+<
+ typename Point,
+ typename NSphere,
+ typename SubStrategy = point_nsphere_within_comparable_distance
+>
+struct point_in_nsphere
+{
+ static inline bool apply(Point const& point, NSphere const& nsphere)
+ {
+ return SubStrategy::apply(
+ geometry::comparable_distance(point, center_view<NSphere const>(nsphere)),
+ get_radius<0>(nsphere));
+ }
+};
+
+
+} // namespace within
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+namespace within { namespace services
+{
+
+template <typename Point, typename NSphere>
+struct default_strategy
+ <
+ point_tag, nsphere_tag,
+ point_tag, areal_tag,
+ cartesian_tag, cartesian_tag,
+ Point, NSphere
+ >
+{
+ typedef within::point_in_nsphere<Point, NSphere, within::point_nsphere_within_comparable_distance> type;
+};
+
+
+}} // namespace within::services
+
+
+namespace covered_by { namespace services
+{
+
+
+template <typename Point, typename NSphere>
+struct default_strategy
+ <
+ point_tag, nsphere_tag,
+ point_tag, areal_tag,
+ cartesian_tag, cartesian_tag,
+ Point, NSphere
+ >
+{
+ typedef within::point_in_nsphere<Point, NSphere, within::point_nsphere_covered_by_comparable_distance> type;
+};
+
+
+}} // namespace covered_by::services
+
+
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+}}} // namespace boost::geometry::strategy
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_NSPHERE_STRATEGIES_CARTESIAN_NSPHERE_IN_BOX_HPP


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