Merge pull request #35 from mkaravel/feature/disjoint

Feature/disjoint
This commit is contained in:
Adam Wulkiewicz
2014-05-24 00:09:07 +02:00
35 changed files with 3057 additions and 905 deletions

View File

@@ -23,7 +23,6 @@
#include <boost/geometry/algorithms/clear.hpp>
#include <boost/geometry/algorithms/not_implemented.hpp>
#include <boost/geometry/algorithms/detail/disjoint.hpp>
#include <boost/geometry/arithmetic/arithmetic.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/geometries/segment.hpp>

View File

@@ -1,246 +0,0 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// 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_ALGORITHMS_DETAIL_DISJOINT_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_HPP
// Note: contrary to most files, the geometry::detail::disjoint namespace
// is partly implemented in separate files, to avoid circular references
// disjoint -> get_turns -> disjoint
#include <cstddef>
#include <boost/range.hpp>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/core/reverse_dispatch.hpp>
#include <boost/geometry/algorithms/covered_by.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/algorithms/detail/disjoint/box_box.hpp>
#include <boost/geometry/algorithms/detail/disjoint/point_point.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace disjoint
{
struct disjoint_interrupt_policy
{
static bool const enabled = true;
bool has_intersections;
inline disjoint_interrupt_policy()
: has_intersections(false)
{}
template <typename Range>
inline bool apply(Range const& range)
{
// If there is any IP in the range, it is NOT disjoint
if (boost::size(range) > 0)
{
has_intersections = true;
return true;
}
return false;
}
};
template
<
typename Point, typename Box,
std::size_t Dimension, std::size_t DimensionCount
>
struct point_box
{
static inline bool apply(Point const& point, Box const& box)
{
if (get<Dimension>(point) < get<min_corner, Dimension>(box)
|| get<Dimension>(point) > get<max_corner, Dimension>(box))
{
return true;
}
return point_box
<
Point, Box,
Dimension + 1, DimensionCount
>::apply(point, box);
}
};
template <typename Point, typename Box, std::size_t DimensionCount>
struct point_box<Point, Box, DimensionCount, DimensionCount>
{
static inline bool apply(Point const& , Box const& )
{
return false;
}
};
// Segment - Box intersection
// Based on Ray-AABB intersection
// http://www.siggraph.org/education/materials/HyperGraph/raytrace/rtinter3.htm
// TODO - later maybe move to strategy::intersects and add a policy to conditionally extract intersection points
template <typename Point, typename Box, size_t I>
struct segment_box_intersection_dim
{
//BOOST_STATIC_ASSERT(I < dimension<Box>::value);
//BOOST_STATIC_ASSERT(I < dimension<Point>::value);
//BOOST_STATIC_ASSERT(dimension<Point>::value == dimension<Box>::value);
typedef typename coordinate_type<Point>::type point_coordinate;
template <typename RelativeDistance> static inline
bool apply(Point const& p0, Point const& p1, Box const& b, RelativeDistance & t_near, RelativeDistance & t_far)
{
//// WARNING! - RelativeDistance must be IEEE float for this to work (division by 0)
//BOOST_STATIC_ASSERT(boost::is_float<RelativeDistance>::value);
//// Ray origin is in segment point 0
//RelativeDistance ray_d = geometry::get<I>(p1) - geometry::get<I>(p0);
//RelativeDistance tn = ( geometry::get<min_corner, I>(b) - geometry::get<I>(p0) ) / ray_d;
//RelativeDistance tf = ( geometry::get<max_corner, I>(b) - geometry::get<I>(p0) ) / ray_d;
// TODO - should we support also unsigned integers?
BOOST_STATIC_ASSERT(!boost::is_unsigned<point_coordinate>::value);
point_coordinate ray_d = geometry::get<I>(p1) - geometry::get<I>(p0);
RelativeDistance tn, tf;
if ( is_zero(ray_d) )
{
tn = dist_div_by_zero<RelativeDistance>(geometry::get<min_corner, I>(b) - geometry::get<I>(p0));
tf = dist_div_by_zero<RelativeDistance>(geometry::get<max_corner, I>(b) - geometry::get<I>(p0));
}
else
{
tn = static_cast<RelativeDistance>(geometry::get<min_corner, I>(b) - geometry::get<I>(p0)) / ray_d;
tf = static_cast<RelativeDistance>(geometry::get<max_corner, I>(b) - geometry::get<I>(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 && t_near <= 1;
}
template <typename R, typename T> static inline
R dist_div_by_zero(T const& val)
{
if ( is_zero(val) )
return 0;
else if ( val < 0 )
return -(::std::numeric_limits<R>::max)();
else
return (::std::numeric_limits<R>::max)();
}
template <typename T> static inline
bool is_zero(T const& val)
{
// ray_d == 0 is here because eps of rational<int> is 0 which isn't < than 0
return val == 0 || math::abs(val) < ::std::numeric_limits<T>::epsilon();
}
};
template <typename Point, typename Box, size_t CurrentDimension>
struct segment_box_intersection_impl
{
BOOST_STATIC_ASSERT(0 < CurrentDimension);
typedef segment_box_intersection_dim<Point, Box, CurrentDimension - 1> for_dim;
template <typename RelativeDistance>
static inline bool apply(Point const& p0, Point const& p1, Box const& b,
RelativeDistance & t_near, RelativeDistance & t_far)
{
return segment_box_intersection_impl<Point, Box, CurrentDimension - 1>::apply(p0, p1, b, t_near, t_far)
&& for_dim::apply(p0, p1, b, t_near, t_far);
}
};
template <typename Point, typename Box>
struct segment_box_intersection_impl<Point, Box, 1>
{
typedef segment_box_intersection_dim<Point, Box, 0> for_dim;
template <typename RelativeDistance>
static inline bool apply(Point const& p0, Point const& p1, Box const& b,
RelativeDistance & t_near, RelativeDistance & t_far)
{
return for_dim::apply(p0, p1, b, t_near, t_far);
}
};
template <typename Point, typename Box>
struct segment_box_intersection
{
typedef segment_box_intersection_impl<Point, Box, dimension<Box>::value> impl;
static inline bool apply(Point const& p0, Point const& p1, Box const& b)
{
typedef
typename geometry::promote_floating_point<
typename geometry::select_most_precise<
typename coordinate_type<Point>::type,
typename coordinate_type<Box>::type
>::type
>::type relative_distance_type;
relative_distance_type t_near = -(::std::numeric_limits<relative_distance_type>::max)();
relative_distance_type t_far = (::std::numeric_limits<relative_distance_type>::max)();
// relative_distance = 0 < t_near ? t_near : 0;
return impl::apply(p0, p1, b, t_near, t_far);
}
};
template
<
typename Geometry1, typename Geometry2
>
struct reverse_covered_by
{
static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2)
{
return ! geometry::covered_by(geometry1, geometry2);
}
};
}} // namespace detail::disjoint
#endif // DOXYGEN_NO_DETAIL
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_HPP

View File

@@ -0,0 +1,138 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// 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-2014.
// Modifications copyright (c) 2013-2014, 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
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// 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_ALGORITHMS_DETAIL_DISJOINT_AREAL_AREAL_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_AREAL_AREAL_HPP
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/multi/core/point_type.hpp>
#include <boost/geometry/algorithms/within.hpp>
#include <boost/geometry/algorithms/detail/for_each_range.hpp>
#include <boost/geometry/algorithms/point_on_surface.hpp>
#include <boost/geometry/algorithms/detail/disjoint/linear_linear.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace disjoint
{
template<typename Geometry>
struct check_each_ring_for_within
{
bool has_within;
Geometry const& m_geometry;
inline check_each_ring_for_within(Geometry const& g)
: has_within(false)
, m_geometry(g)
{}
template <typename Range>
inline void apply(Range const& range)
{
if ( geometry::within(geometry::return_point_on_surface(range), m_geometry) )
{
has_within = true;
}
}
};
template <typename FirstGeometry, typename SecondGeometry>
inline bool rings_containing(FirstGeometry const& geometry1,
SecondGeometry const& geometry2)
{
check_each_ring_for_within<FirstGeometry> checker(geometry1);
geometry::detail::for_each_range(geometry2, checker);
return checker.has_within;
}
template <typename Geometry1, typename Geometry2>
struct general_areal
{
static inline
bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2)
{
if ( !disjoint_linear<Geometry1, Geometry2>::apply(geometry1, geometry2))
{
return false;
}
// If there is no intersection of segments, they might located
// inside each other
// We check that using a point on the surface, and see if that is inside
// the other geometry. And vice versa.
typedef typename geometry::point_type<Geometry1>::type point_type1;
typedef typename geometry::point_type<Geometry2>::type point_type2;
if (rings_containing(geometry1, geometry2)
|| rings_containing(geometry2, geometry1))
{
return false;
}
return true;
}
};
}} // namespace detail::disjoint
#endif // DOXYGEN_NO_DETAIL
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
template <typename Areal1, typename Areal2>
struct disjoint<Areal1, Areal2, 2, areal_tag, areal_tag, false>
: detail::disjoint::general_areal<Areal1, Areal2>
{};
template <typename Areal, typename Box>
struct disjoint<Areal, Box, 2, areal_tag, box_tag, false>
: detail::disjoint::general_areal<Areal, Box>
{};
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_AREAL_AREAL_HPP

