GEOS  3.9.1
planargraph/DirectedEdgeStar.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_DIRECTEDEDGESTAR_H
17 #define GEOS_PLANARGRAPH_DIRECTEDEDGESTAR_H
18 
19 #include <geos/export.h>
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
29 namespace geos {
30 namespace geom {
31 class Coordinate;
32 }
33 namespace planargraph {
34 class DirectedEdge;
35 class Edge;
36 }
37 }
38 
39 namespace geos {
40 namespace planargraph { // geos.planargraph
41 
43 class GEOS_DLL DirectedEdgeStar {
44 protected:
45 
46 private:
50  mutable std::vector<DirectedEdge*> outEdges;
51  mutable bool sorted;
52  void sortEdges() const;
53 
54 public:
58  DirectedEdgeStar(): sorted(false) {}
59 
60  virtual
61  ~DirectedEdgeStar() {}
62 
66  void add(DirectedEdge* de);
67 
71  void remove(DirectedEdge* de);
72 
77  std::vector<DirectedEdge*>::iterator
79  {
80  return begin();
81  }
83  std::vector<DirectedEdge*>::iterator begin();
84 
86  std::vector<DirectedEdge*>::iterator end();
87 
89  std::vector<DirectedEdge*>::const_iterator begin() const;
90 
92  std::vector<DirectedEdge*>::const_iterator end() const;
93 
98  std::size_t
99  getDegree() const
100  {
101  return outEdges.size();
102  }
103 
109 
114  std::vector<DirectedEdge*>& getEdges();
115 
121  int getIndex(const Edge* edge);
122 
128  int getIndex(const DirectedEdge* dirEdge);
129 
134  int getIndex(int i) const;
135 
142 };
143 
144 } // namespace geos::planargraph
145 } // namespace geos
146 
147 #ifdef _MSC_VER
148 #pragma warning(pop)
149 #endif
150 
151 #endif // GEOS_PLANARGRAPH_DIRECTEDEDGESTAR_H
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
A sorted collection of DirectedEdge which leave a Node in a PlanarGraph.
Definition: planargraph/DirectedEdgeStar.h:43
void add(DirectedEdge *de)
Adds a new member to this DirectedEdgeStar.
std::vector< DirectedEdge * >::const_iterator begin() const
Returns an const_iterator to first DirectedEdge.
std::vector< DirectedEdge * >::iterator begin()
Returns an iterator to first DirectedEdge.
std::vector< DirectedEdge * > & getEdges()
Returns the DirectedEdges, in ascending order by angle with the positive x-axis.
geom::Coordinate & getCoordinate() const
Returns the coordinate for the node at wich this star is based.
int getIndex(const Edge *edge)
Returns the zero-based index of the given Edge, after sorting in ascending order by angle with the po...
std::size_t getDegree() const
Returns the number of edges around the Node associated with this DirectedEdgeStar.
Definition: planargraph/DirectedEdgeStar.h:99
DirectedEdgeStar()
Constructs a DirectedEdgeStar with no edges.
Definition: planargraph/DirectedEdgeStar.h:58
std::vector< DirectedEdge * >::iterator iterator()
Returns an Iterator over the DirectedEdges, in ascending order by angle with the positive x-axis.
Definition: planargraph/DirectedEdgeStar.h:78
std::vector< DirectedEdge * >::iterator end()
Returns an iterator to one-past last DirectedEdge.
std::vector< DirectedEdge * >::const_iterator end() const
Returns an const_iterator to one-past last DirectedEdge.
int getIndex(int i) const
Returns the remainder when i is divided by the number of edges in this DirectedEdgeStar.
DirectedEdge * getNextEdge(DirectedEdge *dirEdge)
Returns the DirectedEdge on the left-hand side of the given DirectedEdge (which must be a member of t...
void remove(DirectedEdge *de)
Drops a member of this DirectedEdgeStar.
int getIndex(const DirectedEdge *dirEdge)
Returns the zero-based index of the given DirectedEdge, after sorting in ascending order by angle wit...
Represents a directed edge in a PlanarGraph.
Definition: planargraph/DirectedEdge.h:46
Represents an undirected edge of a PlanarGraph.
Definition: planargraph/Edge.h:54
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26