updated boost on windows
This commit is contained in:
@@ -110,6 +110,26 @@ struct default_strategy<Box1, Box2, box_tag, box_tag, false>
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename Linear, typename Box>
|
||||
struct default_strategy<Linear, Box, segment_tag, box_tag, false>
|
||||
: strategy::distance::services::default_strategy
|
||||
<
|
||||
segment_tag, box_tag,
|
||||
typename point_type<Linear>::type,
|
||||
typename point_type<Box>::type
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename Linear, typename Box>
|
||||
struct default_strategy<Linear, Box, linear_tag, box_tag, false>
|
||||
: strategy::distance::services::default_strategy
|
||||
<
|
||||
segment_tag, box_tag,
|
||||
typename point_type<Linear>::type,
|
||||
typename point_type<Box>::type
|
||||
>
|
||||
{};
|
||||
|
||||
|
||||
|
||||
// Helper metafunction for default point-segment strategy retrieval
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2014.
|
||||
// Modifications copyright (c) 2014, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2014, 2018.
|
||||
// Modifications copyright (c) 2014-2018, 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
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
@@ -25,6 +26,7 @@
|
||||
#include <boost/geometry/algorithms/detail/distance/multipoint_to_geometry.hpp>
|
||||
#include <boost/geometry/algorithms/detail/distance/linear_to_linear.hpp>
|
||||
#include <boost/geometry/algorithms/detail/distance/linear_or_areal_to_areal.hpp>
|
||||
#include <boost/geometry/algorithms/detail/distance/linear_to_box.hpp>
|
||||
#include <boost/geometry/algorithms/detail/distance/geometry_to_segment_or_box.hpp>
|
||||
#include <boost/geometry/algorithms/detail/distance/segment_to_segment.hpp>
|
||||
#include <boost/geometry/algorithms/detail/distance/segment_to_box.hpp>
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
// Copyright (c) 2014 Samuel Debionne, Grenoble, France.
|
||||
|
||||
// This file was modified by Oracle on 2014.
|
||||
// Modifications copyright (c) 2014, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2014, 2018.
|
||||
// Modifications copyright (c) 2014-2018, 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
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
@@ -94,9 +95,10 @@ struct distance
|
||||
namespace resolve_strategy
|
||||
{
|
||||
|
||||
template <typename Strategy>
|
||||
struct distance
|
||||
{
|
||||
template <typename Geometry1, typename Geometry2, typename Strategy>
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
static inline typename distance_result<Geometry1, Geometry2, Strategy>::type
|
||||
apply(Geometry1 const& geometry1,
|
||||
Geometry2 const& geometry2,
|
||||
@@ -107,7 +109,11 @@ struct distance
|
||||
Geometry1, Geometry2, Strategy
|
||||
>::apply(geometry1, geometry2, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct distance<default_strategy>
|
||||
{
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
static inline
|
||||
typename distance_result<Geometry1, Geometry2, default_strategy>::type
|
||||
@@ -143,8 +149,10 @@ struct distance
|
||||
Geometry2 const& geometry2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return
|
||||
resolve_strategy::distance::apply(geometry1, geometry2, strategy);
|
||||
return resolve_strategy::distance
|
||||
<
|
||||
Strategy
|
||||
>::apply(geometry1, geometry2, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -320,10 +328,10 @@ struct distance
|
||||
|
||||
|
||||
/*!
|
||||
\brief \brief_calc2{distance} \brief_strategy
|
||||
\brief Calculate the distance between two geometries \brief_strategy
|
||||
\ingroup distance
|
||||
\details
|
||||
\details \details_calc{area}. \brief_strategy. \details_strategy_reasons
|
||||
\details The free function distance calculates the distance between two geometries \brief_strategy. \details_strategy_reasons
|
||||
|
||||
\tparam Geometry1 \tparam_geometry
|
||||
\tparam Geometry2 \tparam_geometry
|
||||
@@ -376,9 +384,10 @@ distance(Geometry1 const& geometry1,
|
||||
|
||||
|
||||
/*!
|
||||
\brief \brief_calc2{distance}
|
||||
\brief Calculate the distance between two geometries.
|
||||
\ingroup distance
|
||||
\details The default strategy is used, corresponding to the coordinate system of the geometries
|
||||
\details The free function distance calculates the distance between two geometries. \details_default_strategy
|
||||
|
||||
\tparam Geometry1 \tparam_geometry
|
||||
\tparam Geometry2 \tparam_geometry
|
||||
\param geometry1 \param_geometry
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#include <boost/geometry/algorithms/detail/distance/linear_to_linear.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
@@ -61,7 +60,6 @@ struct linear_to_areal
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Areal1, typename Areal2, typename Strategy>
|
||||
struct areal_to_areal
|
||||
{
|
||||
@@ -110,7 +108,6 @@ struct distance
|
||||
>
|
||||
{};
|
||||
|
||||
|
||||
template <typename Areal, typename Linear, typename Strategy>
|
||||
struct distance
|
||||
<
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2018, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, 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_LINEAR_TO_BOX_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_LINEAR_TO_BOX_HPP
|
||||
|
||||
#include <boost/geometry/core/point_type.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/intersects.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace distance
|
||||
{
|
||||
|
||||
template <typename Linear, typename Box, typename Strategy>
|
||||
struct linear_to_box
|
||||
{
|
||||
typedef typename strategy::distance::services::return_type
|
||||
<
|
||||
Strategy,
|
||||
typename point_type<Linear>::type,
|
||||
typename point_type<Box>::type
|
||||
>::type return_type;
|
||||
|
||||
template <typename Iterator>
|
||||
static inline return_type apply(Box const& box,
|
||||
Iterator begin,
|
||||
Iterator end,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
bool first = true;
|
||||
return_type d_min(0);
|
||||
for (Iterator it = begin; it != end; ++it, first = false)
|
||||
{
|
||||
typedef typename std::iterator_traits<Iterator>::value_type
|
||||
Segment;
|
||||
|
||||
return_type d = dispatch::distance<Segment, Box, Strategy>
|
||||
::apply(*it, box, strategy);
|
||||
|
||||
if ( first || d < d_min )
|
||||
{
|
||||
d_min = d;
|
||||
}
|
||||
}
|
||||
return d_min;
|
||||
}
|
||||
|
||||
static inline return_type apply(Linear const& linear,
|
||||
Box const& box,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
if ( geometry::intersects(linear, box) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return apply(box,
|
||||
geometry::segments_begin(linear),
|
||||
geometry::segments_end(linear),
|
||||
strategy);
|
||||
}
|
||||
|
||||
|
||||
static inline return_type apply(Box const& box,
|
||||
Linear const& linear,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return apply(linear, box, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace detail::distance
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch
|
||||
{
|
||||
|
||||
template <typename Linear, typename Box, typename Strategy>
|
||||
struct distance
|
||||
<
|
||||
Linear, Box, Strategy,
|
||||
linear_tag, box_tag,
|
||||
strategy_tag_distance_segment_box, false
|
||||
>
|
||||
: detail::distance::linear_to_box
|
||||
<
|
||||
Linear, Box, Strategy
|
||||
>
|
||||
{};
|
||||
|
||||
|
||||
template <typename Areal, typename Box, typename Strategy>
|
||||
struct distance
|
||||
<
|
||||
Areal, Box, Strategy,
|
||||
areal_tag, box_tag,
|
||||
strategy_tag_distance_segment_box, false
|
||||
>
|
||||
: detail::distance::linear_to_box
|
||||
<
|
||||
Areal, Box, Strategy
|
||||
>
|
||||
{};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_LINEAR_TO_BOX_HPP
|
||||
@@ -193,6 +193,7 @@ struct distance
|
||||
>
|
||||
{};
|
||||
|
||||
|
||||
template <typename MultiPoint, typename Linear, typename Strategy>
|
||||
struct distance
|
||||
<
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2014.
|
||||
// Modifications copyright (c) 2014, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2014, 2019.
|
||||
// Modifications copyright (c) 2014-2019, 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
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
@@ -39,13 +40,12 @@
|
||||
#include <boost/geometry/strategies/tags.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/assign.hpp>
|
||||
#include <boost/geometry/algorithms/covered_by.hpp>
|
||||
#include <boost/geometry/algorithms/within.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/closest_feature/geometry_to_range.hpp>
|
||||
#include <boost/geometry/algorithms/detail/closest_feature/point_to_range.hpp>
|
||||
#include <boost/geometry/algorithms/detail/distance/is_comparable.hpp>
|
||||
#include <boost/geometry/algorithms/detail/distance/iterator_selector.hpp>
|
||||
#include <boost/geometry/algorithms/detail/within/point_in_geometry.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/dispatch/distance.hpp>
|
||||
|
||||
@@ -160,7 +160,8 @@ struct point_to_ring
|
||||
Ring const& ring,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
if (geometry::within(point, ring))
|
||||
// TODO: pass strategy
|
||||
if (within::within_point_geometry(point, ring))
|
||||
{
|
||||
return return_type(0);
|
||||
}
|
||||
@@ -204,7 +205,8 @@ private:
|
||||
{
|
||||
for (InteriorRingIterator it = first; it != last; ++it)
|
||||
{
|
||||
if (geometry::within(point, *it))
|
||||
// TODO: pass strategy
|
||||
if (within::within_point_geometry(point, *it))
|
||||
{
|
||||
// the point is inside a polygon hole, so its distance
|
||||
// to the polygon its distance to the polygon's
|
||||
@@ -233,7 +235,8 @@ public:
|
||||
Polygon const& polygon,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
if (!geometry::covered_by(point, exterior_ring(polygon)))
|
||||
// TODO: pass strategy
|
||||
if (! within::covered_by_point_geometry(point, exterior_ring(polygon)))
|
||||
{
|
||||
// the point is outside the exterior ring, so its distance
|
||||
// to the polygon is its distance to the polygon's exterior ring
|
||||
@@ -330,7 +333,8 @@ struct point_to_multigeometry<Point, MultiPolygon, Strategy, true>
|
||||
MultiPolygon const& multipolygon,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
if (geometry::covered_by(point, multipolygon))
|
||||
// TODO: pass strategy
|
||||
if (within::covered_by_point_geometry(point, multipolygon))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -391,7 +395,7 @@ struct distance
|
||||
template <typename Point, typename Polygon, typename Strategy>
|
||||
struct distance
|
||||
<
|
||||
Point, Polygon, Strategy, point_tag, polygon_tag,
|
||||
Point, Polygon, Strategy, point_tag, polygon_tag,
|
||||
strategy_tag_distance_point_segment, false
|
||||
> : detail::distance::point_to_polygon
|
||||
<
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2014, 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
|
||||
@@ -27,26 +29,26 @@
|
||||
#include <boost/geometry/core/point_type.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/util/calculation_type.hpp>
|
||||
#include <boost/geometry/util/condition.hpp>
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/distance.hpp>
|
||||
#include <boost/geometry/strategies/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/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>
|
||||
#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>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
@@ -58,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,
|
||||
@@ -73,7 +89,7 @@ private:
|
||||
|
||||
typedef typename strategy::distance::services::comparable_type
|
||||
<
|
||||
Strategy
|
||||
typename Strategy::distance_ps_strategy::type
|
||||
>::type comparable_strategy;
|
||||
|
||||
typedef detail::closest_feature::point_to_point_range
|
||||
@@ -100,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;
|
||||
}
|
||||
@@ -108,8 +124,8 @@ public:
|
||||
comparable_strategy cstrategy =
|
||||
strategy::distance::services::get_comparable
|
||||
<
|
||||
Strategy
|
||||
>::apply(strategy);
|
||||
typename Strategy::distance_ps_strategy::type
|
||||
>::apply(strategy.get_distance_ps_strategy());
|
||||
|
||||
// get segment points
|
||||
segment_point p[2];
|
||||
@@ -159,12 +175,12 @@ public:
|
||||
|
||||
if (imin < 4)
|
||||
{
|
||||
return strategy.apply(box_points[imin], p[0], p[1]);
|
||||
return strategy.get_distance_ps_strategy().apply(box_points[imin], p[0], p[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int bimin = imin - 4;
|
||||
return strategy.apply(p[bimin],
|
||||
return strategy.get_distance_ps_strategy().apply(p[bimin],
|
||||
*bit_min[bimin].first,
|
||||
*bit_min[bimin].second);
|
||||
}
|
||||
@@ -215,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;
|
||||
}
|
||||
@@ -280,8 +296,7 @@ template
|
||||
typename ReturnType,
|
||||
typename SegmentPoint,
|
||||
typename BoxPoint,
|
||||
typename PPStrategy,
|
||||
typename PSStrategy
|
||||
typename SBStrategy
|
||||
>
|
||||
class segment_to_box_2D
|
||||
{
|
||||
@@ -340,10 +355,9 @@ private:
|
||||
SegmentPoint const& p1,
|
||||
BoxPoint const& bottom_right,
|
||||
BoxPoint const& top_right,
|
||||
PPStrategy const& pp_strategy,
|
||||
PSStrategy const& ps_strategy)
|
||||
SBStrategy const& sb_strategy)
|
||||
{
|
||||
boost::ignore_unused(pp_strategy, ps_strategy);
|
||||
boost::ignore_unused(sb_strategy);
|
||||
|
||||
// the implementation below is written for non-negative slope
|
||||
// segments
|
||||
@@ -355,22 +369,29 @@ private:
|
||||
|
||||
LessEqual less_equal;
|
||||
|
||||
if (less_equal(geometry::get<1>(top_right), geometry::get<1>(p0)))
|
||||
typename SBStrategy::distance_ps_strategy::type ps_strategy =
|
||||
sb_strategy.get_distance_ps_strategy();
|
||||
|
||||
if (less_equal(geometry::get<1>(bottom_right), geometry::get<1>(p0)))
|
||||
{
|
||||
// closest box point is the top-right corner
|
||||
return cast::apply(pp_strategy.apply(p0, top_right));
|
||||
}
|
||||
else if (less_equal(geometry::get<1>(bottom_right),
|
||||
geometry::get<1>(p0)))
|
||||
{
|
||||
// distance is realized between p0 and right-most
|
||||
// segment of box
|
||||
ReturnType diff = cast::apply(geometry::get<0>(p0))
|
||||
- cast::apply(geometry::get<0>(bottom_right));
|
||||
return strategy::distance::services::result_from_distance
|
||||
<
|
||||
PSStrategy, BoxPoint, SegmentPoint
|
||||
>::apply(ps_strategy, math::abs(diff));
|
||||
//if p0 is in box's band
|
||||
if (less_equal(geometry::get<1>(p0), geometry::get<1>(top_right)))
|
||||
{
|
||||
// segment & crosses band (TODO:merge with box-box dist)
|
||||
if (math::equals(geometry::get<0>(p0), geometry::get<0>(p1)))
|
||||
{
|
||||
SegmentPoint high = geometry::get<1>(p1) > geometry::get<1>(p0) ? p1 : p0;
|
||||
if (less_equal(geometry::get<1>(high), geometry::get<1>(top_right)))
|
||||
{
|
||||
return cast::apply(ps_strategy.apply(high, bottom_right, top_right));
|
||||
}
|
||||
return cast::apply(ps_strategy.apply(top_right, p0, p1));
|
||||
}
|
||||
return cast::apply(ps_strategy.apply(p0, bottom_right, top_right));
|
||||
}
|
||||
// distance is realized between the top-right
|
||||
// corner of the box and the segment
|
||||
return cast::apply(ps_strategy.apply(top_right, p0, p1));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -381,45 +402,55 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// it is assumed here that p0 lies above the box (so the
|
||||
// entire segment lies above the box)
|
||||
|
||||
template <typename LessEqual>
|
||||
struct above_of_box
|
||||
{
|
||||
|
||||
static inline ReturnType apply(SegmentPoint const& p0,
|
||||
SegmentPoint const& p1,
|
||||
BoxPoint const& top_left,
|
||||
PSStrategy const& ps_strategy)
|
||||
SBStrategy const& sb_strategy)
|
||||
{
|
||||
boost::ignore_unused(ps_strategy);
|
||||
|
||||
// the segment lies above the box
|
||||
boost::ignore_unused(sb_strategy);
|
||||
return apply(p0, p1, p0, top_left, sb_strategy);
|
||||
}
|
||||
|
||||
static inline ReturnType apply(SegmentPoint const& p0,
|
||||
SegmentPoint const& p1,
|
||||
SegmentPoint const& p_max,
|
||||
BoxPoint const& top_left,
|
||||
SBStrategy const& sb_strategy)
|
||||
{
|
||||
boost::ignore_unused(sb_strategy);
|
||||
typedef cast_to_result<ReturnType> cast;
|
||||
|
||||
LessEqual less_equal;
|
||||
|
||||
// p0 is above the upper segment of the box
|
||||
// (and inside its band)
|
||||
if (less_equal(geometry::get<0>(top_left), geometry::get<0>(p0)))
|
||||
// p0 is above the upper segment of the box (and inside its band)
|
||||
// then compute the vertical (i.e. meridian for spherical) distance
|
||||
if (less_equal(geometry::get<0>(top_left), geometry::get<0>(p_max)))
|
||||
{
|
||||
ReturnType diff = cast::apply(geometry::get<1>(p0))
|
||||
- cast::apply(geometry::get<1>(top_left));
|
||||
ReturnType diff =
|
||||
sb_strategy.get_distance_ps_strategy().vertical_or_meridian(
|
||||
geometry::get_as_radian<1>(p_max),
|
||||
geometry::get_as_radian<1>(top_left));
|
||||
|
||||
return strategy::distance::services::result_from_distance
|
||||
<
|
||||
PSStrategy, SegmentPoint, BoxPoint
|
||||
>::apply(ps_strategy, math::abs(diff));
|
||||
SBStrategy, SegmentPoint, BoxPoint
|
||||
>::apply(sb_strategy, math::abs(diff));
|
||||
}
|
||||
|
||||
// p0 is to the left of the box, but p1 is above the box
|
||||
// in this case the distance is realized between the
|
||||
// top-left corner of the box and the segment
|
||||
return cast::apply(ps_strategy.apply(top_left, p0, p1));
|
||||
return cast::apply(sb_strategy.get_distance_ps_strategy().
|
||||
apply(top_left, p0, p1));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename LessEqual>
|
||||
struct check_right_left_of_box
|
||||
{
|
||||
@@ -429,8 +460,7 @@ private:
|
||||
BoxPoint const& top_right,
|
||||
BoxPoint const& bottom_left,
|
||||
BoxPoint const& bottom_right,
|
||||
PPStrategy const& pp_strategy,
|
||||
PSStrategy const& ps_strategy,
|
||||
SBStrategy const& sb_strategy,
|
||||
ReturnType& result)
|
||||
{
|
||||
// p0 lies to the right of the box
|
||||
@@ -440,7 +470,7 @@ private:
|
||||
<
|
||||
LessEqual
|
||||
>::apply(p0, p1, bottom_right, top_right,
|
||||
pp_strategy, ps_strategy);
|
||||
sb_strategy);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -451,7 +481,7 @@ private:
|
||||
<
|
||||
typename other_compare<LessEqual>::type
|
||||
>::apply(p1, p0, top_left, bottom_left,
|
||||
pp_strategy, ps_strategy);
|
||||
sb_strategy);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -459,7 +489,6 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename LessEqual>
|
||||
struct check_above_below_of_box
|
||||
{
|
||||
@@ -469,26 +498,35 @@ private:
|
||||
BoxPoint const& top_right,
|
||||
BoxPoint const& bottom_left,
|
||||
BoxPoint const& bottom_right,
|
||||
PSStrategy const& ps_strategy,
|
||||
SBStrategy const& sb_strategy,
|
||||
ReturnType& result)
|
||||
{
|
||||
typedef compare_less_equal<ReturnType, false> GreaterEqual;
|
||||
|
||||
// the segment lies below the box
|
||||
if (geometry::get<1>(p1) < geometry::get<1>(bottom_left))
|
||||
{
|
||||
result = above_of_box
|
||||
<
|
||||
typename other_compare<LessEqual>::type
|
||||
>::apply(p1, p0, bottom_right, ps_strategy);
|
||||
result = sb_strategy.template segment_below_of_box
|
||||
<
|
||||
LessEqual,
|
||||
ReturnType
|
||||
>(p0, p1,
|
||||
top_left, top_right,
|
||||
bottom_left, bottom_right);
|
||||
return true;
|
||||
}
|
||||
|
||||
// the segment lies above the box
|
||||
if (geometry::get<1>(p0) > geometry::get<1>(top_right))
|
||||
{
|
||||
result = above_of_box
|
||||
<
|
||||
LessEqual
|
||||
>::apply(p0, p1, top_left, ps_strategy);
|
||||
result = (std::min)(above_of_box
|
||||
<
|
||||
LessEqual
|
||||
>::apply(p0, p1, top_left, sb_strategy),
|
||||
above_of_box
|
||||
<
|
||||
GreaterEqual
|
||||
>::apply(p1, p0, top_right, sb_strategy));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -499,47 +537,30 @@ private:
|
||||
{
|
||||
static inline bool apply(SegmentPoint const& p0,
|
||||
SegmentPoint const& p1,
|
||||
BoxPoint const& bottom_left0,
|
||||
BoxPoint const& top_right0,
|
||||
BoxPoint const& bottom_left1,
|
||||
BoxPoint const& top_right1,
|
||||
BoxPoint const& corner1,
|
||||
BoxPoint const& corner2,
|
||||
PSStrategy const& ps_strategy,
|
||||
SBStrategy const& sb_strategy,
|
||||
ReturnType& result)
|
||||
{
|
||||
typedef typename geometry::strategy::side::services::default_strategy
|
||||
<
|
||||
typename geometry::cs_tag<SegmentPoint>::type
|
||||
>::type side;
|
||||
|
||||
typedef cast_to_result<ReturnType> cast;
|
||||
|
||||
ReturnType diff0 = cast::apply(geometry::get<0>(p1))
|
||||
- cast::apply(geometry::get<0>(p0));
|
||||
ReturnType t_min0 = cast::apply(geometry::get<0>(bottom_left0))
|
||||
- cast::apply(geometry::get<0>(p0));
|
||||
ReturnType t_max0 = cast::apply(geometry::get<0>(top_right0))
|
||||
- cast::apply(geometry::get<0>(p0));
|
||||
|
||||
ReturnType diff1 = cast::apply(geometry::get<1>(p1))
|
||||
- cast::apply(geometry::get<1>(p0));
|
||||
ReturnType t_min1 = cast::apply(geometry::get<1>(bottom_left1))
|
||||
- cast::apply(geometry::get<1>(p0));
|
||||
ReturnType t_max1 = cast::apply(geometry::get<1>(top_right1))
|
||||
- cast::apply(geometry::get<1>(p0));
|
||||
- cast::apply(geometry::get<1>(p0));
|
||||
|
||||
if (diff1 < 0)
|
||||
{
|
||||
diff1 = -diff1;
|
||||
t_min1 = -t_min1;
|
||||
t_max1 = -t_max1;
|
||||
}
|
||||
typename SBStrategy::distance_ps_strategy::type ps_strategy =
|
||||
sb_strategy.get_distance_ps_strategy();
|
||||
|
||||
// t_min0 > t_max1
|
||||
if (t_min0 * diff1 > t_max1 * diff0)
|
||||
int sign = diff1 < 0 ? -1 : 1;
|
||||
if (side::apply(p0, p1, corner1) * sign < 0)
|
||||
{
|
||||
result = cast::apply(ps_strategy.apply(corner1, p0, p1));
|
||||
return true;
|
||||
}
|
||||
|
||||
// t_max0 < t_min1
|
||||
if (t_max0 * diff1 < t_min1 * diff0)
|
||||
if (side::apply(p0, p1, corner2) * sign > 0)
|
||||
{
|
||||
result = cast::apply(ps_strategy.apply(corner2, p0, p1));
|
||||
return true;
|
||||
@@ -555,8 +576,7 @@ private:
|
||||
BoxPoint const& top_right,
|
||||
BoxPoint const& bottom_left,
|
||||
BoxPoint const& bottom_right,
|
||||
PPStrategy const& pp_strategy,
|
||||
PSStrategy const& ps_strategy)
|
||||
SBStrategy const& sb_strategy)
|
||||
{
|
||||
typedef compare_less_equal<ReturnType, true> less_equal;
|
||||
|
||||
@@ -576,7 +596,7 @@ private:
|
||||
less_equal
|
||||
>::apply(p0, p1,
|
||||
top_left, top_right, bottom_left, bottom_right,
|
||||
pp_strategy, ps_strategy, result))
|
||||
sb_strategy, result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
@@ -586,16 +606,14 @@ private:
|
||||
less_equal
|
||||
>::apply(p0, p1,
|
||||
top_left, top_right, bottom_left, bottom_right,
|
||||
ps_strategy, result))
|
||||
sb_strategy, result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if (check_generic_position::apply(p0, p1,
|
||||
bottom_left, top_right,
|
||||
bottom_left, top_right,
|
||||
top_left, bottom_right,
|
||||
ps_strategy, result))
|
||||
sb_strategy, result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
@@ -612,8 +630,7 @@ private:
|
||||
BoxPoint const& top_right,
|
||||
BoxPoint const& bottom_left,
|
||||
BoxPoint const& bottom_right,
|
||||
PPStrategy const& pp_strategy,
|
||||
PSStrategy const& ps_strategy)
|
||||
SBStrategy const& sb_strategy)
|
||||
{
|
||||
typedef compare_less_equal<ReturnType, false> greater_equal;
|
||||
|
||||
@@ -630,7 +647,7 @@ private:
|
||||
greater_equal
|
||||
>::apply(p0, p1,
|
||||
bottom_left, bottom_right, top_left, top_right,
|
||||
pp_strategy, ps_strategy, result))
|
||||
sb_strategy, result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
@@ -640,16 +657,14 @@ private:
|
||||
greater_equal
|
||||
>::apply(p1, p0,
|
||||
top_right, top_left, bottom_right, bottom_left,
|
||||
ps_strategy, result))
|
||||
sb_strategy, result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if (check_generic_position::apply(p0, p1,
|
||||
bottom_left, top_right,
|
||||
top_right, bottom_left,
|
||||
bottom_left, top_right,
|
||||
ps_strategy, result))
|
||||
sb_strategy, result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
@@ -665,8 +680,7 @@ public:
|
||||
BoxPoint const& top_right,
|
||||
BoxPoint const& bottom_left,
|
||||
BoxPoint const& bottom_right,
|
||||
PPStrategy const& pp_strategy,
|
||||
PSStrategy const& ps_strategy)
|
||||
SBStrategy const& sb_strategy)
|
||||
{
|
||||
BOOST_GEOMETRY_ASSERT( geometry::less<SegmentPoint>()(p0, p1)
|
||||
|| geometry::has_nan_coordinate(p0)
|
||||
@@ -678,27 +692,43 @@ public:
|
||||
return negative_slope_segment(p0, p1,
|
||||
top_left, top_right,
|
||||
bottom_left, bottom_right,
|
||||
pp_strategy, ps_strategy);
|
||||
sb_strategy);
|
||||
}
|
||||
|
||||
return non_negative_slope_segment(p0, p1,
|
||||
top_left, top_right,
|
||||
bottom_left, bottom_right,
|
||||
pp_strategy, ps_strategy);
|
||||
sb_strategy);
|
||||
}
|
||||
|
||||
template <typename LessEqual>
|
||||
static inline ReturnType call_above_of_box(SegmentPoint const& p0,
|
||||
SegmentPoint const& p1,
|
||||
SegmentPoint const& p_max,
|
||||
BoxPoint const& top_left,
|
||||
SBStrategy const& sb_strategy)
|
||||
{
|
||||
return above_of_box<LessEqual>::apply(p0, p1, p_max, top_left, sb_strategy);
|
||||
}
|
||||
|
||||
template <typename LessEqual>
|
||||
static inline ReturnType call_above_of_box(SegmentPoint const& p0,
|
||||
SegmentPoint const& p1,
|
||||
BoxPoint const& top_left,
|
||||
SBStrategy const& sb_strategy)
|
||||
{
|
||||
return above_of_box<LessEqual>::apply(p0, p1, top_left, sb_strategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//=========================================================================
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Segment,
|
||||
typename Box,
|
||||
typename std::size_t Dimension,
|
||||
typename PPStrategy,
|
||||
typename PSStrategy
|
||||
typename SBStrategy
|
||||
>
|
||||
class segment_to_box
|
||||
: not_implemented<Segment, Box>
|
||||
@@ -709,10 +739,9 @@ template
|
||||
<
|
||||
typename Segment,
|
||||
typename Box,
|
||||
typename PPStrategy,
|
||||
typename PSStrategy
|
||||
typename SBStrategy
|
||||
>
|
||||
class segment_to_box<Segment, Box, 2, PPStrategy, PSStrategy>
|
||||
class segment_to_box<Segment, Box, 2, SBStrategy>
|
||||
{
|
||||
private:
|
||||
typedef typename point_type<Segment>::type segment_point;
|
||||
@@ -720,12 +749,7 @@ private:
|
||||
|
||||
typedef typename strategy::distance::services::comparable_type
|
||||
<
|
||||
PPStrategy
|
||||
>::type pp_comparable_strategy;
|
||||
|
||||
typedef typename strategy::distance::services::comparable_type
|
||||
<
|
||||
PSStrategy
|
||||
SBStrategy
|
||||
>::type ps_comparable_strategy;
|
||||
|
||||
typedef typename strategy::distance::services::return_type
|
||||
@@ -735,26 +759,26 @@ private:
|
||||
public:
|
||||
typedef typename strategy::distance::services::return_type
|
||||
<
|
||||
PSStrategy, segment_point, box_point
|
||||
SBStrategy, segment_point, box_point
|
||||
>::type return_type;
|
||||
|
||||
static inline return_type apply(Segment const& segment,
|
||||
Box const& box,
|
||||
PPStrategy const& pp_strategy,
|
||||
PSStrategy const& ps_strategy)
|
||||
SBStrategy const& sb_strategy)
|
||||
{
|
||||
segment_point p[2];
|
||||
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_
|
||||
<
|
||||
boost::is_same
|
||||
<
|
||||
ps_comparable_strategy,
|
||||
PSStrategy
|
||||
SBStrategy
|
||||
>,
|
||||
typename strategy::distance::services::comparable_type
|
||||
<
|
||||
@@ -781,6 +805,10 @@ public:
|
||||
detail::assign_box_corners(box, bottom_left, bottom_right,
|
||||
top_left, top_right);
|
||||
|
||||
SBStrategy::mirror(p[0], p[1],
|
||||
bottom_left, bottom_right,
|
||||
top_left, top_right);
|
||||
|
||||
if (geometry::less<segment_point>()(p[0], p[1]))
|
||||
{
|
||||
return segment_to_box_2D
|
||||
@@ -788,12 +816,10 @@ public:
|
||||
return_type,
|
||||
segment_point,
|
||||
box_point,
|
||||
PPStrategy,
|
||||
PSStrategy
|
||||
SBStrategy
|
||||
>::apply(p[0], p[1],
|
||||
top_left, top_right, bottom_left, bottom_right,
|
||||
pp_strategy,
|
||||
ps_strategy);
|
||||
sb_strategy);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -802,12 +828,10 @@ public:
|
||||
return_type,
|
||||
segment_point,
|
||||
box_point,
|
||||
PPStrategy,
|
||||
PSStrategy
|
||||
SBStrategy
|
||||
>::apply(p[1], p[0],
|
||||
top_left, top_right, bottom_left, bottom_right,
|
||||
pp_strategy,
|
||||
ps_strategy);
|
||||
sb_strategy);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -826,7 +850,7 @@ template <typename Segment, typename Box, typename Strategy>
|
||||
struct distance
|
||||
<
|
||||
Segment, Box, Strategy, segment_tag, box_tag,
|
||||
strategy_tag_distance_point_segment, false
|
||||
strategy_tag_distance_segment_box, false
|
||||
>
|
||||
{
|
||||
typedef typename strategy::distance::services::return_type
|
||||
@@ -843,40 +867,13 @@ struct distance
|
||||
{
|
||||
assert_dimension_equal<Segment, Box>();
|
||||
|
||||
typedef typename boost::mpl::if_
|
||||
<
|
||||
boost::is_same
|
||||
<
|
||||
typename strategy::distance::services::comparable_type
|
||||
<
|
||||
Strategy
|
||||
>::type,
|
||||
Strategy
|
||||
>,
|
||||
typename strategy::distance::services::comparable_type
|
||||
<
|
||||
typename detail::distance::default_strategy
|
||||
<
|
||||
typename point_type<Segment>::type,
|
||||
typename point_type<Box>::type
|
||||
>::type
|
||||
>::type,
|
||||
typename detail::distance::default_strategy
|
||||
<
|
||||
typename point_type<Segment>::type,
|
||||
typename point_type<Box>::type
|
||||
>::type
|
||||
>::type pp_strategy_type;
|
||||
|
||||
|
||||
return detail::distance::segment_to_box
|
||||
<
|
||||
Segment,
|
||||
Box,
|
||||
dimension<Segment>::value,
|
||||
pp_strategy_type,
|
||||
Strategy
|
||||
>::apply(segment, box, pp_strategy_type(), strategy);
|
||||
>::apply(segment, box, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user