View File

@@ -1,9 +1,15 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland
// 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-2014.
// Modifications copyright (c) 2013-2014, 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
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@@ -15,7 +21,12 @@
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_BOX_BOX_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_BOX_BOX_HPP
#include <cstddef>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
namespace boost { namespace geometry
@@ -81,6 +92,22 @@ inline bool disjoint_box_box(Box1 const& box1, Box2 const& box2)
}} // namespace detail::disjoint
#endif // DOXYGEN_NO_DETAIL
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
template <typename Box1, typename Box2, std::size_t DimensionCount>
struct disjoint<Box1, Box2, DimensionCount, box_tag, box_tag, false>
: detail::disjoint::box_box<Box1, Box2, 0, DimensionCount>
{};
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
}} // namespace boost::geometry

View File

@@ -0,0 +1,36 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// 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-2014.
// Modifications copyright (c) 2013-2014, 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
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// 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_ALGORITHMS_DETAIL_DISJOINT_IMPLEMENTATION_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_IMPLEMENTATION_HPP
#include <boost/geometry/algorithms/detail/disjoint/areal_areal.hpp>
#include <boost/geometry/algorithms/detail/disjoint/linear_areal.hpp>
#include <boost/geometry/algorithms/detail/disjoint/linear_linear.hpp>
#include <boost/geometry/algorithms/detail/disjoint/point_geometry.hpp>
#include <boost/geometry/algorithms/detail/disjoint/point_point.hpp>
#include <boost/geometry/algorithms/detail/disjoint/point_box.hpp>
#include <boost/geometry/algorithms/detail/disjoint/box_box.hpp>
#include <boost/geometry/algorithms/detail/disjoint/segment_box.hpp>
#include <boost/geometry/algorithms/detail/disjoint/linear_segment_or_box.hpp>
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_IMPLEMENTATION_HPP

View File

@@ -0,0 +1,187 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// 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-2014.
// Modifications copyright (c) 2013-2014, 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
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// 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_ALGORITHMS_DETAIL_DISJOINT_INTERFACE_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_INTERFACE_HPP
#include <cstddef>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/variant_fwd.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
// If reversal is needed, perform it
template
<
typename Geometry1, typename Geometry2,
std::size_t DimensionCount,
typename Tag1, typename Tag2
>
struct disjoint<Geometry1, Geometry2, DimensionCount, Tag1, Tag2, true>
{
static inline bool apply(Geometry1 const& g1, Geometry2 const& g2)
{
return disjoint
<
Geometry2, Geometry1,
DimensionCount,
Tag2, Tag1
>::apply(g2, g1);
}
};
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
namespace resolve_variant {
template <typename Geometry1, typename Geometry2>
struct disjoint
{
static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2)
{
concept::check_concepts_and_equal_dimensions
<
Geometry1 const,
Geometry2 const
>();
return dispatch::disjoint<Geometry1, Geometry2>::apply(geometry1, geometry2);
}
};
template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2>
struct disjoint<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2>
{
struct visitor: boost::static_visitor<bool>
{
Geometry2 const& m_geometry2;
visitor(Geometry2 const& geometry2): m_geometry2(geometry2) {}
template <typename Geometry1>
bool operator()(Geometry1 const& geometry1) const
{
return disjoint<Geometry1, Geometry2>::apply(geometry1, m_geometry2);
}
};
static inline bool
apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry1,
Geometry2 const& geometry2)
{
return boost::apply_visitor(visitor(geometry2), geometry1);
}
};
template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)>
struct disjoint<Geometry1, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
{
struct visitor: boost::static_visitor<bool>
{
Geometry1 const& m_geometry1;
visitor(Geometry1 const& geometry1): m_geometry1(geometry1) {}
template <typename Geometry2>
bool operator()(Geometry2 const& geometry2) const
{
return disjoint<Geometry1, Geometry2>::apply(m_geometry1, geometry2);
}
};
static inline bool
apply(Geometry1 const& geometry1,
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry2)
{
return boost::apply_visitor(visitor(geometry1), geometry2);
}
};
template <
BOOST_VARIANT_ENUM_PARAMS(typename T1),
BOOST_VARIANT_ENUM_PARAMS(typename T2)
>
struct disjoint<
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)>,
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)>
>
{
struct visitor: boost::static_visitor<bool>
{
template <typename Geometry1, typename Geometry2>
bool operator()(Geometry1 const& geometry1,
Geometry2 const& geometry2) const
{
return disjoint<Geometry1, Geometry2>::apply(geometry1, geometry2);
}
};
static inline bool
apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)> const& geometry1,
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)> const& geometry2)
{
return boost::apply_visitor(visitor(), geometry1, geometry2);
}
};
} // namespace resolve_variant
/*!
\brief \brief_check2{are disjoint}
\ingroup disjoint
\tparam Geometry1 \tparam_geometry
\tparam Geometry2 \tparam_geometry
\param geometry1 \param_geometry
\param geometry2 \param_geometry
\return \return_check2{are disjoint}
\qbk{[include reference/algorithms/disjoint.qbk]}
*/
template <typename Geometry1, typename Geometry2>
inline bool disjoint(Geometry1 const& geometry1,
Geometry2 const& geometry2)
{
return resolve_variant::disjoint<Geometry1, Geometry2>::apply(geometry1, geometry2);
}
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_INTERFACE_HPP

View File

