GEOS 3.9.1
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#ifndef GEOS_PLANARGRAPH_SUBGRAPH_H
17#define GEOS_PLANARGRAPH_SUBGRAPH_H
18
19#include <geos/export.h>
20#include <geos/planargraph/NodeMap.h> // for composition
21
22#include <vector>
23
24#ifdef _MSC_VER
25#pragma warning(push)
26#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
27#endif
28
29// Forward declarations
30namespace geos {
31namespace planargraph {
32class PlanarGraph;
33class DirectedEdge;
34class Edge;
35}
36}
37
38namespace geos {
39namespace planargraph { // geos.planargraph
40
53class GEOS_DLL Subgraph {
54public:
61 :
62 parentGraph(parent)
63 {}
64
72 getParent() const
73 {
74 return parentGraph;
75 }
76
91 std::pair<std::set<Edge*>::iterator, bool> add(Edge* e);
92
101 std::vector<const DirectedEdge*>::iterator
103 {
104 return dirEdges.begin();
105 }
106
107
116 std::set<Edge*>::iterator
118 {
119 return edges.begin();
120 }
121 std::set<Edge*>::iterator
122 edgeEnd()
123 {
124 return edges.end();
125 }
126
131 NodeMap::container::iterator
133 {
134 return nodeMap.begin();
135 }
136 NodeMap::container::const_iterator
137 nodeEnd() const
138 {
139 return nodeMap.end();
140 }
141 NodeMap::container::iterator
142 nodeEnd()
143 {
144 return nodeMap.end();
145 }
146 NodeMap::container::const_iterator
147 nodeBegin() const
148 {
149 return nodeMap.begin();
150 }
151
158 bool
160 {
161 return (edges.find(e) != edges.end());
162 }
163
164protected:
165
166 PlanarGraph& parentGraph;
167 std::set<Edge*> edges;
168 std::vector<const DirectedEdge*> dirEdges;
169 NodeMap nodeMap;
170
171 // Declare type as noncopyable
172 Subgraph(const Subgraph& other) = delete;
173 Subgraph& operator=(const Subgraph& rhs) = delete;
174};
175
176} // namespace geos::planargraph
177} // namespace geos
178
179#ifdef _MSC_VER
180#pragma warning(pop)
181#endif
182
183#endif // GEOS_PLANARGRAPH_SUBGRAPH_H
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:48
Represents a directed graph which is embeddable in a planar surface.
Definition planargraph/PlanarGraph.h:60
A subgraph of a PlanarGraph.
Definition Subgraph.h:53
bool contains(Edge *e)
Tests whether an Edge is contained in this subgraph.
Definition Subgraph.h:159
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:117
PlanarGraph & getParent() const
Gets the PlanarGraph which this subgraph is part of.
Definition Subgraph.h:72
NodeMap::container::iterator nodeBegin()
Returns a iterators over the planar NodeMap::container in this graph.
Definition Subgraph.h:132
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:102
Subgraph(PlanarGraph &parent)
Creates a new subgraph of the given PlanarGraph.
Definition Subgraph.h:60
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:26