GEOS  3.14.0dev
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 #pragma once
17 
18 #include <geos/export.h>
19 
20 #include <vector>
21 
22 #ifdef _MSC_VER
23 #pragma warning(push)
24 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
25 #endif
26 
27 // Forward declarations
28 namespace geos {
29 namespace geom {
30 class Coordinate;
31 }
32 namespace planargraph {
33 class DirectedEdge;
34 class Edge;
35 }
36 }
37 
38 namespace geos {
39 namespace planargraph { // geos.planargraph
40 
42 class GEOS_DLL DirectedEdgeStar {
43 protected:
44 
45 private:
49  mutable std::vector<DirectedEdge*> outEdges;
50  mutable bool sorted;
51  void sortEdges() const;
52 
53 public:
57  DirectedEdgeStar(): sorted(false) {}
58 
59  virtual
60  ~DirectedEdgeStar() {}
61 
65  void add(DirectedEdge* de);
66 
70  void remove(DirectedEdge* de);
71 
76  std::vector<DirectedEdge*>::iterator
78  {
79  return begin();
80  }
82  std::vector<DirectedEdge*>::iterator begin();
83 
85  std::vector<DirectedEdge*>::iterator end();
86 
88  std::vector<DirectedEdge*>::const_iterator begin() const;
89 
91  std::vector<DirectedEdge*>::const_iterator end() const;
92 
97  std::size_t
98  getDegree() const
99  {
100  return outEdges.size();
101  }
102 
108 
113  std::vector<DirectedEdge*>& getEdges();
114 
120  int getIndex(const Edge* edge);
121 
127  int getIndex(const DirectedEdge* dirEdge);
128 
133  unsigned int getIndex(int i) const;
134 
141 };
142 
143 } // namespace geos::planargraph
144 } // namespace geos
145 
146 #ifdef _MSC_VER
147 #pragma warning(pop)
148 #endif
149 
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:217
A sorted collection of DirectedEdge which leave a Node in a PlanarGraph.
Definition: planargraph/DirectedEdgeStar.h:42
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.
unsigned int getIndex(int i) const
Returns the remainder when i is divided by the number of edges in this DirectedEdgeStar.
geom::Coordinate & getCoordinate() const
Returns the coordinate for the node at which 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:98
DirectedEdgeStar()
Constructs a DirectedEdgeStar with no edges.
Definition: planargraph/DirectedEdgeStar.h:57
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:77
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.
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:45
Represents an undirected edge of a PlanarGraph.
Definition: planargraph/Edge.h:54
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25