@@ -0,0 +1,222 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// 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-2014.
// Modifications copyright (c) 2013-2014, 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
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// 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_ALGORITHMS_DETAIL_DISJOINT_LINEAR_AREAL_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_AREAL_HPP
#include <boost/range.hpp>
#include <boost/typeof/typeof.hpp>
#include <boost/geometry/core/closure.hpp>
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/core/exterior_ring.hpp>
#include <boost/geometry/core/interior_rings.hpp>
#include <boost/geometry/core/interior_type.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/multi/core/tags.hpp>
#include <boost/geometry/algorithms/covered_by.hpp>
#include <boost/geometry/algorithms/not_implemented.hpp>
#include <boost/geometry/algorithms/detail/point_on_border.hpp>
#include <boost/geometry/multi/algorithms/detail/point_on_border.hpp>
#include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
#include <boost/geometry/algorithms/detail/disjoint/point_box.hpp>
#include <boost/geometry/algorithms/detail/disjoint/segment_box.hpp>
#include <boost/geometry/algorithms/detail/disjoint/linear_segment_or_box.hpp>
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace disjoint
{
template<typename Geometry1, typename Geometry2>
struct disjoint_linear_areal
{
static inline bool apply(Geometry1 const& g1, Geometry2 const& g2)
{
// if there are intersections - return false
if ( !disjoint_linear<Geometry1, Geometry2>::apply(g1, g2) )
return false;
typedef typename point_type<Geometry1>::type point1_type;
point1_type p;
geometry::point_on_border(p, g1);
return !geometry::covered_by(p, g2);
}
};
template
<
typename Segment,
typename Areal,
typename Tag = typename tag<Areal>::type
>
struct disjoint_segment_areal
: not_implemented<Segment, Areal>
{};
template <typename Segment, typename Polygon>
struct disjoint_segment_areal<Segment, Polygon, polygon_tag>
{
static inline bool apply(Segment const& segment, Polygon const& polygon)
{
typedef typename geometry::ring_type<Polygon>::type ring;
typedef typename geometry::interior_return_type
<
Polygon const
>::type interior_rings;
if ( !disjoint_range_segment_or_box
<
ring, closure<Polygon>::value, Segment
>::apply(geometry::exterior_ring(polygon), segment) )
{
return false;
}
interior_rings const& irings = geometry::interior_rings(polygon);
for (BOOST_AUTO_TPL(it, boost::begin(irings));
it != boost::end(irings); ++it)
{
if ( !disjoint_range_segment_or_box
<
ring, closure<Polygon>::value, Segment
>::apply(*it, segment) )
{
return false;
}
}
typename point_type<Segment>::type p;
detail::assign_point_from_index<0>(segment, p);
return !geometry::covered_by(p, polygon);
}
};
template <typename Segment, typename MultiPolygon>
struct disjoint_segment_areal<Segment, MultiPolygon, multi_polygon_tag>
{
static inline
bool apply(Segment const& segment, MultiPolygon const& multipolygon)
{
return disjoint_multirange_segment_or_box
<
MultiPolygon, Segment
>::apply(multipolygon, segment);
}
};
template <typename Segment, typename Ring>
struct disjoint_segment_areal<Segment, Ring, ring_tag>
{
static inline bool apply(Segment const& segment, Ring const& ring)
{
if ( !disjoint_range_segment_or_box
<
Ring, closure<Ring>::value, Segment
>::apply(ring, segment) )
{
return false;
}
typename point_type<Segment>::type p;
detail::assign_point_from_index<0>(segment, p);
return !geometry::covered_by(p, ring);
}
};
}} // namespace detail::disjoint
#endif // DOXYGEN_NO_DETAIL
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
template <typename Linear, typename Areal>
struct disjoint<Linear, Areal, 2, linear_tag, areal_tag, false>
: public detail::disjoint::disjoint_linear_areal<Linear, Areal>
{};
template <typename Areal, typename Linear>
struct disjoint<Areal, Linear, 2, areal_tag, linear_tag, false>
{
static inline
bool apply(Areal const& areal, Linear const& linear)
{
return detail::disjoint::disjoint_linear_areal
<
Linear, Areal
>::apply(linear, areal);
}
};
template <typename Areal, typename Segment>
struct disjoint<Areal, Segment, 2, areal_tag, segment_tag, false>
{
static inline bool apply(Areal const& g1, Segment const& g2)
{
return detail::disjoint::disjoint_segment_areal
<
Segment, Areal
>::apply(g2, g1);
}
};
template <typename Segment, typename Areal>
struct disjoint<Segment, Areal, 2, segment_tag, areal_tag, false>
: detail::disjoint::disjoint_segment_areal<Segment, Areal>
{};
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_AREAL_HPP

View File

@@ -0,0 +1,176 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// 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-2014.
// Modifications copyright (c) 2013-2014, 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
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// 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_ALGORITHMS_DETAIL_DISJOINT_LINEAR_LINEAR_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_LINEAR_HPP
#include <cstddef>
#include <deque>
#include <boost/range.hpp>
#include <boost/geometry/util/range.hpp>
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/multi/core/tags.hpp>
#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
#include <boost/geometry/multi/algorithms/detail/overlay/get_turns.hpp>
#include <boost/geometry/algorithms/detail/overlay/do_reverse.hpp>
#include <boost/geometry/policies/disjoint_interrupt_policy.hpp>
#include <boost/geometry/policies/robustness/no_rescale_policy.hpp>
#include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace disjoint
{
template <typename Segment1, typename Segment2>
struct disjoint_segment
{
static inline bool apply(Segment1 const& segment1, Segment2 const& segment2)
{
typedef typename point_type<Segment1>::type point_type;
// We don't need to rescale to detect disjointness
typedef no_rescale_policy rescale_policy_type;
rescale_policy_type robust_policy;
typedef segment_intersection_points
<
point_type,
typename segment_ratio_type
<
point_type,
rescale_policy_type
>::type
> intersection_return_type;
intersection_return_type is
= strategy::intersection::relate_cartesian_segments
<
policies::relate::segments_intersection_points
<
intersection_return_type
>
>::apply(segment1, segment2, robust_policy);
return is.count == 0;
}
};
struct assign_disjoint_policy
{
// We want to include all points:
static bool const include_no_turn = true;
static bool const include_degenerate = true;
static bool const include_opposite = true;
// We don't assign extra info:
template
<
typename Info,
typename Point1,
typename Point2,
typename IntersectionInfo,
typename DirInfo
>
static inline void apply(Info& , Point1 const& , Point2 const&,
IntersectionInfo const&, DirInfo const&)
{}
};
template <typename Geometry1, typename Geometry2>
struct disjoint_linear
{
static inline
bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2)
{
typedef typename geometry::point_type<Geometry1>::type point_type;
typedef detail::no_rescale_policy rescale_policy_type;
typedef overlay::turn_info
<
point_type,
typename segment_ratio_type<point_type, rescale_policy_type>::type
> turn_info;
std::deque<turn_info> turns;
static const bool reverse1 = overlay::do_reverse<geometry::point_order<Geometry1>::value>::value; // should be false
static const bool reverse2 = overlay::do_reverse<geometry::point_order<Geometry2>::value>::value; // should be false
// Specify two policies:
// 1) Stop at any intersection
// 2) In assignment, include also degenerate points (which are normally skipped)
disjoint_interrupt_policy policy;
rescale_policy_type robust_policy;
geometry::get_turns
<
reverse1, reverse2,
assign_disjoint_policy
>(geometry1, geometry2, robust_policy, turns, policy);
return !policy.has_intersections;
}
};
}} // namespace detail::disjoint
#endif // DOXYGEN_NO_DETAIL
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
template <typename Linear1, typename Linear2>
struct disjoint<Linear1, Linear2, 2, linear_tag, linear_tag, false>
: detail::disjoint::disjoint_linear<Linear1, Linear2>
{};
template <typename Segment1, typename Segment2>
struct disjoint<Segment1, Segment2, 2, segment_tag, segment_tag, false>
: detail::disjoint::disjoint_segment<Segment1, Segment2>
{};
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_LINEAR_HPP

