/usr/include/boost/geometry/index/detail/algorithms
NameSizeModeActions
bounds.hpp64570644editdlrm
comparable_distance_centroid.hpp27950644editdlrm
comparable_distance_far.hpp23950644editdlrm
comparable_distance_near.hpp26550644editdlrm
content.hpp23800644editdlrm
diff_abs.hpp11460644editdlrm
intersection_content.hpp29120644editdlrm
is_valid.hpp21760644editdlrm
margin.hpp52610644editdlrm
minmaxdist.hpp41030644editdlrm
nth_element.hpp17490644editdlrm
path_intersection.hpp46090644editdlrm
segment_intersection.hpp53040644editdlrm
smallest_for_indexable.hpp24420644editdlrm
sum_for_indexable.hpp22370644editdlrm
union_content.hpp11030644editdlrm
Edit: /usr/include/boost/geometry/index/detail/algorithms/segment_intersection.hpp (5304B)
// Boost.Geometry Index // // n-dimensional box-segment intersection // // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // 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_INDEX_DETAIL_ALGORITHMS_SEGMENT_INTERSECTION_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_SEGMENT_INTERSECTION_HPP namespace boost { namespace geometry { namespace index { namespace detail { //template //struct default_relative_distance_type //{ // typedef typename select_most_precise< // typename select_most_precise< // typename coordinate_type::type, // typename coordinate_type::type // >::type, // float // TODO - use bigger type, calculated from the size of coordinate types // >::type type; // // // BOOST_MPL_ASSERT_MSG((!::boost::is_unsigned::value), // THIS_TYPE_SHOULDNT_BE_UNSIGNED, (type)); //}; namespace dispatch { template struct box_segment_intersection_dim { BOOST_STATIC_ASSERT(0 <= dimension::value); BOOST_STATIC_ASSERT(0 <= dimension::value); BOOST_STATIC_ASSERT(I < size_t(dimension::value)); BOOST_STATIC_ASSERT(I < size_t(dimension::value)); BOOST_STATIC_ASSERT(dimension::value == dimension::value); // WARNING! - RelativeDistance must be IEEE float for this to work template static inline bool apply(Box const& b, Point const& p0, Point const& p1, RelativeDistance & t_near, RelativeDistance & t_far) { RelativeDistance ray_d = geometry::get(p1) - geometry::get(p0); RelativeDistance tn = ( geometry::get(b) - geometry::get(p0) ) / ray_d; RelativeDistance tf = ( geometry::get(b) - geometry::get(p0) ) / ray_d; if ( tf < tn ) ::std::swap(tn, tf); if ( t_near < tn ) t_near = tn; if ( tf < t_far ) t_far = tf; return 0 <= t_far && t_near <= t_far; } }; template struct box_segment_intersection { BOOST_STATIC_ASSERT(0 < CurrentDimension); typedef box_segment_intersection_dim for_dim; template static inline bool apply(Box const& b, Point const& p0, Point const& p1, RelativeDistance & t_near, RelativeDistance & t_far) { return box_segment_intersection::apply(b, p0, p1, t_near, t_far) && for_dim::apply(b, p0, p1, t_near, t_far); } }; template struct box_segment_intersection { typedef box_segment_intersection_dim for_dim; template static inline bool apply(Box const& b, Point const& p0, Point const& p1, RelativeDistance & t_near, RelativeDistance & t_far) { return for_dim::apply(b, p0, p1, t_near, t_far); } }; template struct segment_intersection { BOOST_MPL_ASSERT_MSG((false), NOT_IMPLEMENTED_FOR_THIS_GEOMETRY, (segment_intersection)); }; template struct segment_intersection { BOOST_MPL_ASSERT_MSG((false), SEGMENT_POINT_INTERSECTION_UNAVAILABLE, (segment_intersection)); }; template struct segment_intersection { typedef dispatch::box_segment_intersection::value> impl; template static inline bool apply(Indexable const& b, Point const& p0, Point const& p1, RelativeDistance & relative_distance) { // TODO: this ASSERT CHECK is wrong for user-defined CoordinateTypes! static const bool check = !::boost::is_integral::value; BOOST_MPL_ASSERT_MSG(check, RELATIVE_DISTANCE_MUST_BE_FLOATING_POINT_TYPE, (RelativeDistance)); RelativeDistance t_near = -(::std::numeric_limits::max)(); RelativeDistance t_far = (::std::numeric_limits::max)(); return impl::apply(b, p0, p1, t_near, t_far) && (t_near <= 1) && ( relative_distance = 0 < t_near ? t_near : 0, true ); } }; } // namespace dispatch template inline bool segment_intersection(Indexable const& b, Point const& p0, Point const& p1, RelativeDistance & relative_distance) { // TODO check Indexable and Point concepts return dispatch::segment_intersection< Indexable, Point, typename tag::type >::apply(b, p0, p1, relative_distance); } }}}} // namespace boost::geometry::index::detail #endif // BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_SEGMENT_INTERSECTION_HPP