/src/geos/include/geos/operation/overlayng/IntersectionPointBuilder.h
Line | Count | Source |
1 | | /********************************************************************** |
2 | | * |
3 | | * GEOS - Geometry Engine Open Source |
4 | | * http://geos.osgeo.org |
5 | | * |
6 | | * Copyright (C) 2020 Paul Ramsey <pramsey@cleverelephant.ca> |
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 | | #pragma once |
16 | | |
17 | | #include <geos/geom/Point.h> |
18 | | #include <geos/operation/overlayng/OverlayNG.h> |
19 | | |
20 | | #include <geos/export.h> |
21 | | #include <vector> |
22 | | #include <memory> |
23 | | |
24 | | // Forward declarations |
25 | | namespace geos { |
26 | | namespace geom { |
27 | | class GeometryFactory; |
28 | | } |
29 | | namespace operation { |
30 | | namespace overlayng { |
31 | | class OverlayEdge; |
32 | | class OverlayGraph; |
33 | | class OverlayLabel; |
34 | | } |
35 | | } |
36 | | } |
37 | | |
38 | | namespace geos { // geos. |
39 | | namespace operation { // geos.operation |
40 | | namespace overlayng { // geos.operation.overlayng |
41 | | |
42 | | /** |
43 | | * Extracts Point resultants from an overlay graph |
44 | | * created by an Intersection operation |
45 | | * between non-Point inputs. |
46 | | * Points may be created during intersection |
47 | | * if lines or areas touch one another at single points. |
48 | | * Intersection is the only overlay operation which can |
49 | | * result in Points from non-Point inputs. |
50 | | * <p> |
51 | | * Overlay operations where one or more inputs |
52 | | * are Points are handled via a different code path. |
53 | | * |
54 | | * |
55 | | * @author Martin Davis |
56 | | * |
57 | | * @see OverlayPoints |
58 | | * |
59 | | */ |
60 | | class GEOS_DLL IntersectionPointBuilder { |
61 | | |
62 | | private: |
63 | | |
64 | | // Members |
65 | | OverlayGraph* graph; |
66 | | const geom::GeometryFactory* geometryFactory; |
67 | | std::vector<std::unique_ptr<geom::Point>> points; |
68 | | /** |
69 | | * Controls whether lines created by area topology collapses |
70 | | * to participate in the result computation. |
71 | | * True provides the original JTS semantics. |
72 | | */ |
73 | | bool isAllowCollapseLines; |
74 | | |
75 | | // Methods |
76 | | void addResultPoints(); |
77 | | |
78 | | /** |
79 | | * Tests if a node is a result point. |
80 | | * This is the case if the node is incident on edges from both |
81 | | * inputs, and none of the edges are themselves in the result. |
82 | | */ |
83 | | bool isResultPoint(OverlayEdge* nodeEdge) const; |
84 | | bool isEdgeOf(const OverlayLabel* label, uint8_t i) const; |
85 | | |
86 | | |
87 | | public: |
88 | | |
89 | | |
90 | | IntersectionPointBuilder(OverlayGraph* p_graph, const geom::GeometryFactory* geomFact) |
91 | 6.56k | : graph(p_graph) |
92 | 6.56k | , geometryFactory(geomFact) |
93 | 6.56k | , isAllowCollapseLines(!OverlayNG::STRICT_MODE_DEFAULT) |
94 | 6.56k | {} |
95 | | |
96 | | std::vector<std::unique_ptr<geom::Point>> getPoints(); |
97 | | |
98 | | IntersectionPointBuilder(const IntersectionPointBuilder&) = delete; |
99 | | IntersectionPointBuilder& operator=(const IntersectionPointBuilder&) = delete; |
100 | | |
101 | | void setStrictMode(bool p_isStrictMode) |
102 | 6.56k | { |
103 | 6.56k | isAllowCollapseLines = ! p_isStrictMode; |
104 | 6.56k | } |
105 | | |
106 | | |
107 | | }; |
108 | | |
109 | | |
110 | | } // namespace geos.operation.overlayng |
111 | | } // namespace geos.operation |
112 | | } // namespace geos |
113 | | |