View File

@@ -0,0 +1,195 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// 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-2014.
// Modifications copyright (c) 2013-2014, 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
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// 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_ALGORITHMS_DETAIL_DISJOINT_LINEAR_SEGMENT_OR_BOX_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_SEGMENT_OR_BOX_HPP
#include <boost/range.hpp>
#include <boost/geometry/util/range.hpp>
#include <boost/geometry/core/closure.hpp>
#include <boost/geometry/geometries/segment.hpp>
#include <boost/geometry/algorithms/not_implemented.hpp>
#include <boost/geometry/views/closeable_view.hpp>
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace disjoint
{
template <typename MultiRange, typename SegmentOrBox>
struct disjoint_multirange_segment_or_box
{
static inline
bool apply(MultiRange const& multirange, SegmentOrBox const& segment_or_box)
{
typedef typename boost::range_iterator
<
MultiRange const
>::type const_iterator;
for (const_iterator it = boost::begin(multirange);
it != boost::end(multirange); ++it)
{
if ( !dispatch::disjoint
<
typename boost::range_value<MultiRange>::type,
SegmentOrBox
>::apply(*it, segment_or_box) )
{
return false;
}
}
return true;
}
};
template
<
typename Range,
closure_selector Closure,
typename SegmentOrBox
>
struct disjoint_range_segment_or_box
{
static inline
bool apply(Range const& range, SegmentOrBox const& segment_or_box)
{
typedef typename closeable_view<Range const, Closure>::type view_type;
typedef typename ::boost::range_value<view_type>::type point_type;
typedef typename ::boost::range_iterator
<
view_type const
>::type const_iterator;
typedef typename ::boost::range_size<view_type>::type size_type;
typedef typename geometry::model::referring_segment
<
point_type const
> range_segment;
view_type view(range);
const size_type count = ::boost::size(view);
if ( count == 0 )
{
return false;
}
else if ( count == 1 )
{
return dispatch::disjoint
<
point_type, SegmentOrBox
>::apply(geometry::range::front<view_type const>(view),
segment_or_box);
}
else
{
const_iterator it0 = ::boost::begin(view);
const_iterator it1 = ::boost::begin(view) + 1;
const_iterator last = ::boost::end(view);
for ( ; it1 != last ; ++it0, ++it1 )
{
range_segment rng_segment(*it0, *it1);
if ( !dispatch::disjoint
<
range_segment, SegmentOrBox
>::apply(rng_segment, segment_or_box) )
{
return false;
}
}
return true;
}
}
};
template
<
typename Linear,
typename SegmentOrBox,
typename Tag = typename tag<Linear>::type
>
struct disjoint_linear_segment_or_box
: not_implemented<Linear, SegmentOrBox>
{};
template <typename Linestring, typename SegmentOrBox>
struct disjoint_linear_segment_or_box<Linestring, SegmentOrBox, linestring_tag>
: disjoint_range_segment_or_box<Linestring, closed, SegmentOrBox>
{};
template <typename MultiLinestring, typename SegmentOrBox>
struct disjoint_linear_segment_or_box
<
MultiLinestring, SegmentOrBox, multi_linestring_tag
> : disjoint_multirange_segment_or_box<MultiLinestring, SegmentOrBox>
{};
}} // namespace detail::disjoint
#endif // DOXYGEN_NO_DETAIL
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
template <typename Linear, typename Segment>
struct disjoint<Linear, Segment, 2, linear_tag, segment_tag, false>
: detail::disjoint::disjoint_linear_segment_or_box<Linear, Segment>
{};
template <typename Linear, typename Box, std::size_t DimensionCount>
struct disjoint<Linear, Box, DimensionCount, linear_tag, box_tag, false>
: detail::disjoint::disjoint_linear_segment_or_box<Linear, Box>
{};
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_SEGMENT_OR_BOX_HPP

View File

@@ -0,0 +1,94 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// 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-2014.
// Modifications copyright (c) 2013-2014, 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
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// 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_ALGORITHMS_DETAIL_DISJOINT_POINT_BOX_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_BOX_HPP
#include <cstddef>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace disjoint
{
template
<
typename Point, typename Box,
std::size_t Dimension, std::size_t DimensionCount
>
struct point_box
{
static inline bool apply(Point const& point, Box const& box)
{
if (get<Dimension>(point) < get<min_corner, Dimension>(box)
|| get<Dimension>(point) > get<max_corner, Dimension>(box))
{
return true;
}
return point_box
<
Point, Box,
Dimension + 1, DimensionCount
>::apply(point, box);
}
};
template <typename Point, typename Box, std::size_t DimensionCount>
struct point_box<Point, Box, DimensionCount, DimensionCount>
{
static inline bool apply(Point const& , Box const& )
{
return false;
}
};
}} // namespace detail::equals
#endif // DOXYGEN_NO_DETAIL
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
template <typename Point, typename Box, std::size_t DimensionCount>
struct disjoint<Point, Box, DimensionCount, point_tag, box_tag, false>
: detail::disjoint::point_box<Point, Box, 0, DimensionCount>
{};
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_BOX_HPP

View File

@@ -0,0 +1,112 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// 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-2014.
// Modifications copyright (c) 2013-2014, 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
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// 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_ALGORITHMS_DETAIL_DISJOINT_POINT_GEOMETRY_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_GEOMETRY_HPP
#include <boost/geometry/geometries/segment.hpp>
#include <boost/geometry/algorithms/covered_by.hpp>
#include <boost/geometry/multi/algorithms/covered_by.hpp>
#include <boost/geometry/algorithms/detail/disjoint/linear_linear.hpp>
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace disjoint
{
template<typename Point, typename Geometry>
struct disjoint_point_linear
{
static inline
bool apply(Point const& pt, Geometry const& g)
{
return !geometry::covered_by(pt, g);
}
};
template <typename Geometry1, typename Geometry2>
struct reverse_covered_by
{
static inline
bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2)
{
return !geometry::covered_by(geometry1, geometry2);
}
};
}} // namespace detail::disjoint
#endif // DOXYGEN_NO_DETAIL
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
template<typename Point, typename Linear, std::size_t DimensionCount>
struct disjoint<Point, Linear, DimensionCount, point_tag, linear_tag, false>
: public detail::disjoint::disjoint_point_linear<Point, Linear>
{};
template <typename Point, typename Areal, std::size_t DimensionCount>
struct disjoint<Point, Areal, DimensionCount, point_tag, areal_tag, false>
: detail::disjoint::reverse_covered_by<Point, Areal>
{};
template<typename Point, typename Segment, std::size_t DimensionCount>
struct disjoint<Point, Segment, DimensionCount, point_tag, segment_tag, false>
{
static inline bool apply(Point const& point, Segment const& segment)
{
typedef geometry::model::referring_segment<Point const> other_segment;
other_segment other(point, point);
return detail::disjoint::disjoint_segment
<
Segment, other_segment
>::apply(segment, other);
}
};
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_GEOMETRY_HPP

