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

« back to all changes in this revision

Viewing changes to include/ggl/algorithms/overlaps.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Bernd Zeimetz
  • Date: 2009-09-13 00:52:12 UTC
  • mto: (1.2.7 upstream) (0.1.3 upstream) (3.1.7 sid)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20090913005212-pjecal8zxm07x0fj
ImportĀ upstreamĀ versionĀ 0.14+svnfixes~20090912

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_OVERLAPS_HPP
 
10
#define GGL_ALGORITHMS_OVERLAPS_HPP
 
11
 
 
12
#include <ggl/core/access.hpp>
 
13
 
 
14
/*!
 
15
\defgroup overlap overlap detection
 
16
\par Source descriptions:
 
17
- Egenhofer: Two objects overlap if they have common interior faces and the bounding faces have common parts
 
18
with the opposite interior faces.
 
19
 
 
20
\note Implemented in scratch the Generic Geometry library. Will be reworked internally to support more geometries
 
21
but function call will stay as it is now.
 
22
\see http://docs.codehaus.org/display/GEOTDOC/02+Geometry+Relationships#02GeometryRelationships-Overlaps
 
23
where is stated that "inside" is not an "overlap", this is probably true and should then be implemented as such.
 
24
 
 
25
*/
 
26
 
 
27
namespace ggl
 
28
{
 
29
 
 
30
/*!
 
31
    \brief Determines overlap between two geometries
 
32
    \details parameters are now boxes but in the future will be geometries
 
33
    \ingroup overlap
 
34
    \return true if there is overlap
 
35
 */
 
36
template <typename B>
 
37
inline bool overlaps(const B& b1, const B& b2)
 
38
{
 
39
    return !(
 
40
            get<max_corner, 0>(b1) <= get<min_corner, 0>(b2) ||
 
41
            get<min_corner, 0>(b1) >= get<max_corner, 0>(b2) ||
 
42
            get<max_corner, 1>(b1) <= get<min_corner, 1>(b2) ||
 
43
            get<min_corner, 1>(b1) >= get<max_corner, 1>(b2)
 
44
            );
 
45
 
 
46
}
 
47
 
 
48
} // namespace ggl
 
49
 
 
50
#endif // GGL_ALGORITHMS_OVERLAPS_HPP