/src/geos/include/geos/operation/valid/PolygonRingSelfNode.h
Line | Count | Source |
1 | | /********************************************************************** |
2 | | * |
3 | | * GEOS - Geometry Engine Open Source |
4 | | * http://geos.osgeo.org |
5 | | * |
6 | | * Copyright (C) 2021 Paul Ramsey <pramsey@cleverelephant.ca> |
7 | | * Copyright (C) 2021 Martin Davis |
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 <geos/export.h> |
19 | | |
20 | | #include <geos/geom/Coordinate.h> |
21 | | |
22 | | #include <memory> |
23 | | |
24 | | |
25 | | namespace geos { // geos. |
26 | | namespace operation { // geos.operation |
27 | | namespace valid { // geos.operation.valid |
28 | | |
29 | | class GEOS_DLL PolygonRingSelfNode { |
30 | | using CoordinateXY = geos::geom::CoordinateXY; |
31 | | |
32 | | private: |
33 | | |
34 | | CoordinateXY nodePt; |
35 | | const CoordinateXY* e00; |
36 | | const CoordinateXY* e01; |
37 | | const CoordinateXY* e10; |
38 | | const CoordinateXY* e11; |
39 | | |
40 | | |
41 | | public: |
42 | | |
43 | | PolygonRingSelfNode( |
44 | | const CoordinateXY& p_nodePt, |
45 | | const CoordinateXY* p_e00, |
46 | | const CoordinateXY* p_e01, |
47 | | const CoordinateXY* p_e10, |
48 | | const CoordinateXY* p_e11) |
49 | 0 | : nodePt(p_nodePt) |
50 | 0 | , e00(p_e00) |
51 | 0 | , e01(p_e01) |
52 | 0 | , e10(p_e10) |
53 | 0 | , e11(p_e11) |
54 | 0 | {} |
55 | | |
56 | | /** |
57 | | * The node point. |
58 | | * |
59 | | * @return |
60 | | */ |
61 | 0 | const CoordinateXY* getCoordinate() const { |
62 | 0 | return &nodePt; |
63 | 0 | } |
64 | | |
65 | | /** |
66 | | * Tests if a self-touch has the segments of each half of the touch |
67 | | * lying in the exterior of a polygon. |
68 | | * This is a valid self-touch. |
69 | | * It applies to both shells and holes. |
70 | | * Only one of the four possible cases needs to be tested, |
71 | | * since the situation has full symmetry. |
72 | | * |
73 | | * @param isInteriorOnRight whether the interior is to the right of the parent ring |
74 | | * @return true if the self-touch is in the exterior |
75 | | */ |
76 | | bool isExterior(bool isInteriorOnRight) const; |
77 | | |
78 | | }; |
79 | | |
80 | | } // namespace geos.operation.valid |
81 | | } // namespace geos.operation |
82 | | } // namespace geos |
83 | | |