View File

@@ -1,9 +1,15 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland
// 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-2014.
// Modifications copyright (c) 2013-2014, 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
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@@ -19,9 +25,13 @@
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
namespace boost { namespace geometry
{
@@ -81,23 +91,21 @@ inline bool disjoint_point_point(Point1 const& point1, Point2 const& point2)
#endif // DOXYGEN_NO_DETAIL
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace equals
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
/*!
\brief Internal utility function to detect of points are disjoint
\note To avoid circular references
*/
template <typename Point1, typename Point2>
inline bool equals_point_point(Point1 const& point1, Point2 const& point2)
{
return ! detail::disjoint::disjoint_point_point(point1, point2);
}
template <typename Point1, typename Point2, std::size_t DimensionCount>
struct disjoint<Point1, Point2, DimensionCount, point_tag, point_tag, false>
: detail::disjoint::point_point<Point1, Point2, 0, DimensionCount>
{};
}} // namespace detail::equals
#endif // DOXYGEN_NO_DETAIL
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
}} // namespace boost::geometry

View File

@@ -0,0 +1,272 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// 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-2014.
// Modifications copyright (c) 2013-2014, 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
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// 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_ALGORITHMS_DETAIL_DISJOINT_SEGMENT_BOX_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_SEGMENT_BOX_HPP
#include <cstddef>
#include <utility>
#include <boost/numeric/conversion/cast.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/algorithms/dispatch/disjoint.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace disjoint
{
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);
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 ( 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;
}
};
//=========================================================================
template <typename Segment, typename Box>
struct disjoint_segment_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 disjoint_segment_box_impl
<
relative_distance_type, segment_point_type, Box,
0, dimension<Box>::value
>::apply(p0, p1, box);
}
};
}} // namespace detail::disjoint
#endif // DOXYGEN_NO_DETAIL
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
template <typename Segment, typename Box, std::size_t DimensionCount>
struct disjoint<Segment, Box, DimensionCount, segment_tag, box_tag, false>
: detail::disjoint::disjoint_segment_box<Segment, Box>
{};
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_SEGMENT_BOX_HPP

View File

@@ -0,0 +1,52 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// 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-2014.
// Modifications copyright (c) 2013-2014, 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
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// 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_ALGORITHMS_DETAIL_EQUALS_POINT_POINT_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EQUALS_POINT_POINT_HPP
#include <boost/geometry/algorithms/detail/disjoint/point_point.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace equals
{
/*!
\brief Internal utility function to detect of points are disjoint
\note To avoid circular references
*/
template <typename Point1, typename Point2>
inline bool equals_point_point(Point1 const& point1, Point2 const& point2)
{
return ! detail::disjoint::disjoint_point_point(point1, point2);
}
}} // namespace detail::equals
#endif // DOXYGEN_NO_DETAIL
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_EQUALS_POINT_POINT_HPP

View File

@@ -17,6 +17,7 @@
#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
#include <boost/geometry/algorithms/detail/overlay/self_turn_points.hpp>
#include <boost/geometry/policies/disjoint_interrupt_policy.hpp>
#include <boost/geometry/policies/robustness/robust_point_type.hpp>
#include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
#include <boost/geometry/policies/robustness/get_rescale_policy.hpp>

View File

@@ -13,7 +13,7 @@
#include <boost/range.hpp>
#include <boost/geometry/algorithms/append.hpp>
#include <boost/geometry/algorithms/detail/disjoint.hpp>
#include <boost/geometry/algorithms/detail/equals/point_point.hpp>

View File

