GEOS 3.14.0dev
Subgraph.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2001-2002 Vivid Solutions Inc.
7 * Copyright (C) 2005-2006 Refractions Research 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 <geos/export.h>
19#include <geos/planargraph/NodeMap.h> // for composition
20
21#include <vector>
22
23#ifdef _MSC_VER
24#pragma warning(push)
25#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
26#endif
27
28// Forward declarations
29namespace geos {
30namespace planargraph {
31class PlanarGraph;
32class DirectedEdge;
33class Edge;
34}
35}
36
37namespace geos {
38namespace planargraph { // geos.planargraph
39
52class GEOS_DLL Subgraph {
53public:
60 :
61 parentGraph(parent)
62 {}
63
71 getParent() const
72 {
73 return parentGraph;
74 }
75
90 std::pair<std::set<Edge*>::iterator, bool> add(Edge* e);
91
100 std::vector<const DirectedEdge*>::iterator
102 {
103 return dirEdges.begin();
104 }
105
106
115 std::set<Edge*>::iterator
117 {
118 return edges.begin();
119 }
120 std::set<Edge*>::iterator
121 edgeEnd()
122 {
123 return edges.end();
124 }
125
130 NodeMap::container::iterator
132 {
133 return nodeMap.begin();
134 }
135 NodeMap::container::const_iterator
136 nodeEnd() const
137 {
138 return nodeMap.end();
139 }
140 NodeMap::container::iterator
141 nodeEnd()
142 {
143 return nodeMap.end();
144 }
145 NodeMap::container::const_iterator
146 nodeBegin() const
147 {
148 return nodeMap.begin();
149 }
150
157 bool
159 {
160 return (edges.find(e) != edges.end());
161 }
162
163protected:
164
165 PlanarGraph& parentGraph;
166 std::set<Edge*> edges;
167 std::vector<const DirectedEdge*> dirEdges;
168 NodeMap nodeMap;
169
170 // Declare type as noncopyable
171 Subgraph(const Subgraph& other) = delete;
172 Subgraph& operator=(const Subgraph& rhs) = delete;
173};
174
175} // namespace geos::planargraph
176} // namespace geos
177
178#ifdef _MSC_VER
179#pragma warning(pop)
180#endif
181
Represents an undirected edge of a PlanarGraph.
Definition planargraph/Edge.h:54
A map of Node, indexed by the coordinate of the node.
Definition planargraph/NodeMap.h:47
Represents a directed graph which is embeddable in a planar surface.
Definition planargraph/PlanarGraph.h:59
A subgraph of a PlanarGraph.
Definition Subgraph.h:52
bool contains(Edge *e)
Tests whether an Edge is contained in this subgraph.
Definition Subgraph.h:158
std::pair< std::set< Edge * >::iterator, bool > add(Edge *e)
Adds an Edge to the subgraph.
std::set< Edge * >::iterator edgeBegin()
Returns an iterator over the Edges in this graph, in the order in which they were added.
Definition Subgraph.h:116
PlanarGraph & getParent() const
Gets the PlanarGraph which this subgraph is part of.
Definition Subgraph.h:71
NodeMap::container::iterator nodeBegin()
Returns a iterators over the planar NodeMap::container in this graph.
Definition Subgraph.h:131
std::vector< constDirectedEdge * >::iterator getDirEdgeBegin()
Returns an iterator over the DirectedEdge in this graph, in the order in which they were added.
Definition Subgraph.h:101
Subgraph(PlanarGraph &parent)
Creates a new subgraph of the given PlanarGraph.
Definition Subgraph.h:59
Basic namespace for all GEOS functionalities.
Definition geos.h:39