/src/geos/include/geos/geomgraph/index/MonotoneChainIndexer.h
Line | Count | Source |
1 | | /********************************************************************** |
2 | | * |
3 | | * GEOS - Geometry Engine Open Source |
4 | | * http://geos.osgeo.org |
5 | | * |
6 | | * Copyright (C) 2005-2006 Refractions Research Inc. |
7 | | * Copyright (C) 2001-2002 Vivid Solutions Inc. |
8 | | * |
9 | | * This is free software; you can redistribute and/or modify it under |
10 | | * the terms of the GNU Lesser General Public Licence as published |
11 | | * by the Free Software Foundation. |
12 | | * See the COPYING file for more information. |
13 | | * |
14 | | **********************************************************************/ |
15 | | |
16 | | #pragma once |
17 | | |
18 | | #include <vector> |
19 | | #include <geos/export.h> |
20 | | |
21 | | // Forward declarations |
22 | | namespace geos { |
23 | | namespace geom { |
24 | | class CoordinateSequence; |
25 | | } |
26 | | } |
27 | | |
28 | | namespace geos { |
29 | | namespace geomgraph { // geos::geomgraph |
30 | | namespace index { // geos::geomgraph::index |
31 | | |
32 | | /// \brief MonotoneChains are a way of partitioning the segments of an edge to |
33 | | /// allow for fast searching of intersections. |
34 | | /// |
35 | | /// Specifically, a sequence of contiguous line segments is a monotone chain |
36 | | /// iff all the vectors defined by the oriented segments lies in the same |
37 | | /// quadrant. |
38 | | /// |
39 | | /// Monotone Chains have the following useful properties: |
40 | | /// |
41 | | /// - the segments within a monotone chain will never intersect each other |
42 | | /// |
43 | | /// - the envelope of any contiguous subset of the segments in a monotone chain |
44 | | /// is simply the envelope of the endpoints of the subset. |
45 | | /// |
46 | | /// Property 1 means that there is no need to test pairs of segments from |
47 | | /// within the same monotone chain for intersection. Property 2 allows binary |
48 | | /// search to be used to find the intersection points of two monotone chains. |
49 | | /// For many types of real-world data, these properties eliminate a large |
50 | | /// number of segment comparisons, producing substantial speed gains. |
51 | | /// |
52 | | /// \note Due to the efficient intersection test, there is no need to limit the |
53 | | /// size of chains to obtain fast performance. |
54 | | class GEOS_DLL MonotoneChainIndexer { |
55 | | |
56 | | public: |
57 | | |
58 | 0 | MonotoneChainIndexer() {} |
59 | | |
60 | | void getChainStartIndices(const geom::CoordinateSequence*, std::vector<std::size_t>&); |
61 | | |
62 | | private: |
63 | | |
64 | | std::size_t findChainEnd(const geom::CoordinateSequence* pts, std::size_t start); |
65 | | |
66 | | }; |
67 | | |
68 | | } // namespace geos.geomgraph.index |
69 | | } // namespace geos.geomgraph |
70 | | } // namespace geos |
71 | | |