@@ -13,7 +13,7 @@
#include <boost/geometry/algorithms/append.hpp>
#include <boost/geometry/algorithms/detail/point_is_spike_or_equal.hpp>
#include <boost/geometry/algorithms/detail/disjoint.hpp>
#include <boost/geometry/algorithms/detail/equals/point_point.hpp>
namespace boost { namespace geometry

View File

@@ -26,7 +26,7 @@
#include <boost/geometry/algorithms/not_implemented.hpp>
#include <boost/geometry/algorithms/detail/relate/less.hpp>
#include <boost/geometry/algorithms/detail/disjoint/point_point.hpp>
#include <boost/geometry/algorithms/detail/equals/point_point.hpp>
#include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>

View File

@@ -18,7 +18,7 @@
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/algorithms/detail/disjoint.hpp>
#include <boost/geometry/algorithms/detail/disjoint/box_box.hpp>
#include <boost/geometry/algorithms/detail/partition.hpp>
#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>

View File

@@ -26,7 +26,7 @@
#include <boost/geometry/algorithms/assign.hpp>
#include <boost/geometry/algorithms/detail/convert_point_to_point.hpp>
#include <boost/geometry/algorithms/detail/disjoint.hpp>
#include <boost/geometry/algorithms/detail/equals/point_point.hpp>
namespace boost { namespace geometry

View File

@@ -15,7 +15,7 @@
#include <boost/geometry/algorithms/num_points.hpp>
#include <boost/geometry/algorithms/detail/sub_range.hpp>
#include <boost/geometry/algorithms/detail/disjoint/point_point.hpp>
#include <boost/geometry/algorithms/detail/equals/point_point.hpp>
namespace boost { namespace geometry
{

View File

@@ -14,7 +14,7 @@
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_POINT_POINT_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_POINT_POINT_HPP
#include <boost/geometry/algorithms/detail/disjoint/point_point.hpp>
#include <boost/geometry/algorithms/detail/equals/point_point.hpp>
#include <boost/geometry/algorithms/detail/within/point_in_geometry.hpp>
#include <boost/geometry/algorithms/detail/relate/less.hpp>

View File

@@ -13,7 +13,7 @@
#include <boost/geometry/util/range.hpp>
#include <boost/geometry/algorithms/detail/disjoint/point_point.hpp>
#include <boost/geometry/algorithms/detail/equals/point_point.hpp>
#include <boost/geometry/policies/compare.hpp>
namespace boost { namespace geometry {

View File

@@ -24,7 +24,7 @@
#include <boost/type_traits/is_same.hpp>
#include <boost/range.hpp>
#include <boost/geometry/algorithms/detail/disjoint/point_point.hpp>
#include <boost/geometry/algorithms/detail/equals/point_point.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/strategies/concepts/within_concept.hpp>

View File

@@ -1,12 +1,15 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
// 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.
// Modifications copyright (c) 2013, Oracle and/or its affiliates.
// This file was modified by Oracle on 2013-2014.
// Modifications copyright (c) 2013-2014, 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
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@@ -18,591 +21,7 @@
#ifndef BOOST_GEOMETRY_ALGORITHMS_DISJOINT_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DISJOINT_HPP
#include <cstddef>
#include <deque>
#include <boost/mpl/if.hpp>
#include <boost/range.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/variant_fwd.hpp>
#include <boost/static_assert.hpp>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/core/reverse_dispatch.hpp>
#include <boost/geometry/algorithms/within.hpp>
#include <boost/geometry/algorithms/detail/disjoint.hpp>
#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
#include <boost/geometry/algorithms/detail/point_on_border.hpp>
#include <boost/geometry/multi/algorithms/detail/point_on_border.hpp>
#include <boost/geometry/algorithms/point_on_surface.hpp>
#include <boost/geometry/algorithms/detail/for_each_range.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/algorithms/detail/overlay/do_reverse.hpp>
#include <boost/geometry/views/segment_view.hpp>
#include <boost/geometry/policies/robustness/no_rescale_policy.hpp>
#include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace disjoint
{
template<typename Geometry>
struct check_each_ring_for_within
{
bool has_within;
Geometry const& m_geometry;
inline check_each_ring_for_within(Geometry const& g)
: has_within(false)
, m_geometry(g)
{}
template <typename Range>
inline void apply(Range const& range)
{
if ( geometry::within(geometry::return_point_on_surface(range), m_geometry) )
{
has_within = true;
}
}
};
template <typename FirstGeometry, typename SecondGeometry>
inline bool rings_containing(FirstGeometry const& geometry1,
SecondGeometry const& geometry2)
{
check_each_ring_for_within<FirstGeometry> checker(geometry1);
geometry::detail::for_each_range(geometry2, checker);
return checker.has_within;
}
struct assign_disjoint_policy
{
// We want to include all points:
static bool const include_no_turn = true;
static bool const include_degenerate = true;
static bool const include_opposite = true;
// We don't assign extra info:
template
<
typename Info,
typename Point1,
typename Point2,
typename IntersectionInfo,
typename DirInfo
>
static inline void apply(Info& , Point1 const& , Point2 const&,
IntersectionInfo const&, DirInfo const&)
{}
};
template <typename Geometry1, typename Geometry2>
struct disjoint_linear
{
static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2)
{
typedef typename geometry::point_type<Geometry1>::type point_type;
typedef detail::no_rescale_policy rescale_policy_type;
typedef overlay::turn_info
<
point_type,
typename segment_ratio_type<point_type, rescale_policy_type>::type
> turn_info;
std::deque<turn_info> turns;
static const bool reverse1 = overlay::do_reverse<geometry::point_order<Geometry1>::value>::value; // should be false
static const bool reverse2 = overlay::do_reverse<geometry::point_order<Geometry2>::value>::value; // should be false
// Specify two policies:
// 1) Stop at any intersection
// 2) In assignment, include also degenerate points (which are normally skipped)
disjoint_interrupt_policy policy;
rescale_policy_type robust_policy;
geometry::get_turns
<
reverse1, reverse2,
assign_disjoint_policy
>(geometry1, geometry2, robust_policy, turns, policy);
return !policy.has_intersections;
}
};
template <typename Segment1, typename Segment2>
struct disjoint_segment
{
static inline bool apply(Segment1 const& segment1, Segment2 const& segment2)
{
typedef typename point_type<Segment1>::type point_type;
// We don't need to rescale to detect disjointness
typedef no_rescale_policy rescale_policy_type;
rescale_policy_type robust_policy;
typedef segment_intersection_points
<
point_type,
typename segment_ratio_type
<
point_type,
rescale_policy_type
>::type
> intersection_return_type;
intersection_return_type is
= strategy::intersection::relate_cartesian_segments
<
policies::relate::segments_intersection_points
<
intersection_return_type
>
>::apply(segment1, segment2, robust_policy);
return is.count == 0;
}
};
template <typename Geometry1, typename Geometry2>
struct general_areal
{
static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2)
{
if (! disjoint_linear<Geometry1, Geometry2>::apply(geometry1, geometry2))
{
return false;
}
// If there is no intersection of segments, they might located
// inside each other
// We check that using a point on the surface, and see if that is inside
// the other geometry. And vice versa.
typedef typename geometry::point_type<Geometry1>::type point_type1;
typedef typename geometry::point_type<Geometry2>::type point_type2;
if (rings_containing(geometry1, geometry2)
|| rings_containing(geometry2, geometry1))
{
return false;
}
return true;
}
};
template <typename Segment, typename Box>
struct disjoint_segment_box
{
static inline bool apply(Segment const& segment, Box const& box)
{
typedef typename point_type<Segment>::type point_type;
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_intersection<point_type, Box>::apply(p0, p1, box);
}
};
template <typename Linestring, typename Box>
struct disjoint_linestring_box
{
static inline bool apply(Linestring const& linestring, Box const& box)
{
typedef typename ::boost::range_value<Linestring>::type point_type;
typedef typename ::boost::range_const_iterator<Linestring>::type const_iterator;
typedef typename ::boost::range_size<Linestring>::type size_type;
const size_type count = ::boost::size(linestring);
if ( count == 0 )
return false;
else if ( count == 1 )
return detail::disjoint::point_box<point_type, Box, 0, dimension<point_type>::value>
::apply(*::boost::begin(linestring), box);
else
{
const_iterator it0 = ::boost::begin(linestring);
const_iterator it1 = ::boost::begin(linestring) + 1;
const_iterator last = ::boost::end(linestring);
for ( ; it1 != last ; ++it0, ++it1 )
{
if ( detail::disjoint::segment_box_intersection<point_type, Box>::apply(*it0, *it1, box) )
return false;
}
return true;
}
}
};
template<typename Point, typename Geometry>
struct disjoint_point_linear
{
static inline
bool apply(Point const& pt, Geometry const& g)
{
return !geometry::covered_by(pt, g);
}
};
// computes disjointness of segment and linestring
template<typename Linestring, typename Segment>
struct disjoint_linestring_segment
{
static inline
bool apply(Linestring const& ls, Segment const& seg)
{
return disjoint_linear
<
Linestring, segment_view<Segment>
>::apply(ls, geometry::segment_view<Segment>(seg));
}
};
template<typename Geometry1, typename Geometry2>
struct disjoint_linear_areal
{
static inline
bool apply(Geometry1 const& g1, Geometry2 const& g2)
{
// if there are intersections - return false
if ( !disjoint_linear<Geometry1, Geometry2>::apply(g1, g2) )
return false;
typedef typename point_type<Geometry1>::type point1_type;
point1_type p;
geometry::point_on_border(p, g1);
return !geometry::covered_by(p, g2);
}
};
template<typename Segment, typename Geometry>
struct disjoint_segment_areal
{
static inline
bool apply(Segment const& seg, Geometry const& g)
{
return disjoint_linear_areal
<
segment_view<Segment>, Geometry
>::apply(segment_view<Segment>(seg), g);
}
};
}} // namespace detail::disjoint
#endif // DOXYGEN_NO_DETAIL
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
template
<
typename Geometry1, typename Geometry2,
std::size_t DimensionCount = dimension<Geometry1>::type::value,
typename Tag1 = typename tag<Geometry1>::type,
typename Tag2 = typename tag<Geometry2>::type,
bool Reverse = reverse_dispatch<Geometry1, Geometry2>::type::value
>
struct disjoint
: detail::disjoint::general_areal<Geometry1, Geometry2>
{};
// If reversal is needed, perform it
template
<
typename Geometry1, typename Geometry2,
std::size_t DimensionCount,
typename Tag1, typename Tag2
>
struct disjoint<Geometry1, Geometry2, DimensionCount, Tag1, Tag2, true>
: disjoint<Geometry2, Geometry1, DimensionCount, Tag2, Tag1, false>
{
static inline bool apply(Geometry1 const& g1, Geometry2 const& g2)
{
return disjoint
<
Geometry2, Geometry1,
DimensionCount,
Tag2, Tag1
>::apply(g2, g1);
}
};
template <typename Point1, typename Point2, std::size_t DimensionCount, bool Reverse>
struct disjoint<Point1, Point2, DimensionCount, point_tag, point_tag, Reverse>
: detail::disjoint::point_point<Point1, Point2, 0, DimensionCount>
{};
template <typename Box1, typename Box2, std::size_t DimensionCount, bool Reverse>
struct disjoint<Box1, Box2, DimensionCount, box_tag, box_tag, Reverse>
: detail::disjoint::box_box<Box1, Box2, 0, DimensionCount>
{};
template <typename Point, typename Box, std::size_t DimensionCount, bool Reverse>
struct disjoint<Point, Box, DimensionCount, point_tag, box_tag, Reverse>
: detail::disjoint::point_box<Point, Box, 0, DimensionCount>
{};
template <typename Point, typename Ring, std::size_t DimensionCount, bool Reverse>
struct disjoint<Point, Ring, DimensionCount, point_tag, ring_tag, Reverse>
: detail::disjoint::reverse_covered_by<Point, Ring>
{};
template <typename Point, typename Polygon, std::size_t DimensionCount, bool Reverse>
struct disjoint<Point, Polygon, DimensionCount, point_tag, polygon_tag, Reverse>
: detail::disjoint::reverse_covered_by<Point, Polygon>
{};
template <typename Linestring1, typename Linestring2, bool Reverse>
struct disjoint<Linestring1, Linestring2, 2, linestring_tag, linestring_tag, Reverse>
: detail::disjoint::disjoint_linear<Linestring1, Linestring2>
{};
template <typename Segment1, typename Segment2, bool Reverse>
struct disjoint<Segment1, Segment2, 2, segment_tag, segment_tag, Reverse>
: detail::disjoint::disjoint_segment<Segment1, Segment2>
{};
template <typename Segment, typename Box, std::size_t DimensionCount, bool Reverse>
struct disjoint<Segment, Box, DimensionCount, segment_tag, box_tag, Reverse>
: detail::disjoint::disjoint_segment_box<Segment, Box>
{};
template <typename Linestring, typename Box, std::size_t DimensionCount, bool Reverse>
struct disjoint<Linestring, Box, DimensionCount, linestring_tag, box_tag, Reverse>
: detail::disjoint::disjoint_linestring_box<Linestring, Box>
{};
//template <typename Linestring, typename Segment, bool Reverse>
//struct disjoint<Linestring, Segment, 2, linestring_tag, segment_tag, Reverse>
// : detail::disjoint::disjoint_linear<Linestring, Segment>
//{};
template<typename Linestring, typename Segment, std::size_t DimensionCount, bool Reverse>
struct disjoint<Linestring, Segment, DimensionCount, linestring_tag, segment_tag, Reverse>
: detail::disjoint::disjoint_linestring_segment<Linestring, Segment>
{};
template<typename Segment, typename Ring, std::size_t DimensionCount, bool Reverse>
struct disjoint<Segment, Ring, DimensionCount, segment_tag, ring_tag, Reverse>
: detail::disjoint::disjoint_segment_areal<Segment, Ring>
{};
template<typename Polygon, typename Segment, std::size_t DimensionCount, bool Reverse>
struct disjoint<Polygon, Segment, DimensionCount, polygon_tag, segment_tag, Reverse>
{
static inline
bool apply(Polygon const& g1, Segment const& g2)
{
return detail::disjoint::disjoint_segment_areal<Segment, Polygon>::apply(g2, g1);
}
};
template<typename Linestring, typename Polygon, std::size_t DimensionCount, bool Reverse>
struct disjoint<Linestring, Polygon, DimensionCount, linestring_tag, polygon_tag, Reverse>
: public detail::disjoint::disjoint_linear_areal<Linestring, Polygon>
{};
template<typename Linestring, typename Ring, std::size_t DimensionCount, bool Reverse>
struct disjoint<Linestring, Ring, DimensionCount, linestring_tag, ring_tag, Reverse>
: public detail::disjoint::disjoint_linear_areal<Linestring, Ring>
{};
template<typename Linestring, typename MultiLinestring, std::size_t DimensionCount, bool Reverse>
struct disjoint<Linestring, MultiLinestring, DimensionCount, linestring_tag, multi_linestring_tag, Reverse>
: public detail::disjoint::disjoint_linear<Linestring, MultiLinestring>
{};
template<typename Polygon, typename MultiLinestring, std::size_t DimensionCount, bool Reverse>
struct disjoint<Polygon, MultiLinestring, DimensionCount, polygon_tag, multi_linestring_tag, Reverse>
{
static inline bool apply(Polygon const& polygon,
MultiLinestring const& multilinestring)
{
return detail::disjoint::disjoint_linear_areal
<
MultiLinestring,
Polygon
>::apply(multilinestring, polygon);
}
};
template<typename MultiLinestring, typename Ring, std::size_t DimensionCount, bool Reverse>
struct disjoint<MultiLinestring, Ring, DimensionCount, multi_linestring_tag, ring_tag, Reverse>
: public detail::disjoint::disjoint_linear_areal<MultiLinestring, Ring>
{};
template<typename Linestring, typename MultiPolygon, std::size_t DimensionCount, bool Reverse>
struct disjoint<Linestring, MultiPolygon, DimensionCount, linestring_tag, multi_polygon_tag, Reverse>
: public detail::disjoint::disjoint_linear_areal<Linestring, MultiPolygon>
{};
template<typename MultiLinestring, typename MultiPolygon, std::size_t DimensionCount, bool Reverse>
struct disjoint<MultiLinestring, MultiPolygon, DimensionCount, multi_linestring_tag, multi_polygon_tag, Reverse>
: public detail::disjoint::disjoint_linear_areal<MultiLinestring, MultiPolygon>
{};
template<typename MultiLinestring1, typename MultiLinestring2, std::size_t DimensionCount, bool Reverse>
struct disjoint<MultiLinestring1, MultiLinestring2, DimensionCount, multi_linestring_tag, multi_linestring_tag, Reverse>
: public detail::disjoint::disjoint_linear<MultiLinestring1, MultiLinestring2>
{};
template<typename Point, typename Linestring, std::size_t DimensionCount, bool Reverse>
struct disjoint<Point, Linestring, DimensionCount, point_tag, linestring_tag, Reverse>
: public detail::disjoint::disjoint_point_linear<Point, Linestring>
{};
template<typename Point, typename MultiLinestring, std::size_t DimensionCount, bool Reverse>
struct disjoint<Point, MultiLinestring, DimensionCount, point_tag, multi_linestring_tag, Reverse>
: public detail::disjoint::disjoint_point_linear<Point, MultiLinestring>
{};
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
namespace resolve_variant {
template <typename Geometry1, typename Geometry2>
struct disjoint
{
static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2)
{
concept::check_concepts_and_equal_dimensions
<
Geometry1 const,
Geometry2 const
>();
return dispatch::disjoint<Geometry1, Geometry2>::apply(geometry1, geometry2);
}
};
template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2>
struct disjoint<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2>
{
struct visitor: boost::static_visitor<bool>
{
Geometry2 const& m_geometry2;
visitor(Geometry2 const& geometry2): m_geometry2(geometry2) {}
template <typename Geometry1>
bool operator()(Geometry1 const& geometry1) const
{
return disjoint<Geometry1, Geometry2>::apply(geometry1, m_geometry2);
}
};
static inline bool
apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry1,
Geometry2 const& geometry2)
{
return boost::apply_visitor(visitor(geometry2), geometry1);
}
};
template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)>
struct disjoint<Geometry1, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
{
struct visitor: boost::static_visitor<bool>
{
Geometry1 const& m_geometry1;
visitor(Geometry1 const& geometry1): m_geometry1(geometry1) {}
template <typename Geometry2>
bool operator()(Geometry2 const& geometry2) const
{
return disjoint<Geometry1, Geometry2>::apply(m_geometry1, geometry2);
}
};
static inline bool
apply(Geometry1 const& geometry1,
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry2)
{
return boost::apply_visitor(visitor(geometry1), geometry2);
}
};
template <
BOOST_VARIANT_ENUM_PARAMS(typename T1),
BOOST_VARIANT_ENUM_PARAMS(typename T2)
>
struct disjoint<
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)>,
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)>
>
{
struct visitor: boost::static_visitor<bool>
{
template <typename Geometry1, typename Geometry2>
bool operator()(Geometry1 const& geometry1,
Geometry2 const& geometry2) const
{
return disjoint<Geometry1, Geometry2>::apply(geometry1, geometry2);
}
};
static inline bool
apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)> const& geometry1,
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)> const& geometry2)
{
return boost::apply_visitor(visitor(), geometry1, geometry2);
}
};
} // namespace resolve_variant
/*!
\brief \brief_check2{are disjoint}
\ingroup disjoint
\tparam Geometry1 \tparam_geometry
\tparam Geometry2 \tparam_geometry
\param geometry1 \param_geometry
\param geometry2 \param_geometry
\return \return_check2{are disjoint}
\qbk{[include reference/algorithms/disjoint.qbk]}
*/
template <typename Geometry1, typename Geometry2>
inline bool disjoint(Geometry1 const& geometry1,
Geometry2 const& geometry2)
{
return resolve_variant::disjoint<Geometry1, Geometry2>::apply(geometry1, geometry2);
}
}} // namespace boost::geometry
#include <boost/geometry/algorithms/detail/disjoint/interface.hpp>
#include <boost/geometry/algorithms/detail/disjoint/implementation.hpp>
#endif // BOOST_GEOMETRY_ALGORITHMS_DISJOINT_HPP

