GEOS  3.7.2
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 ~DirectedEdgeStar() {}
61 
65  void add(DirectedEdge *de);
66 
70  void remove(DirectedEdge *de);
71 
76  std::vector<DirectedEdge*>::iterator iterator() { return begin(); }
78  std::vector<DirectedEdge*>::iterator begin();
79 
81  std::vector<DirectedEdge*>::iterator end();
82 
84  std::vector<DirectedEdge*>::const_iterator begin() const;
85 
87  std::vector<DirectedEdge*>::const_iterator end() const;
88 
93  std::size_t getDegree() const { return outEdges.size(); }
94 
100 
105  std::vector<DirectedEdge*>& getEdges();
106 
112  int getIndex(const Edge *edge);
113 
119  int getIndex(const DirectedEdge *dirEdge);
120 
125  int getIndex(int i) const;
126 
133 };
134 
135 } // namespace geos::planargraph
136 } // namespace geos
137 
138 #ifdef _MSC_VER
139 #pragma warning(pop)
140 #endif
141 
142 #endif // GEOS_PLANARGRAPH_DIRECTEDEDGESTAR_H
geos::planargraph::DirectedEdgeStar::getIndex
int getIndex(const Edge *edge)
Returns the zero-based index of the given Edge, after sorting in ascending order by angle with the po...
geos::planargraph::DirectedEdge
Represents a directed edge in a PlanarGraph.
Definition: planargraph/DirectedEdge.h:46
geos::planargraph::DirectedEdgeStar::getCoordinate
geom::Coordinate & getCoordinate() const
Returns the coordinate for the node at wich this star is based.
geos::planargraph::DirectedEdgeStar::getIndex
int getIndex(const DirectedEdge *dirEdge)
Returns the zero-based index of the given DirectedEdge, after sorting in ascending order by angle wit...
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
geos::planargraph::DirectedEdgeStar::getNextEdge
DirectedEdge * getNextEdge(DirectedEdge *dirEdge)
Returns the DirectedEdge on the left-hand side of the given DirectedEdge (which must be a member of t...
geos::planargraph::DirectedEdgeStar::getDegree
std::size_t getDegree() const
Returns the number of edges around the Node associated with this DirectedEdgeStar.
Definition: planargraph/DirectedEdgeStar.h:93
geos::planargraph::DirectedEdgeStar
A sorted collection of DirectedEdge which leave a Node in a PlanarGraph.
Definition: planargraph/DirectedEdgeStar.h:43
geos::planargraph::DirectedEdgeStar::end
std::vector< DirectedEdge * >::iterator end()
Returns an iterator to one-past last DirectedEdge.
geos::planargraph::DirectedEdgeStar::begin
std::vector< DirectedEdge * >::const_iterator begin() const
Returns an const_iterator to first DirectedEdge.
geos::planargraph::DirectedEdgeStar::remove
void remove(DirectedEdge *de)
Drops a member of this DirectedEdgeStar.
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
geos::planargraph::DirectedEdgeStar::add
void add(DirectedEdge *de)
Adds a new member to this DirectedEdgeStar.
geos::planargraph::DirectedEdgeStar::end
std::vector< DirectedEdge * >::const_iterator end() const
Returns an const_iterator to one-past last DirectedEdge.
geos::planargraph::DirectedEdgeStar::getIndex
int getIndex(int i) const
Returns the remainder when i is divided by the number of edges in this DirectedEdgeStar.
geos::planargraph::DirectedEdgeStar::iterator
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:76
geos::planargraph::Edge
Represents an undirected edge of a PlanarGraph.
Definition: planargraph/Edge.h:54
geos::planargraph::DirectedEdgeStar::begin
std::vector< DirectedEdge * >::iterator begin()
Returns an iterator to first DirectedEdge.
geos::planargraph::DirectedEdgeStar::getEdges
std::vector< DirectedEdge * > & getEdges()
Returns the DirectedEdges, in ascending order by angle with the positive x-axis.
geos::planargraph::DirectedEdgeStar::DirectedEdgeStar
DirectedEdgeStar()
Constructs a DirectedEdgeStar with no edges.
Definition: planargraph/DirectedEdgeStar.h:58