summaryrefslogtreecommitdiff
path: root/boost/geometry/algorithms/detail/is_simple
diff options
context:
space:
mode:
Diffstat (limited to 'boost/geometry/algorithms/detail/is_simple')
-rw-r--r--boost/geometry/algorithms/detail/is_simple/always_simple.hpp6
-rw-r--r--boost/geometry/algorithms/detail/is_simple/areal.hpp18
-rw-r--r--boost/geometry/algorithms/detail/is_simple/interface.hpp77
-rw-r--r--boost/geometry/algorithms/detail/is_simple/linear.hpp31
-rw-r--r--boost/geometry/algorithms/detail/is_simple/multipoint.hpp6
5 files changed, 117 insertions, 21 deletions
diff --git a/boost/geometry/algorithms/detail/is_simple/always_simple.hpp b/boost/geometry/algorithms/detail/is_simple/always_simple.hpp
index 91e2ef76bd..5cec5e1924 100644
--- a/boost/geometry/algorithms/detail/is_simple/always_simple.hpp
+++ b/boost/geometry/algorithms/detail/is_simple/always_simple.hpp
@@ -1,8 +1,9 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
-// Copyright (c) 2014, Oracle and/or its affiliates.
+// Copyright (c) 2014-2017, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
@@ -27,7 +28,8 @@ namespace detail { namespace is_simple
template <typename Geometry>
struct always_simple
{
- static inline bool apply(Geometry const&)
+ template <typename Strategy>
+ static inline bool apply(Geometry const&, Strategy const&)
{
return true;
}
diff --git a/boost/geometry/algorithms/detail/is_simple/areal.hpp b/boost/geometry/algorithms/detail/is_simple/areal.hpp
index a2322e4831..d4d6db9bce 100644
--- a/boost/geometry/algorithms/detail/is_simple/areal.hpp
+++ b/boost/geometry/algorithms/detail/is_simple/areal.hpp
@@ -1,8 +1,9 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
-// Copyright (c) 2014-2015, Oracle and/or its affiliates.
+// Copyright (c) 2014-2017, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
@@ -37,6 +38,12 @@ namespace detail { namespace is_simple
template <typename Ring>
struct is_simple_ring
{
+ template <typename Strategy>
+ static inline bool apply(Ring const& ring, Strategy const&)
+ {
+ return apply(ring);
+ }
+
static inline bool apply(Ring const& ring)
{
simplicity_failure_policy policy;
@@ -69,6 +76,12 @@ private:
}
public:
+ template <typename Strategy>
+ static inline bool apply(Polygon const& polygon, Strategy const&)
+ {
+ return apply(polygon);
+ }
+
static inline bool apply(Polygon const& polygon)
{
return
@@ -119,7 +132,8 @@ struct is_simple<Polygon, polygon_tag>
template <typename MultiPolygon>
struct is_simple<MultiPolygon, multi_polygon_tag>
{
- static inline bool apply(MultiPolygon const& multipolygon)
+ template <typename Strategy>
+ static inline bool apply(MultiPolygon const& multipolygon, Strategy const&)
{
return
detail::check_iterator_range
diff --git a/boost/geometry/algorithms/detail/is_simple/interface.hpp b/boost/geometry/algorithms/detail/is_simple/interface.hpp
index 6d425232b0..af0127dc75 100644
--- a/boost/geometry/algorithms/detail/is_simple/interface.hpp
+++ b/boost/geometry/algorithms/detail/is_simple/interface.hpp
@@ -1,8 +1,9 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
-// Copyright (c) 2014, Oracle and/or its affiliates.
+// Copyright (c) 2014-2017, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
@@ -17,46 +18,106 @@
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/algorithms/dispatch/is_simple.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/strategies/default_strategy.hpp>
+#include <boost/geometry/strategies/intersection.hpp>
namespace boost { namespace geometry
{
+namespace resolve_strategy
+{
+
+struct is_simple
+{
+ template <typename Geometry, typename Strategy>
+ static inline bool apply(Geometry const& geometry,
+ Strategy const& strategy)
+ {
+ return dispatch::is_simple<Geometry>::apply(geometry, strategy);
+ }
+
+ template <typename Geometry>
+ static inline bool apply(Geometry const& geometry,
+ default_strategy)
+ {
+ // NOTE: Currently the strategy is only used for Linear geometries
+ typedef typename strategy::intersection::services::default_strategy
+ <
+ typename cs_tag<Geometry>::type
+ >::type strategy_type;
+
+ return dispatch::is_simple<Geometry>::apply(geometry, strategy_type());
+ }
+};
-namespace resolve_variant {
+} // namespace resolve_strategy
+
+namespace resolve_variant
+{
template <typename Geometry>
struct is_simple
{
- static inline bool apply(Geometry const& geometry)
+ template <typename Strategy>
+ static inline bool apply(Geometry const& geometry, Strategy const& strategy)
{
concepts::check<Geometry const>();
- return dispatch::is_simple<Geometry>::apply(geometry);
+
+ return resolve_strategy::is_simple::apply(geometry, strategy);
}
};
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
struct is_simple<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
{
+ template <typename Strategy>
struct visitor : boost::static_visitor<bool>
{
+ Strategy const& m_strategy;
+
+ visitor(Strategy const& strategy)
+ : m_strategy(strategy)
+ {}
+
template <typename Geometry>
bool operator()(Geometry const& geometry) const
{
- return is_simple<Geometry>::apply(geometry);
+ return is_simple<Geometry>::apply(geometry, m_strategy);
}
};
+ template <typename Strategy>
static inline bool
- apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry)
+ apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry,
+ Strategy const& strategy)
{
- return boost::apply_visitor(visitor(), geometry);
+ return boost::apply_visitor(visitor<Strategy>(strategy), geometry);
}
};
} // namespace resolve_variant
+/*!
+\brief \brief_check{is simple}
+\ingroup is_simple
+\tparam Geometry \tparam_geometry
+\tparam Strategy \tparam_strategy{Is_simple}
+\param geometry \param_geometry
+\param strategy \param_strategy{is_simple}
+\return \return_check{is simple}
+
+\qbk{distinguish,with strategy}
+\qbk{[include reference/algorithms/is_simple.qbk]}
+*/
+template <typename Geometry, typename Strategy>
+inline bool is_simple(Geometry const& geometry, Strategy const& strategy)
+{
+ return resolve_variant::is_simple<Geometry>::apply(geometry, strategy);
+}
+
/*!
\brief \brief_check{is simple}
@@ -70,7 +131,7 @@ struct is_simple<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
template <typename Geometry>
inline bool is_simple(Geometry const& geometry)
{
- return resolve_variant::is_simple<Geometry>::apply(geometry);
+ return resolve_variant::is_simple<Geometry>::apply(geometry, default_strategy());
}
diff --git a/boost/geometry/algorithms/detail/is_simple/linear.hpp b/boost/geometry/algorithms/detail/is_simple/linear.hpp
index 16d7b3a803..52b9d9d1c8 100644
--- a/boost/geometry/algorithms/detail/is_simple/linear.hpp
+++ b/boost/geometry/algorithms/detail/is_simple/linear.hpp
@@ -1,8 +1,9 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
-// Copyright (c) 2014-2015, Oracle and/or its affiliates.
+// Copyright (c) 2014-2017, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
@@ -48,6 +49,8 @@
#include <boost/geometry/algorithms/dispatch/is_simple.hpp>
+#include <boost/geometry/strategies/intersection.hpp>
+
namespace boost { namespace geometry
{
@@ -186,8 +189,8 @@ private:
};
-template <typename Linear>
-inline bool has_self_intersections(Linear const& linear)
+template <typename Linear, typename Strategy>
+inline bool has_self_intersections(Linear const& linear, Strategy const& strategy)
{
typedef typename point_type<Linear>::type point_type;
@@ -218,6 +221,7 @@ inline bool has_self_intersections(Linear const& linear)
<
turn_policy
>::apply(linear,
+ strategy,
detail::no_rescale_policy(),
turns,
interrupt_policy);
@@ -243,8 +247,19 @@ struct is_simple_linestring
&& ! detail::is_valid::has_spikes
<
Linestring, closed
- >::apply(linestring, policy)
- && ! (CheckSelfIntersections && has_self_intersections(linestring));
+ >::apply(linestring, policy);
+ }
+};
+
+template <typename Linestring>
+struct is_simple_linestring<Linestring, true>
+{
+ template <typename Strategy>
+ static inline bool apply(Linestring const& linestring,
+ Strategy const& strategy)
+ {
+ return is_simple_linestring<Linestring, false>::apply(linestring)
+ && ! has_self_intersections(linestring, strategy);
}
};
@@ -252,7 +267,9 @@ struct is_simple_linestring
template <typename MultiLinestring>
struct is_simple_multilinestring
{
- static inline bool apply(MultiLinestring const& multilinestring)
+ template <typename Strategy>
+ static inline bool apply(MultiLinestring const& multilinestring,
+ Strategy const& strategy)
{
// check each of the linestrings for simplicity
// but do not compute self-intersections yet; these will be
@@ -272,7 +289,7 @@ struct is_simple_multilinestring
return false;
}
- return ! has_self_intersections(multilinestring);
+ return ! has_self_intersections(multilinestring, strategy);
}
};
diff --git a/boost/geometry/algorithms/detail/is_simple/multipoint.hpp b/boost/geometry/algorithms/detail/is_simple/multipoint.hpp
index f9f43d1cdb..61f0bc9130 100644
--- a/boost/geometry/algorithms/detail/is_simple/multipoint.hpp
+++ b/boost/geometry/algorithms/detail/is_simple/multipoint.hpp
@@ -1,8 +1,9 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
-// Copyright (c) 2014-2015, Oracle and/or its affiliates.
+// Copyright (c) 2014-2017, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
@@ -38,7 +39,8 @@ namespace detail { namespace is_simple
template <typename MultiPoint>
struct is_simple_multipoint
{
- static inline bool apply(MultiPoint const& multipoint)
+ template <typename Strategy>
+ static inline bool apply(MultiPoint const& multipoint, Strategy const&)
{
if (boost::empty(multipoint))
{