View File

@@ -0,0 +1,70 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// 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-2014.
// Modifications copyright (c) 2013-2014, 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
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// 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_ALGORITHMS_DISPATCH_DISJOINT_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DISPATCH_DISJOINT_HPP
#include <cstddef>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tag_cast.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/core/reverse_dispatch.hpp>
#include <boost/geometry/algorithms/not_implemented.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
template
<
typename Geometry1, typename Geometry2,
std::size_t DimensionCount = dimension<Geometry1>::type::value,
typename Tag1 = typename tag_cast
<
typename tag<Geometry1>::type,
segment_tag, box_tag, linear_tag, areal_tag
>::type,
typename Tag2 = typename tag_cast
<
typename tag<Geometry2>::type,
segment_tag, box_tag, linear_tag, areal_tag
>::type,
bool Reverse = reverse_dispatch<Geometry1, Geometry2>::type::value
>
struct disjoint
: not_implemented<Geometry1, Geometry2>
{};
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DISPATCH_DISJOINT_HPP

View File

@@ -32,7 +32,7 @@
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/algorithms/detail/disjoint.hpp>
#include <boost/geometry/algorithms/detail/equals/point_point.hpp>
#include <boost/geometry/algorithms/detail/not.hpp>
#include <boost/geometry/algorithms/not_implemented.hpp>

