GEOS 3.4.2

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

geomgraph/Edge.h
1 /**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
7 * Copyright (C) 2005-2006 Refractions Research Inc.
8 * Copyright (C) 2001-2002 Vivid Solutions Inc.
9 *
10 * This is free software; you can redistribute and/or modify it under
11 * the terms of the GNU Lesser General Public Licence as published
12 * by the Free Software Foundation.
13 * See the COPYING file for more information.
14 *
15 **********************************************************************
16 *
17 * Last port: geomgraph/Edge.java r428 (JTS-1.12+)
18 *
19 **********************************************************************/
20
21
22 #ifndef GEOS_GEOMGRAPH_EDGE_H
23 #define GEOS_GEOMGRAPH_EDGE_H
24
25 #include <geos/export.h>
26 #include <string>
27 #include <cassert>
28
29 #include <geos/geomgraph/GraphComponent.h> // for inheritance
30 #include <geos/geomgraph/Depth.h> // for member
31 #include <geos/geomgraph/EdgeIntersectionList.h> // for composition
32 #include <geos/geom/CoordinateSequence.h> // for inlines
33
34 #include <geos/inline.h>
35
36 #ifdef _MSC_VER
37 #pragma warning(push)
38 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
39 #endif
40
41 // Forward declarations
42 namespace geos {
43 namespace geom {
44 class Envelope;
45 class IntersectionMatrix;
46 class Coordinate;
47 }
48 namespace algorithm {
49 class LineIntersector;
50 }
51 namespace geomgraph {
52 class Node;
53 class EdgeEndStar;
54 class Label;
55 class NodeFactory;
56 namespace index {
57 class MonotoneChainEdge;
58 }
59 }
60 }
61
62 namespace geos {
63 namespace geomgraph { // geos.geomgraph
64
66 class GEOS_DLL Edge: public GraphComponent{
67 using GraphComponent::updateIM;
68
69 private:
70
71 std::string name;
72
74 index::MonotoneChainEdge *mce;
75
77 geom::Envelope *env;
78
79 bool isIsolatedVar;
80
81 Depth depth;
82
83 int depthDelta; // the change in area depth from the R to L side of this edge
84
85 public:
86
87 void testInvariant() const {
88 assert(pts);
89 assert(pts->size() > 1);
90 }
91
92
93 friend std::ostream& operator<< (std::ostream& os, const Edge& el);
94
95 static void updateIM(const Label& lbl, geom::IntersectionMatrix& im);
96
98 geom::CoordinateSequence* pts;
99
100 EdgeIntersectionList eiList;
101
102 //Edge();
103
105 Edge(geom::CoordinateSequence* newPts, const Label& newLabel);
106
108 Edge(geom::CoordinateSequence* newPts);
109
110 virtual ~Edge();
111
112 virtual int getNumPoints() const {
113 return static_cast<int>(pts->getSize());
114 }
115
116 virtual void setName(const std::string &newName) {
117 name=newName;
118 }
119
120 virtual const geom::CoordinateSequence* getCoordinates() const {
121 testInvariant();
122 return pts;
123 }
124
125 virtual const geom::Coordinate& getCoordinate(int i) const {
126 testInvariant();
127 return pts->getAt(i);
128 }
129
130 virtual const geom::Coordinate& getCoordinate() const {
131 testInvariant();
132 return pts->getAt(0);
133 }
134
135
136 virtual Depth &getDepth() {
137 testInvariant();
138 return depth;
139 }
140
146 virtual int getDepthDelta() const {
147 testInvariant();
148 return depthDelta;
149 }
150
151 virtual void setDepthDelta(int newDepthDelta) {
152 depthDelta=newDepthDelta;
153 testInvariant();
154 }
155
156 virtual int getMaximumSegmentIndex() const {
157 testInvariant();
158 return getNumPoints()-1;
159 }
160
161 virtual EdgeIntersectionList& getEdgeIntersectionList() {
162 testInvariant();
163 return eiList;
164 }
165
170 virtual index::MonotoneChainEdge* getMonotoneChainEdge();
171
172 virtual bool isClosed() const {
173 testInvariant();
174 return pts->getAt(0)==pts->getAt(getNumPoints()-1);
175 }
176
181 virtual bool isCollapsed() const;
182
183 virtual Edge* getCollapsedEdge();
184
185 virtual void setIsolated(bool newIsIsolated) {
186 isIsolatedVar=newIsIsolated;
187 testInvariant();
188 }
189
190 virtual bool isIsolated() const {
191 testInvariant();
192 return isIsolatedVar;
193 }
194
199 virtual void addIntersections(algorithm::LineIntersector *li, int segmentIndex,
200 int geomIndex);
201
203 //
207 virtual void addIntersection(algorithm::LineIntersector *li, int segmentIndex,
208 int geomIndex, int intIndex);
209
211 //
215 virtual void computeIM(geom::IntersectionMatrix& im) {
216 updateIM(label, im);
217 testInvariant();
218 }
219
221 virtual bool isPointwiseEqual(const Edge *e) const;
222
223 virtual std::string print() const;
224
225 virtual std::string printReverse() const;
226
234 virtual bool equals(const Edge& e) const;
235
236 virtual bool equals(const Edge* e) const {
237 assert(e);
238 return equals(*e);
239 }
240
241 virtual geom::Envelope* getEnvelope();
242 };
243
244
245 //Operators
246 inline bool operator==(const Edge &a, const Edge &b) {
247 return a.equals(b);
248 }
249
250 std::ostream& operator<< (std::ostream& os, const Edge& el);
251
252
253 } // namespace geos.geomgraph
254 } // namespace geos
255
256 #ifdef _MSC_VER
257 #pragma warning(pop)
258 #endif
259
260 //#ifdef GEOS_INLINE
261 //# include "geos/geomgraph/Edge.inl"
262 //#endif
263
264 #endif // ifndef GEOS_GEOMGRAPH_EDGE_H
265