GEOS: Edge.h Source File

GEOS 3.3.8

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

- File List

geomgraph/Edge.h
1 /**********************************************************************
2 * $Id: Edge.h 3255 2011-03-01 17:56:10Z mloskot $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
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 rev. 1.4 (JTS-1.10)
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
65 class GEOS_DLL Edge: public GraphComponent{
66 using GraphComponent::updateIM;
67
68 private:
69
70 std::string name;
71
73 index::MonotoneChainEdge *mce;
74
76 geom::Envelope *env;
77
78 bool isIsolatedVar;
79
80 Depth depth;
81
82 int depthDelta; // the change in area depth from the R to L side of this edge
83
84 public:
85
86 void testInvariant() const {
87 assert(pts);
88 assert(pts->size() > 1);
89 }
90
91
92 friend std::ostream& operator<< (std::ostream& os, const Edge& el);
93
94 static void updateIM(Label *lbl,geom::IntersectionMatrix *im);
95
97 geom::CoordinateSequence* pts;
98
99 EdgeIntersectionList eiList;
100
101 //Edge();
102
103 Edge(geom::CoordinateSequence* newPts, Label *newLabel);
104
105 Edge(geom::CoordinateSequence* newPts);
106
107 virtual ~Edge();
108
109 virtual int getNumPoints() const {
110 return static_cast<int>(pts->getSize());
111 }
112
113 virtual void setName(const std::string &newName) {
114 name=newName;
115 }
116
117 virtual const geom::CoordinateSequence* getCoordinates() const {
118 testInvariant();
119 return pts;
120 }
121
122 virtual const geom::Coordinate& getCoordinate(int i) const {
123 testInvariant();
124 return pts->getAt(i);
125 }
126
127 virtual const geom::Coordinate& getCoordinate() const {
128 testInvariant();
129 return pts->getAt(0);
130 }
131
132
133 virtual Depth &getDepth() {
134 testInvariant();
135 return depth;
136 }
137
143 virtual int getDepthDelta() const {
144 testInvariant();
145 return depthDelta;
146 }
147
148 virtual void setDepthDelta(int newDepthDelta) {
149 depthDelta=newDepthDelta;
150 testInvariant();
151 }
152
153 virtual int getMaximumSegmentIndex() const {
154 testInvariant();
155 return getNumPoints()-1;
156 }
157
158 virtual EdgeIntersectionList& getEdgeIntersectionList() {
159 testInvariant();
160 return eiList;
161 }
162
167 virtual index::MonotoneChainEdge* getMonotoneChainEdge();
168
169 virtual bool isClosed() const {
170 testInvariant();
171 return pts->getAt(0)==pts->getAt(getNumPoints()-1);
172 }
173
178 virtual bool isCollapsed() const;
179
180 virtual Edge* getCollapsedEdge();
181
182 virtual void setIsolated(bool newIsIsolated) {
183 isIsolatedVar=newIsIsolated;
184 testInvariant();
185 }
186
187 virtual bool isIsolated() const {
188 testInvariant();
189 return isIsolatedVar;
190 }
191
196 virtual void addIntersections(algorithm::LineIntersector *li, int segmentIndex,
197 int geomIndex);
198
200 //
204 virtual void addIntersection(algorithm::LineIntersector *li, int segmentIndex,
205 int geomIndex, int intIndex);
206
208 //
211 virtual void computeIM(geom::IntersectionMatrix *im) {
212 updateIM(label, im);
213 testInvariant();
214 }
215
217 virtual bool isPointwiseEqual(const Edge *e) const;
218
219 virtual std::string print() const;
220
221 virtual std::string printReverse() const;
222
230 virtual bool equals(const Edge& e) const;
231
232 virtual bool equals(const Edge* e) const {
233 assert(e);
234 return equals(*e);
235 }
236
237 virtual geom::Envelope* getEnvelope();
238 };
239
240
241 //Operators
242 inline bool operator==(const Edge &a, const Edge &b) {
243 return a.equals(b);
244 }
245
246 std::ostream& operator<< (std::ostream& os, const Edge& el);
247
248
249 } // namespace geos.geomgraph
250 } // namespace geos
251
252 #ifdef _MSC_VER
253 #pragma warning(pop)
254 #endif
255
256 //#ifdef GEOS_INLINE
257 //# include "geos/geomgraph/Edge.inl"
258 //#endif
259
260 #endif // ifndef GEOS_GEOMGRAPH_EDGE_H
261
262 /**********************************************************************
263 * $Log$
264 * Revision 1.4 2006/04/05 18:28:42 strk
265 * Moved testInvariant() methods from private to public, added
266 * some comments about them.
267 *
268 * Revision 1.3 2006/03/24 09:52:41 strk
269 * USE_INLINE => GEOS_INLINE
270 *
271 * Revision 1.2 2006/03/14 11:03:14 strk
272 * Added operator<< for Edge and EdgeList
273 *
274 * Revision 1.1 2006/03/09 16:46:49 strk
275 * geos::geom namespace definition, first pass at headers split
276 *
277 **********************************************************************/
278