View File

@@ -116,6 +116,18 @@ struct ttmath_big : ttmath::Big<1,4>
: ttmath::Big<1,4>(v)
{}
// needed in order to work with boost::geometry::math::abs
inline ttmath_big operator-() const
{
return ttmath::Big<1,4>::operator-();
}
// needed because unary operator-() is defined (above)
inline ttmath_big operator-(ttmath_big const& other) const
{
return ttmath::Big<1,4>::operator-(other);
}
/*
inline operator double() const
{

View File

@@ -16,7 +16,6 @@
#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
#include <boost/geometry/multi/algorithms/distance.hpp>
#include <boost/geometry/multi/views/detail/range_type.hpp>
#include <boost/geometry/multi/algorithms/detail/sections/range_by_section.hpp>

View File

@@ -1,8 +1,13 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2012 Bruno Lalande, Paris, France.
// Copyright (c) 2012 Mateusz Loskot, London, UK.
// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2012-2014 Bruno Lalande, Paris, France.
// Copyright (c) 2012-2014 Mateusz Loskot, London, UK.
// This file was modified by Oracle on 2014.
// Modifications copyright (c) 2014, Oracle and/or its affiliates.
// 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
@@ -11,35 +16,6 @@
#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DISJOINT_HPP
#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DISJOINT_HPP
#include <boost/geometry/algorithms/disjoint.hpp>
#include <boost/geometry/multi/algorithms/covered_by.hpp>
#include <boost/geometry/multi/algorithms/detail/extreme_points.hpp>
#include <boost/geometry/multi/core/tags.hpp>
#include <boost/geometry/multi/geometries/concepts/check.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
template <typename Point, typename MultiPolygon>
struct disjoint<Point, MultiPolygon, 2, point_tag, multi_polygon_tag, false>
: detail::disjoint::reverse_covered_by<Point, MultiPolygon>
{};
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DISJOINT_HPP

View File

@@ -0,0 +1,67 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// 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-2014.
// Modifications copyright (c) 2013-2014, 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
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// 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_ALGORITHMS_POLICIES_DISJOINT_INTERRUPT_POLICY_HPP
#define BOOST_GEOMETRY_ALGORITHMS_POLICIES_DISJOINT_INTERRUPT_POLICY_HPP
#include <boost/range.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace disjoint
{
struct disjoint_interrupt_policy
{
static bool const enabled = true;
bool has_intersections;
inline disjoint_interrupt_policy()
: has_intersections(false)
{}
template <typename Range>
inline bool apply(Range const& range)
{
// If there is any IP in the range, it is NOT disjoint
if (boost::size(range) > 0)
{
has_intersections = true;
return true;
}
return false;
}
};
}} // namespace detail::disjoint
#endif // DOXYGEN_NO_DETAIL
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_POLICIES_DISJOINT_INTERRUPT_POLICY_HPP

View File

@@ -11,7 +11,7 @@
#ifndef BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POINT_HPP
#define BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POINT_HPP
#include <boost/geometry/algorithms/detail/disjoint/point_point.hpp>
#include <boost/geometry/algorithms/detail/equals/point_point.hpp>
#include <boost/geometry/strategies/covered_by.hpp>
#include <boost/geometry/strategies/within.hpp>

View File

@@ -20,7 +20,7 @@
#include <boost/geometry/arithmetic/determinant.hpp>
#include <boost/geometry/algorithms/detail/assign_values.hpp>
#include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
#include <boost/geometry/algorithms/detail/disjoint/point_point.hpp>
#include <boost/geometry/algorithms/detail/equals/point_point.hpp>
#include <boost/geometry/algorithms/detail/recalculate.hpp>
#include <boost/geometry/util/math.hpp>

View File

@@ -30,6 +30,7 @@ test-suite boost-geometry-algorithms
[ run difference_linear_linear.cpp ]
[ run difference_pl_pl.cpp ]
[ run disjoint.cpp ]
[ run disjoint_coverage.cpp ]
[ run distance.cpp : : : <toolset>msvc:<cxxflags>/bigobj ]
[ run distance_areal_areal.cpp ]
[ run distance_linear_areal.cpp ]

File diff suppressed because it is too large Load Diff