diff options
Diffstat (limited to 'boost/geometry/strategies/cartesian')
-rw-r--r-- | boost/geometry/strategies/cartesian/area_surveyor.hpp | 5 | ||||
-rw-r--r-- | boost/geometry/strategies/cartesian/azimuth.hpp | 49 | ||||
-rw-r--r-- | boost/geometry/strategies/cartesian/box_in_box.hpp | 28 | ||||
-rw-r--r-- | boost/geometry/strategies/cartesian/disjoint_segment_box.hpp | 320 | ||||
-rw-r--r-- | boost/geometry/strategies/cartesian/envelope_segment.hpp | 71 | ||||
-rw-r--r-- | boost/geometry/strategies/cartesian/intersection.hpp (renamed from boost/geometry/strategies/cartesian/cart_intersect.hpp) | 262 | ||||
-rw-r--r-- | boost/geometry/strategies/cartesian/point_in_box.hpp | 28 |
7 files changed, 672 insertions, 91 deletions
diff --git a/boost/geometry/strategies/cartesian/area_surveyor.hpp b/boost/geometry/strategies/cartesian/area_surveyor.hpp index ba76f67946..b3f19b1b1e 100644 --- a/boost/geometry/strategies/cartesian/area_surveyor.hpp +++ b/boost/geometry/strategies/cartesian/area_surveyor.hpp @@ -4,8 +4,8 @@ // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2016. -// Modifications copyright (c) 2016, Oracle and/or its affiliates. +// This file was modified by Oracle on 2016, 2017. +// Modifications copyright (c) 2016-2017, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -25,6 +25,7 @@ //#include <boost/geometry/arithmetic/determinant.hpp> #include <boost/geometry/core/coordinate_type.hpp> #include <boost/geometry/core/coordinate_dimension.hpp> +#include <boost/geometry/strategies/area.hpp> #include <boost/geometry/util/select_most_precise.hpp> diff --git a/boost/geometry/strategies/cartesian/azimuth.hpp b/boost/geometry/strategies/cartesian/azimuth.hpp new file mode 100644 index 0000000000..62f804e8f5 --- /dev/null +++ b/boost/geometry/strategies/cartesian/azimuth.hpp @@ -0,0 +1,49 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2016-2017 Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// 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_STRATEGIES_CARTESIAN_AZIMUTH_HPP +#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_AZIMUTH_HPP + +#include <boost/geometry/core/tags.hpp> + +namespace boost { namespace geometry +{ + +namespace strategy { namespace azimuth +{ + +template +< + typename CalculationType = void +> +class cartesian +{}; + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template <typename CalculationType> +struct default_strategy<cartesian_tag, CalculationType> +{ + typedef strategy::azimuth::cartesian<CalculationType> type; +}; + +} + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +}} // namespace strategy::azimuth + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_AZIMUTH_HPP diff --git a/boost/geometry/strategies/cartesian/box_in_box.hpp b/boost/geometry/strategies/cartesian/box_in_box.hpp index 28a6f29336..4641aafcb1 100644 --- a/boost/geometry/strategies/cartesian/box_in_box.hpp +++ b/boost/geometry/strategies/cartesian/box_in_box.hpp @@ -5,8 +5,8 @@ // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2015, 2016. -// Modifications copyright (c) 2016, Oracle and/or its affiliates. +// This file was modified by Oracle on 2015, 2016, 2017. +// Modifications copyright (c) 2016-2017, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -238,10 +238,10 @@ namespace within { namespace services template <typename BoxContained, typename BoxContaining> struct default_strategy < + BoxContained, BoxContaining, box_tag, box_tag, - box_tag, areal_tag, - cartesian_tag, cartesian_tag, - BoxContained, BoxContaining + areal_tag, areal_tag, + cartesian_tag, cartesian_tag > { typedef within::box_in_box<BoxContained, BoxContaining> type; @@ -251,10 +251,10 @@ struct default_strategy template <typename BoxContained, typename BoxContaining> struct default_strategy < + BoxContained, BoxContaining, box_tag, box_tag, - box_tag, areal_tag, - spherical_tag, spherical_tag, - BoxContained, BoxContaining + areal_tag, areal_tag, + spherical_tag, spherical_tag > { typedef within::box_in_box<BoxContained, BoxContaining> type; @@ -269,10 +269,10 @@ namespace covered_by { namespace services template <typename BoxContained, typename BoxContaining> struct default_strategy < + BoxContained, BoxContaining, box_tag, box_tag, - box_tag, areal_tag, - cartesian_tag, cartesian_tag, - BoxContained, BoxContaining + areal_tag, areal_tag, + cartesian_tag, cartesian_tag > { typedef within::box_in_box @@ -286,10 +286,10 @@ struct default_strategy template <typename BoxContained, typename BoxContaining> struct default_strategy < + BoxContained, BoxContaining, box_tag, box_tag, - box_tag, areal_tag, - spherical_tag, spherical_tag, - BoxContained, BoxContaining + areal_tag, areal_tag, + spherical_tag, spherical_tag > { typedef within::box_in_box diff --git a/boost/geometry/strategies/cartesian/disjoint_segment_box.hpp b/boost/geometry/strategies/cartesian/disjoint_segment_box.hpp new file mode 100644 index 0000000000..4270803322 --- /dev/null +++ b/boost/geometry/strategies/cartesian/disjoint_segment_box.hpp @@ -0,0 +1,320 @@ +// Boost.Geometry + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2013-2017. +// Modifications copyright (c) 2013-2017, Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// 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_STRATEGIES_CARTESIAN_DISJOINT_SEGMENT_BOX_HPP +#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISJOINT_SEGMENT_BOX_HPP + + +#include <cstddef> +#include <utility> + +#include <boost/numeric/conversion/cast.hpp> + +#include <boost/geometry/util/math.hpp> +#include <boost/geometry/util/calculation_type.hpp> + +#include <boost/geometry/core/access.hpp> +#include <boost/geometry/core/tags.hpp> +#include <boost/geometry/core/coordinate_dimension.hpp> +#include <boost/geometry/core/point_type.hpp> + +#include <boost/geometry/algorithms/detail/assign_indexed_point.hpp> + +#include <boost/geometry/strategies/disjoint.hpp> + + +namespace boost { namespace geometry { namespace strategy { namespace disjoint +{ + +namespace detail +{ + +template <std::size_t I> +struct compute_tmin_tmax_per_dim +{ + template <typename SegmentPoint, typename Box, typename RelativeDistance> + static inline void apply(SegmentPoint const& p0, + SegmentPoint const& p1, + Box const& box, + RelativeDistance& ti_min, + RelativeDistance& ti_max, + RelativeDistance& diff) + { + typedef typename coordinate_type<Box>::type box_coordinate_type; + typedef typename coordinate_type + < + SegmentPoint + >::type point_coordinate_type; + + RelativeDistance c_p0 = boost::numeric_cast + < + point_coordinate_type + >( geometry::get<I>(p0) ); + + RelativeDistance c_p1 = boost::numeric_cast + < + point_coordinate_type + >( geometry::get<I>(p1) ); + + RelativeDistance c_b_min = boost::numeric_cast + < + box_coordinate_type + >( geometry::get<geometry::min_corner, I>(box) ); + + RelativeDistance c_b_max = boost::numeric_cast + < + box_coordinate_type + >( geometry::get<geometry::max_corner, I>(box) ); + + if ( geometry::get<I>(p1) >= geometry::get<I>(p0) ) + { + diff = c_p1 - c_p0; + ti_min = c_b_min - c_p0; + ti_max = c_b_max - c_p0; + } + else + { + diff = c_p0 - c_p1; + ti_min = c_p0 - c_b_max; + ti_max = c_p0 - c_b_min; + } + } +}; + + +template +< + typename RelativeDistance, + typename SegmentPoint, + typename Box, + std::size_t I, + std::size_t Dimension +> +struct disjoint_segment_box_impl +{ + template <typename RelativeDistancePair> + static inline bool apply(SegmentPoint const& p0, + SegmentPoint const& p1, + Box const& box, + RelativeDistancePair& t_min, + RelativeDistancePair& t_max) + { + RelativeDistance ti_min, ti_max, diff; + + compute_tmin_tmax_per_dim<I>::apply(p0, p1, box, ti_min, ti_max, diff); + + if ( geometry::math::equals(diff, 0) ) + { + if ( (geometry::math::equals(t_min.second, 0) + && t_min.first > ti_max) + || + (geometry::math::equals(t_max.second, 0) + && t_max.first < ti_min) + || + (math::sign(ti_min) * math::sign(ti_max) > 0) ) + { + return true; + } + } + + RelativeDistance t_min_x_diff = t_min.first * diff; + RelativeDistance t_max_x_diff = t_max.first * diff; + + if ( t_min_x_diff > ti_max * t_min.second + || t_max_x_diff < ti_min * t_max.second ) + { + return true; + } + + if ( ti_min * t_min.second > t_min_x_diff ) + { + t_min.first = ti_min; + t_min.second = diff; + } + if ( ti_max * t_max.second < t_max_x_diff ) + { + t_max.first = ti_max; + t_max.second = diff; + } + + if ( t_min.first > t_min.second || t_max.first < 0 ) + { + return true; + } + + return disjoint_segment_box_impl + < + RelativeDistance, + SegmentPoint, + Box, + I + 1, + Dimension + >::apply(p0, p1, box, t_min, t_max); + } +}; + + +template +< + typename RelativeDistance, + typename SegmentPoint, + typename Box, + std::size_t Dimension +> +struct disjoint_segment_box_impl + < + RelativeDistance, SegmentPoint, Box, 0, Dimension + > +{ + static inline bool apply(SegmentPoint const& p0, + SegmentPoint const& p1, + Box const& box) + { + std::pair<RelativeDistance, RelativeDistance> t_min, t_max; + RelativeDistance diff; + + compute_tmin_tmax_per_dim<0>::apply(p0, p1, box, + t_min.first, t_max.first, diff); + + if ( geometry::math::equals(diff, 0) ) + { + if ( geometry::math::equals(t_min.first, 0) ) { t_min.first = -1; } + if ( geometry::math::equals(t_max.first, 0) ) { t_max.first = 1; } + + if (math::sign(t_min.first) * math::sign(t_max.first) > 0) + { + return true; + } + } + + if ( t_min.first > diff || t_max.first < 0 ) + { + return true; + } + + t_min.second = t_max.second = diff; + + return disjoint_segment_box_impl + < + RelativeDistance, SegmentPoint, Box, 1, Dimension + >::apply(p0, p1, box, t_min, t_max); + } +}; + + +template +< + typename RelativeDistance, + typename SegmentPoint, + typename Box, + std::size_t Dimension +> +struct disjoint_segment_box_impl + < + RelativeDistance, SegmentPoint, Box, Dimension, Dimension + > +{ + template <typename RelativeDistancePair> + static inline bool apply(SegmentPoint const&, SegmentPoint const&, + Box const&, + RelativeDistancePair&, RelativeDistancePair&) + { + return false; + } +}; + +} // namespace detail + +// NOTE: This may be temporary place for this or corresponding strategy +// It seems to be more appropriate to implement the opposite of it +// e.g. intersection::segment_box because in disjoint() algorithm +// other strategies that are used are intersection and covered_by strategies. +struct segment_box +{ + template <typename Segment, typename Box> + struct point_in_geometry_strategy + : services::default_strategy + < + typename point_type<Segment>::type, + Box + > + {}; + + template <typename Segment, typename Box> + static inline typename point_in_geometry_strategy<Segment, Box>::type + get_point_in_geometry_strategy() + { + typedef typename point_in_geometry_strategy<Segment, Box>::type strategy_type; + + return strategy_type(); + } + + template <typename Segment, typename Box> + static inline bool apply(Segment const& segment, Box const& box) + { + assert_dimension_equal<Segment, Box>(); + + typedef typename util::calculation_type::geometric::binary + < + Segment, Box, void + >::type relative_distance_type; + + typedef typename point_type<Segment>::type segment_point_type; + segment_point_type p0, p1; + geometry::detail::assign_point_from_index<0>(segment, p0); + geometry::detail::assign_point_from_index<1>(segment, p1); + + return detail::disjoint_segment_box_impl + < + relative_distance_type, segment_point_type, Box, + 0, dimension<Box>::value + >::apply(p0, p1, box); + } +}; + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +namespace services +{ + +// Currently used in all coordinate systems + +template <typename Linear, typename Box, typename LinearTag> +struct default_strategy<Linear, Box, LinearTag, box_tag, 1, 2> +{ + typedef disjoint::segment_box type; +}; + +template <typename Box, typename Linear, typename LinearTag> +struct default_strategy<Box, Linear, box_tag, LinearTag, 2, 1> +{ + typedef disjoint::segment_box type; +}; + + +} // namespace services + + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}}}} // namespace boost::geometry::strategy::disjoint + + +#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISJOINT_SEGMENT_BOX_HPP diff --git a/boost/geometry/strategies/cartesian/envelope_segment.hpp b/boost/geometry/strategies/cartesian/envelope_segment.hpp new file mode 100644 index 0000000000..0ddbf12a41 --- /dev/null +++ b/boost/geometry/strategies/cartesian/envelope_segment.hpp @@ -0,0 +1,71 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2017 Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// 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_STRATEGIES_CARTESIAN_ENVELOPE_SEGMENT_HPP +#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_SEGMENT_HPP + + +#include <boost/geometry/algorithms/detail/envelope/segment.hpp> +#include <boost/geometry/core/tags.hpp> +#include <boost/geometry/util/select_calculation_type.hpp> + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace envelope +{ + +template +< + typename CalculationType = void +> +class cartesian_segment +{ +public : + + template <typename Point1, typename Point2, typename Box> + inline void + apply(Point1 const& point1, Point2 const& point2, Box& box) const + { + geometry::detail::envelope::envelope_one_segment + < + 0, + dimension<Point1>::value + > + ::apply(point1, + point2, + box, + strategy::envelope::cartesian_segment<CalculationType>()); + } + +}; + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + +namespace services +{ + +template <typename CalculationType> +struct default_strategy<cartesian_tag, CalculationType> +{ + typedef strategy::envelope::cartesian_segment<CalculationType> type; +}; + +} + +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::envelope + +}} //namepsace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_SEGMENT_HPP diff --git a/boost/geometry/strategies/cartesian/cart_intersect.hpp b/boost/geometry/strategies/cartesian/intersection.hpp index 0cb5d75457..20b6b93367 100644 --- a/boost/geometry/strategies/cartesian/cart_intersect.hpp +++ b/boost/geometry/strategies/cartesian/intersection.hpp @@ -3,8 +3,8 @@ // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014, 2016. -// Modifications copyright (c) 2014-2016, Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2016, 2017. +// Modifications 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 @@ -33,13 +33,16 @@ #include <boost/geometry/util/promote_integral.hpp> #include <boost/geometry/util/select_calculation_type.hpp> -// Temporary / will be Strategy as template parameter -#include <boost/geometry/strategies/side.hpp> +#include <boost/geometry/strategies/agnostic/point_in_poly_winding.hpp> +#include <boost/geometry/strategies/cartesian/area_surveyor.hpp> +#include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp> #include <boost/geometry/strategies/cartesian/side_by_triangle.hpp> - -#include <boost/geometry/strategies/side_info.hpp> +#include <boost/geometry/strategies/covered_by.hpp> #include <boost/geometry/strategies/intersection.hpp> #include <boost/geometry/strategies/intersection_result.hpp> +#include <boost/geometry/strategies/side.hpp> +#include <boost/geometry/strategies/side_info.hpp> +#include <boost/geometry/strategies/within.hpp> #include <boost/geometry/policies/robustness/robust_point_type.hpp> #include <boost/geometry/policies/robustness/segment_ratio_type.hpp> @@ -61,10 +64,74 @@ namespace strategy { namespace intersection /*! \see http://mathworld.wolfram.com/Line-LineIntersection.html */ -template <typename Policy, typename CalculationType = void> -struct relate_cartesian_segments +template +< + typename CalculationType = void +> +struct cartesian_segments { - typedef typename Policy::return_type return_type; + typedef side::side_by_triangle<CalculationType> side_strategy_type; + + static inline side_strategy_type get_side_strategy() + { + return side_strategy_type(); + } + + template <typename Geometry1, typename Geometry2> + struct point_in_geometry_strategy + { + typedef strategy::within::winding + < + typename point_type<Geometry1>::type, + typename point_type<Geometry2>::type, + side_strategy_type, + CalculationType + > type; + }; + + template <typename Geometry1, typename Geometry2> + static inline typename point_in_geometry_strategy<Geometry1, Geometry2>::type + get_point_in_geometry_strategy() + { + typedef typename point_in_geometry_strategy + < + Geometry1, Geometry2 + >::type strategy_type; + return strategy_type(); + } + + template <typename Geometry> + struct area_strategy + { + typedef area::surveyor + < + typename point_type<Geometry>::type, + CalculationType + > type; + }; + + template <typename Geometry> + static inline typename area_strategy<Geometry>::type get_area_strategy() + { + typedef typename area_strategy<Geometry>::type strategy_type; + return strategy_type(); + } + + template <typename Geometry> + struct distance_strategy + { + typedef distance::pythagoras + < + CalculationType + > type; + }; + + template <typename Geometry> + static inline typename distance_strategy<Geometry>::type get_distance_strategy() + { + typedef typename distance_strategy<Geometry>::type strategy_type; + return strategy_type(); + } template <typename CoordinateType, typename SegmentRatio> struct segment_intersection_info @@ -144,9 +211,16 @@ struct relate_cartesian_segments // Relate segments a and b - template <typename Segment1, typename Segment2, typename RobustPolicy> - static inline return_type apply(Segment1 const& a, Segment2 const& b, - RobustPolicy const& robust_policy) + template + < + typename Segment1, + typename Segment2, + typename Policy, + typename RobustPolicy + > + static inline typename Policy::return_type + apply(Segment1 const& a, Segment2 const& b, + Policy const& policy, RobustPolicy const& robust_policy) { // type them all as in Segment1 - TODO reconsider this, most precise? typedef typename geometry::point_type<Segment1>::type point_type; @@ -169,18 +243,25 @@ struct relate_cartesian_segments geometry::recalculate(b0_rob, b0, robust_policy); geometry::recalculate(b1_rob, b1, robust_policy); - return apply(a, b, robust_policy, a0_rob, a1_rob, b0_rob, b1_rob); + return apply(a, b, policy, robust_policy, a0_rob, a1_rob, b0_rob, b1_rob); } // The main entry-routine, calculating intersections of segments a / b // NOTE: Robust* types may be the same as Segments' point types - template <typename Segment1, typename Segment2, - typename RobustPolicy, - typename RobustPoint1, typename RobustPoint2> - static inline return_type apply(Segment1 const& a, Segment2 const& b, - RobustPolicy const& /*robust_policy*/, - RobustPoint1 const& robust_a1, RobustPoint1 const& robust_a2, - RobustPoint2 const& robust_b1, RobustPoint2 const& robust_b2) + template + < + typename Segment1, + typename Segment2, + typename Policy, + typename RobustPolicy, + typename RobustPoint1, + typename RobustPoint2 + > + static inline typename Policy::return_type + apply(Segment1 const& a, Segment2 const& b, + Policy const&, RobustPolicy const& /*robust_policy*/, + RobustPoint1 const& robust_a1, RobustPoint1 const& robust_a2, + RobustPoint2 const& robust_b1, RobustPoint2 const& robust_b2) { BOOST_CONCEPT_ASSERT( (concepts::ConstSegment<Segment1>) ); BOOST_CONCEPT_ASSERT( (concepts::ConstSegment<Segment2>) ); @@ -197,14 +278,9 @@ struct relate_cartesian_segments ; } - typedef typename select_calculation_type - <Segment1, Segment2, CalculationType>::type coordinate_type; - - typedef side::side_by_triangle<coordinate_type> side; - side_info sides; - sides.set<0>(side::apply(robust_b1, robust_b2, robust_a1), - side::apply(robust_b1, robust_b2, robust_a2)); + sides.set<0>(side_strategy_type::apply(robust_b1, robust_b2, robust_a1), + side_strategy_type::apply(robust_b1, robust_b2, robust_a2)); if (sides.same<0>()) { @@ -212,8 +288,8 @@ struct relate_cartesian_segments return Policy::disjoint(); } - sides.set<1>(side::apply(robust_a1, robust_a2, robust_b1), - side::apply(robust_a1, robust_a2, robust_b2)); + sides.set<1>(side_strategy_type::apply(robust_a1, robust_a2, robust_b1), + side_strategy_type::apply(robust_a1, robust_a2, robust_b2)); if (sides.same<1>()) { @@ -230,16 +306,16 @@ struct relate_cartesian_segments >::type robust_coordinate_type; typedef typename segment_ratio_type - < - typename geometry::point_type<Segment1>::type, // TODO: most precise point? - RobustPolicy - >::type ratio_type; + < + typename geometry::point_type<Segment1>::type, // TODO: most precise point? + RobustPolicy + >::type ratio_type; segment_intersection_info - < - coordinate_type, - ratio_type - > sinfo; + < + typename select_calculation_type<Segment1, Segment2, CalculationType>::type, + ratio_type + > sinfo; sinfo.dx_a = get<1, 0>(a) - get<0, 0>(a); // distance in x-dir sinfo.dx_b = get<1, 0>(b) - get<0, 0>(b); @@ -303,14 +379,14 @@ struct relate_cartesian_segments if (collinear_use_first.first) { - return relate_collinear<0, ratio_type>(a, b, + return relate_collinear<0, Policy, ratio_type>(a, b, robust_a1, robust_a2, robust_b1, robust_b2, a_is_point, b_is_point); } else { // Y direction contains larger segments (maybe dx is zero) - return relate_collinear<1, ratio_type>(a, b, + return relate_collinear<1, Policy, ratio_type>(a, b, robust_a1, robust_a2, robust_b1, robust_b2, a_is_point, b_is_point); } @@ -358,33 +434,35 @@ private: template < std::size_t Dimension, + typename Policy, typename RatioType, typename Segment1, typename Segment2, typename RobustPoint1, typename RobustPoint2 > - static inline return_type relate_collinear(Segment1 const& a, - Segment2 const& b, - RobustPoint1 const& robust_a1, RobustPoint1 const& robust_a2, - RobustPoint2 const& robust_b1, RobustPoint2 const& robust_b2, - bool a_is_point, bool b_is_point) + static inline typename Policy::return_type + relate_collinear(Segment1 const& a, + Segment2 const& b, + RobustPoint1 const& robust_a1, RobustPoint1 const& robust_a2, + RobustPoint2 const& robust_b1, RobustPoint2 const& robust_b2, + bool a_is_point, bool b_is_point) { if (a_is_point) { - return relate_one_degenerate<RatioType>(a, + return relate_one_degenerate<Policy, RatioType>(a, get<Dimension>(robust_a1), get<Dimension>(robust_b1), get<Dimension>(robust_b2), true); } if (b_is_point) { - return relate_one_degenerate<RatioType>(b, + return relate_one_degenerate<Policy, RatioType>(b, get<Dimension>(robust_b1), get<Dimension>(robust_a1), get<Dimension>(robust_a2), false); } - return relate_collinear<RatioType>(a, b, + return relate_collinear<Policy, RatioType>(a, b, get<Dimension>(robust_a1), get<Dimension>(robust_a2), get<Dimension>(robust_b1), @@ -394,17 +472,17 @@ private: /// Relate segments known collinear template < + typename Policy, typename RatioType, typename Segment1, typename Segment2, typename RobustType1, typename RobustType2 > - static inline return_type relate_collinear(Segment1 const& a - , Segment2 const& b - , RobustType1 oa_1, RobustType1 oa_2 - , RobustType2 ob_1, RobustType2 ob_2 - ) + static inline typename Policy::return_type + relate_collinear(Segment1 const& a, Segment2 const& b, + RobustType1 oa_1, RobustType1 oa_2, + RobustType2 ob_1, RobustType2 ob_2) { // Calculate the ratios where a starts in b, b starts in a // a1--------->a2 (2..7) @@ -496,17 +574,16 @@ private: /// Relate segments where one is degenerate template < + typename Policy, typename RatioType, typename DegenerateSegment, typename RobustType1, typename RobustType2 > - static inline return_type relate_one_degenerate( - DegenerateSegment const& degenerate_segment - , RobustType1 d - , RobustType2 s1, RobustType2 s2 - , bool a_degenerate - ) + static inline typename Policy::return_type + relate_one_degenerate(DegenerateSegment const& degenerate_segment, + RobustType1 d, RobustType2 s1, RobustType2 s2, + bool a_degenerate) { // Calculate the ratios where ds starts in s // a1--------->a2 (2..6) @@ -546,10 +623,10 @@ private: namespace services { -template <typename Policy, typename CalculationType> -struct default_strategy<cartesian_tag, Policy, CalculationType> +template <typename CalculationType> +struct default_strategy<cartesian_tag, CalculationType> { - typedef relate_cartesian_segments<Policy, CalculationType> type; + typedef cartesian_segments<CalculationType> type; }; } // namespace services @@ -558,6 +635,69 @@ struct default_strategy<cartesian_tag, Policy, CalculationType> }} // namespace strategy::intersection +namespace strategy +{ + +namespace within { namespace services +{ + +template <typename Geometry1, typename Geometry2, typename AnyTag1, typename AnyTag2> +struct default_strategy<Geometry1, Geometry2, AnyTag1, AnyTag2, linear_tag, linear_tag, cartesian_tag, cartesian_tag> +{ + typedef strategy::intersection::cartesian_segments<> type; +}; + +template <typename Geometry1, typename Geometry2, typename AnyTag1, typename AnyTag2> +struct default_strategy<Geometry1, Geometry2, AnyTag1, AnyTag2, linear_tag, polygonal_tag, cartesian_tag, cartesian_tag> +{ + typedef strategy::intersection::cartesian_segments<> type; +}; + +template <typename Geometry1, typename Geometry2, typename AnyTag1, typename AnyTag2> +struct default_strategy<Geometry1, Geometry2, AnyTag1, AnyTag2, polygonal_tag, linear_tag, cartesian_tag, cartesian_tag> +{ + typedef strategy::intersection::cartesian_segments<> type; +}; + +template <typename Geometry1, typename Geometry2, typename AnyTag1, typename AnyTag2> +struct default_strategy<Geometry1, Geometry2, AnyTag1, AnyTag2, polygonal_tag, polygonal_tag, cartesian_tag, cartesian_tag> +{ + typedef strategy::intersection::cartesian_segments<> type; +}; + +}} // within::services + +namespace covered_by { namespace services +{ + +template <typename Geometry1, typename Geometry2, typename AnyTag1, typename AnyTag2> +struct default_strategy<Geometry1, Geometry2, AnyTag1, AnyTag2, linear_tag, linear_tag, cartesian_tag, cartesian_tag> +{ + typedef strategy::intersection::cartesian_segments<> type; +}; + +template <typename Geometry1, typename Geometry2, typename AnyTag1, typename AnyTag2> +struct default_strategy<Geometry1, Geometry2, AnyTag1, AnyTag2, linear_tag, polygonal_tag, cartesian_tag, cartesian_tag> +{ + typedef strategy::intersection::cartesian_segments<> type; +}; + +template <typename Geometry1, typename Geometry2, typename AnyTag1, typename AnyTag2> +struct default_strategy<Geometry1, Geometry2, AnyTag1, AnyTag2, polygonal_tag, linear_tag, cartesian_tag, cartesian_tag> +{ + typedef strategy::intersection::cartesian_segments<> type; +}; + +template <typename Geometry1, typename Geometry2, typename AnyTag1, typename AnyTag2> +struct default_strategy<Geometry1, Geometry2, AnyTag1, AnyTag2, polygonal_tag, polygonal_tag, cartesian_tag, cartesian_tag> +{ + typedef strategy::intersection::cartesian_segments<> type; +}; + +}} // within::services + +} // strategy + }} // namespace boost::geometry diff --git a/boost/geometry/strategies/cartesian/point_in_box.hpp b/boost/geometry/strategies/cartesian/point_in_box.hpp index 227a98f2ad..1c14125a6d 100644 --- a/boost/geometry/strategies/cartesian/point_in_box.hpp +++ b/boost/geometry/strategies/cartesian/point_in_box.hpp @@ -4,8 +4,8 @@ // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2015-2016. -// Modifications copyright (c) 2015-2016, Oracle and/or its affiliates. +// This file was modified by Oracle on 2015-2017. +// Modifications copyright (c) 2015-2017, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -219,10 +219,10 @@ namespace within { namespace services template <typename Point, typename Box> struct default_strategy < + Point, Box, point_tag, box_tag, - point_tag, areal_tag, - cartesian_tag, cartesian_tag, - Point, Box + pointlike_tag, areal_tag, + cartesian_tag, cartesian_tag > { typedef within::point_in_box<Point, Box> type; @@ -232,10 +232,10 @@ struct default_strategy template <typename Point, typename Box> struct default_strategy < + Point, Box, point_tag, box_tag, - point_tag, areal_tag, - spherical_tag, spherical_tag, - Point, Box + pointlike_tag, areal_tag, + spherical_tag, spherical_tag > { typedef within::point_in_box<Point, Box> type; @@ -252,10 +252,10 @@ namespace covered_by { namespace services template <typename Point, typename Box> struct default_strategy < + Point, Box, point_tag, box_tag, - point_tag, areal_tag, - cartesian_tag, cartesian_tag, - Point, Box + pointlike_tag, areal_tag, + cartesian_tag, cartesian_tag > { typedef within::point_in_box @@ -269,10 +269,10 @@ struct default_strategy template <typename Point, typename Box> struct default_strategy < + Point, Box, point_tag, box_tag, - point_tag, areal_tag, - spherical_tag, spherical_tag, - Point, Box + pointlike_tag, areal_tag, + spherical_tag, spherical_tag > { typedef within::point_in_box |