GEOS  3.8.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 #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
30 namespace geos {
31 namespace planargraph {
32 class PlanarGraph;
33 class DirectedEdge;
34 class Edge;
35 }
36 }
37 
38 namespace geos {
39 namespace planargraph { // geos.planargraph
40 
42 //
53 class GEOS_DLL Subgraph {
54 public:
61  :
62  parentGraph(parent)
63  {}
64 
72  getParent() const
73  {
74  return parentGraph;
75  }
76 
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 
156  bool
158  {
159  return (edges.find(e) != edges.end());
160  }
161 
162 protected:
163 
164  PlanarGraph& parentGraph;
165  std::set<Edge*> edges;
166  std::vector<const DirectedEdge*> dirEdges;
167  NodeMap nodeMap;
168 
169  // Declare type as noncopyable
170  Subgraph(const Subgraph& other) = delete;
171  Subgraph& operator=(const Subgraph& rhs) = delete;
172 };
173 
174 } // namespace geos::planargraph
175 } // namespace geos
176 
177 #ifdef _MSC_VER
178 #pragma warning(pop)
179 #endif
180 
181 #endif // GEOS_PLANARGRAPH_SUBGRAPH_H
Subgraph(PlanarGraph &parent)
Definition: Subgraph.h:60
std::set< Edge * >::iterator edgeBegin()
Definition: Subgraph.h:116
PlanarGraph & getParent() const
Definition: Subgraph.h:72
NodeMap::container::iterator nodeBegin()
Definition: Subgraph.h:131
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
bool contains(Edge *e)
Definition: Subgraph.h:157
Represents an undirected edge of a PlanarGraph.
Definition: planargraph/Edge.h:54
std::vector< const DirectedEdge * >::iterator getDirEdgeBegin()
Definition: Subgraph.h:101
A subgraph of a PlanarGraph.
Definition: Subgraph.h:53
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