GEOS  3.13.1
relateng/RelateNode.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (c) 2024 Martin Davis
7  * Copyright (C) 2024 Paul Ramsey <pramsey@cleverelephant.ca>
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/operation/relateng/RelateEdge.h>
19 
20 #include <vector>
21 #include <memory>
22 #include <cassert>
23 
24 #include <geos/export.h>
25 
26 
27 // Forward declarations
28 namespace geos {
29 namespace operation {
30 namespace relateng {
31  class NodeSection;
32 }
33 }
34 namespace geom {
35  class CoordinateXY;
36  class Geometry;
37 }
38 }
39 
40 
41 using geos::geom::CoordinateXY;
43 
44 
45 namespace geos { // geos.
46 namespace operation { // geos.operation
47 namespace relateng { // geos.operation.relateng
48 
49 
50 class GEOS_DLL RelateNode {
51 
52 private:
53 
54  // Members
55 
60  std::vector<std::unique_ptr<RelateEdge>> edges;
61 
62  const CoordinateXY* nodePt;
63 
64 
65  // Methods
66 
67  void updateEdgesInArea(bool isA, std::size_t indexFrom, std::size_t indexTo);
68 
69  void updateIfAreaPrev(bool isA, std::size_t index);
70 
71  void updateIfAreaNext(bool isA, std::size_t index);
72 
73  const RelateEdge* addLineEdge(bool isA, const CoordinateXY* dirPt);
74 
75  const RelateEdge* addAreaEdge(bool isA, const CoordinateXY* dirPt, bool isForward);
76 
87  const RelateEdge* addEdge(bool isA, const CoordinateXY* dirPt, int dim, bool isForward);
88 
89  void finishNode(bool isA, bool isAreaInterior);
90 
91  void propagateSideLocations(bool isA, std::size_t startIndex);
92 
93  static std::size_t prevIndex(std::vector<std::unique_ptr<RelateEdge>>& list, std::size_t index);
94 
95  static std::size_t nextIndex(std::vector<std::unique_ptr<RelateEdge>>& list, std::size_t i);
96 
97  std::size_t indexOf(
98  const std::vector<std::unique_ptr<RelateEdge>>& edges,
99  const RelateEdge* edge) const;
100 
101 
102 public:
103 
104  RelateNode(const CoordinateXY* pt)
105  : nodePt(pt)
106  {};
107 
108  const CoordinateXY* getCoordinate() const;
109 
110  const std::vector<std::unique_ptr<RelateEdge>>& getEdges() const;
111 
112  void addEdges(std::vector<const NodeSection *>& nss);
113  void addEdges(std::vector<std::unique_ptr<NodeSection>>& nss);
114 
115  void addEdges(const NodeSection* ns);
116 
126  void finish(bool isAreaInteriorA, bool isAreaInteriorB);
127 
128  std::string toString() const;
129 
130  bool hasExteriorEdge(bool isA);
131 
132  friend std::ostream& operator<<(std::ostream& os, const RelateNode& ns);
133 
138  RelateNode(const RelateNode&) = delete;
139  RelateNode& operator=(const RelateNode&) = delete;
140 
141 };
142 
143 } // namespace geos.operation.relateng
144 } // namespace geos.operation
145 } // namespace geos
146 
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:197
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25