~ubuntu-branches/ubuntu/saucy/merkaartor/saucy

« back to all changes in this revision

Viewing changes to include/builtin-ggl/ggl/algorithms/intersects.hpp

Tags: upstream-0.15.3+svn20934
ImportĀ upstreamĀ versionĀ 0.15.3+svn20934

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Generic Geometry Library
 
2
//
 
3
// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
 
4
// Copyright Bruno Lalande 2008, 2009
 
5
// Use, modification and distribution is subject to the Boost Software License,
 
6
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 
7
// http://www.boost.org/LICENSE_1_0.txt)
 
8
 
 
9
#ifndef GGL_ALGORITHMS_INTERSECTS_HPP
 
10
#define GGL_ALGORITHMS_INTERSECTS_HPP
 
11
 
 
12
#include <ggl/algorithms/intersection_linestring.hpp>
 
13
 
 
14
#include <ggl/algorithms/overlay/get_intersection_points.hpp>
 
15
#include <ggl/algorithms/overlay/self_intersection_points.hpp>
 
16
#include <ggl/algorithms/overlay/adapt_turns.hpp>
 
17
#include <ggl/algorithms/overlay/enrich_intersection_points.hpp>
 
18
#include <ggl/algorithms/overlay/traverse.hpp>
 
19
 
 
20
#include <ggl/algorithms/assign.hpp>
 
21
#include <ggl/algorithms/convert.hpp>
 
22
#include <ggl/algorithms/within.hpp>
 
23
 
 
24
 
 
25
 
 
26
namespace ggl
 
27
{
 
28
 
 
29
/*!
 
30
    \brief Determine if there is at least one intersection
 
31
        (crossing or self-tangency)
 
32
    \note This function can be called for one geometry (self-intersection) and
 
33
        also for two geometries (intersection)
 
34
    \ingroup overlay
 
35
    \tparam Geometry geometry type
 
36
    \param geometry geometry
 
37
    \return TRUE if there are intersections, else FALSE
 
38
 */
 
39
template <typename Geometry>
 
40
inline bool intersects(Geometry const& geometry)
 
41
{
 
42
    typedef typename boost::remove_const<Geometry>::type ncg_type;
 
43
 
 
44
    typedef std::vector<ggl::detail::intersection::intersection_point
 
45
        <typename ggl::point_type<Geometry>::type> > ip_vector;
 
46
 
 
47
    ip_vector ips;
 
48
 
 
49
    dispatch::self_intersection_points
 
50
            <
 
51
                typename tag<ncg_type>::type,
 
52
                is_multi<ncg_type>::type::value,
 
53
                ncg_type,
 
54
                ip_vector
 
55
            >::apply(geometry, true, ips);
 
56
    return ips.size() > 0;
 
57
}
 
58
 
 
59
} // ggl
 
60
 
 
61
#endif //GGL_ALGORITHMS_INTERSECTS_HPP