summaryrefslogtreecommitdiff
path: root/boost/geometry/algorithms/detail/distance/segment_to_box.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/geometry/algorithms/detail/distance/segment_to_box.hpp')
-rw-r--r--boost/geometry/algorithms/detail/distance/segment_to_box.hpp52
1 files changed, 35 insertions, 17 deletions
diff --git a/boost/geometry/algorithms/detail/distance/segment_to_box.hpp b/boost/geometry/algorithms/detail/distance/segment_to_box.hpp
index bfe52c7b1b..d88a6699c8 100644
--- a/boost/geometry/algorithms/detail/distance/segment_to_box.hpp
+++ b/boost/geometry/algorithms/detail/distance/segment_to_box.hpp
@@ -1,15 +1,17 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
-// Copyright (c) 2014-2018 Oracle and/or its affiliates.
+// Copyright (c) 2014-2019 Oracle and/or its affiliates.
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// 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
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SEGMENT_TO_BOX_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SEGMENT_TO_BOX_HPP
+
#include <cstddef>
#include <functional>
@@ -27,26 +29,27 @@
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
+#include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
+#include <boost/geometry/algorithms/detail/closest_feature/point_to_range.hpp>
+#include <boost/geometry/algorithms/detail/disjoint/segment_box.hpp>
+#include <boost/geometry/algorithms/detail/distance/default_strategies.hpp>
+#include <boost/geometry/algorithms/detail/distance/is_comparable.hpp>
+#include <boost/geometry/algorithms/detail/equals/point_point.hpp>
+#include <boost/geometry/algorithms/dispatch/distance.hpp>
+#include <boost/geometry/algorithms/not_implemented.hpp>
+
+#include <boost/geometry/policies/compare.hpp>
+
#include <boost/geometry/util/calculation_type.hpp>
#include <boost/geometry/util/condition.hpp>
+#include <boost/geometry/util/has_nan_coordinate.hpp>
#include <boost/geometry/util/math.hpp>
+#include <boost/geometry/strategies/disjoint.hpp>
#include <boost/geometry/strategies/distance.hpp>
#include <boost/geometry/strategies/tags.hpp>
-#include <boost/geometry/policies/compare.hpp>
-
-#include <boost/geometry/algorithms/equals.hpp>
-#include <boost/geometry/algorithms/intersects.hpp>
-#include <boost/geometry/algorithms/not_implemented.hpp>
-
-#include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
-#include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
-#include <boost/geometry/algorithms/detail/distance/default_strategies.hpp>
-#include <boost/geometry/algorithms/detail/distance/is_comparable.hpp>
-
-#include <boost/geometry/algorithms/dispatch/distance.hpp>
-
namespace boost { namespace geometry
{
@@ -57,6 +60,20 @@ namespace detail { namespace distance
{
+// TODO: Take strategy
+template <typename Segment, typename Box>
+inline bool intersects_segment_box(Segment const& segment, Box const& box)
+{
+ typedef typename strategy::disjoint::services::default_strategy
+ <
+ Segment, Box
+ >::type strategy_type;
+
+ return ! detail::disjoint::disjoint_segment_box::apply(segment, box,
+ strategy_type());
+}
+
+
template
<
typename Segment,
@@ -99,7 +116,7 @@ public:
Strategy const& strategy,
bool check_intersection = true)
{
- if (check_intersection && geometry::intersects(segment, box))
+ if (check_intersection && intersects_segment_box(segment, box))
{
return 0;
}
@@ -214,7 +231,7 @@ public:
Strategy const& strategy,
bool check_intersection = true)
{
- if (check_intersection && geometry::intersects(segment, box))
+ if (check_intersection && intersects_segment_box(segment, box))
{
return 0;
}
@@ -753,7 +770,8 @@ public:
detail::assign_point_from_index<0>(segment, p[0]);
detail::assign_point_from_index<1>(segment, p[1]);
- if (geometry::equals(p[0], p[1]))
+ if (detail::equals::equals_point_point(p[0], p[1],
+ sb_strategy.get_equals_point_point_strategy()))
{
typedef typename boost::mpl::if_
<