/src/geos/include/geos/noding/IteratedNoder.h
Line | Count | Source |
1 | | /********************************************************************** |
2 | | * |
3 | | * GEOS - Geometry Engine Open Source |
4 | | * http://geos.osgeo.org |
5 | | * |
6 | | * Copyright (C) 2006 Refractions Research Inc. |
7 | | * |
8 | | * This is free software; you can redistribute and/or modify it under |
9 | | * the terms of the GNU Lesser General Public Licence as published |
10 | | * by the Free Software Foundation. |
11 | | * See the COPYING file for more information. |
12 | | * |
13 | | ********************************************************************** |
14 | | * |
15 | | * Last port: noding/IteratedNoder.java r591 (JTS-1.12+) |
16 | | * |
17 | | **********************************************************************/ |
18 | | |
19 | | #pragma once |
20 | | |
21 | | #include <geos/export.h> |
22 | | |
23 | | #include <vector> |
24 | | #include <iostream> |
25 | | |
26 | | #include <geos/algorithm/LineIntersector.h> |
27 | | #include <geos/noding/SegmentString.h> // due to inlines |
28 | | #include <geos/noding/Noder.h> // for inheritance |
29 | | |
30 | | // Forward declarations |
31 | | namespace geos { |
32 | | namespace geom { |
33 | | class PrecisionModel; |
34 | | } |
35 | | } |
36 | | |
37 | | namespace geos { |
38 | | namespace noding { // geos::noding |
39 | | |
40 | | /** \brief |
41 | | * Nodes a set of SegmentStrings completely. |
42 | | * |
43 | | * The set of segmentStrings is fully noded; |
44 | | * i.e. noding is repeated until no further |
45 | | * intersections are detected. |
46 | | * |
47 | | * Iterated noding using a FLOATING precision model is not guaranteed to converge, |
48 | | * due to roundoff error. This problem is detected and an exception is thrown. |
49 | | * Clients can choose to rerun the noding using a lower precision model. |
50 | | * |
51 | | */ |
52 | | class GEOS_DLL IteratedNoder : public Noder { // implements Noder |
53 | | |
54 | | private: |
55 | | static const int MAX_ITER = 5; |
56 | | |
57 | | |
58 | | const geom::PrecisionModel* pm; |
59 | | algorithm::LineIntersector li; |
60 | | std::vector<std::unique_ptr<SegmentString>> nodedSegStrings; |
61 | | int maxIter; |
62 | | |
63 | | /** |
64 | | * Node the input segment strings once |
65 | | * and create the split edges between the nodes |
66 | | */ |
67 | | void node(const std::vector<SegmentString*>& segStrings, |
68 | | int& numInteriorIntersections, |
69 | | geom::CoordinateXY& intersectionPoint); |
70 | | |
71 | | public: |
72 | | |
73 | | IteratedNoder(const geom::PrecisionModel* newPm) |
74 | | : |
75 | 0 | pm(newPm), |
76 | 0 | li(pm), |
77 | 0 | maxIter(MAX_ITER) |
78 | 0 | { |
79 | 0 | } |
80 | | |
81 | 0 | ~IteratedNoder() override {} |
82 | | |
83 | | /** \brief |
84 | | * Sets the maximum number of noding iterations performed before |
85 | | * the noding is aborted. |
86 | | * |
87 | | * Experience suggests that this should rarely need to be changed |
88 | | * from the default. |
89 | | * The default is MAX_ITER. |
90 | | * |
91 | | * @param n the maximum number of iterations to perform |
92 | | */ |
93 | | void |
94 | | setMaximumIterations(int n) |
95 | 0 | { |
96 | 0 | maxIter = n; |
97 | 0 | } |
98 | | |
99 | | std::vector<std::unique_ptr<SegmentString>> |
100 | | getNodedSubstrings() override |
101 | 0 | { |
102 | 0 | return std::move(nodedSegStrings); |
103 | 0 | } |
104 | | |
105 | | |
106 | | /** \brief |
107 | | * Fully nodes a list of {@link SegmentString}s, i.e. performs noding iteratively |
108 | | * until no intersections are found between segments. |
109 | | * |
110 | | * Maintains labelling of edges correctly through the noding. |
111 | | * |
112 | | * @param inputSegmentStrings a collection of SegmentStrings to be noded |
113 | | * @throws TopologyException if the iterated noding fails to converge. |
114 | | */ |
115 | | void computeNodes(const std::vector<SegmentString*>& inputSegmentStrings) override; // throw(GEOSException); |
116 | | |
117 | | // Declare type as noncopyable |
118 | | IteratedNoder(IteratedNoder const&) = delete; |
119 | | IteratedNoder& operator=(IteratedNoder const&) = delete; |
120 | | }; |
121 | | |
122 | | } // namespace geos::noding |
123 | | } // namespace geos |
124 | | |