/src/geos/src/operation/buffer/MaximalEdgeRing.cpp
Line | Count | Source |
1 | | /********************************************************************** |
2 | | * |
3 | | * GEOS - Geometry Engine Open Source |
4 | | * http://geos.osgeo.org |
5 | | * |
6 | | * Copyright (C) 2005-2006 Refractions Research Inc. |
7 | | * Copyright (C) 2001-2002 Vivid Solutions 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 | | * Last port: operation/overlay/MaximalEdgeRing.java rev. 1.15 (JTS-1.10) |
17 | | * |
18 | | **********************************************************************/ |
19 | | |
20 | | #include <geos/operation/buffer/MaximalEdgeRing.h> |
21 | | #include <geos/operation/buffer/MinimalEdgeRing.h> |
22 | | #include <geos/geomgraph/EdgeRing.h> |
23 | | #include <geos/geomgraph/DirectedEdge.h> |
24 | | #include <geos/geomgraph/Node.h> |
25 | | #include <geos/geomgraph/EdgeEndStar.h> |
26 | | #include <geos/geomgraph/DirectedEdgeStar.h> |
27 | | #include <geos/util.h> |
28 | | |
29 | | #include <cassert> |
30 | | #include <vector> |
31 | | |
32 | | #ifndef GEOS_DEBUG |
33 | | #define GEOS_DEBUG 0 |
34 | | #endif |
35 | | |
36 | | #if GEOS_DEBUG |
37 | | #include <iostream> |
38 | | #endif |
39 | | |
40 | | |
41 | | using namespace geos::geomgraph; |
42 | | using namespace geos::geom; |
43 | | |
44 | | namespace geos { |
45 | | namespace operation { // geos.operation |
46 | | namespace buffer { // geos.operation.buffer |
47 | | |
48 | | /*public*/ |
49 | | MaximalEdgeRing::MaximalEdgeRing(DirectedEdge* start, |
50 | | const GeometryFactory* p_geometryFactory) |
51 | | // throw(const TopologyException &) |
52 | | : |
53 | 0 | EdgeRing(start, p_geometryFactory) |
54 | 0 | { |
55 | 0 | computePoints(start); |
56 | 0 | computeRing(); |
57 | | #if GEOS_DEBUG |
58 | | std::cerr << "MaximalEdgeRing[" << this << "] ctor" << std::endl; |
59 | | #endif |
60 | 0 | } |
61 | | |
62 | | /*public*/ |
63 | | DirectedEdge* |
64 | | MaximalEdgeRing::getNext(DirectedEdge* de) |
65 | 0 | { |
66 | 0 | return de->getNext(); |
67 | 0 | } |
68 | | |
69 | | /*public*/ |
70 | | void |
71 | | MaximalEdgeRing::setEdgeRing(DirectedEdge* de, EdgeRing* er) |
72 | 0 | { |
73 | 0 | de->setEdgeRing(er); |
74 | 0 | } |
75 | | |
76 | | /*public*/ |
77 | | void |
78 | | MaximalEdgeRing::linkDirectedEdgesForMinimalEdgeRings() |
79 | 0 | { |
80 | 0 | DirectedEdge* de = startDe; |
81 | 0 | do { |
82 | 0 | Node* node = de->getNode(); |
83 | 0 | EdgeEndStar* ees = node->getEdges(); |
84 | |
|
85 | 0 | DirectedEdgeStar* des = detail::down_cast<DirectedEdgeStar*>(ees); |
86 | |
|
87 | 0 | des->linkMinimalDirectedEdges(this); |
88 | |
|
89 | 0 | de = de->getNext(); |
90 | |
|
91 | 0 | } |
92 | 0 | while(de != startDe); |
93 | 0 | } |
94 | | |
95 | | /*public*/ |
96 | | std::vector<MinimalEdgeRing*>* |
97 | | MaximalEdgeRing::buildMinimalRings() |
98 | 0 | { |
99 | 0 | std::vector<MinimalEdgeRing*>* minEdgeRings = new std::vector<MinimalEdgeRing*>; |
100 | 0 | buildMinimalRings(*minEdgeRings); |
101 | 0 | return minEdgeRings; |
102 | 0 | } |
103 | | |
104 | | /*public*/ |
105 | | void |
106 | | MaximalEdgeRing::buildMinimalRings(std::vector<MinimalEdgeRing*>& minEdgeRings) |
107 | 0 | { |
108 | 0 | DirectedEdge* de = startDe; |
109 | 0 | do { |
110 | 0 | if(de->getMinEdgeRing() == nullptr) { |
111 | 0 | MinimalEdgeRing* minEr = new MinimalEdgeRing(de, geometryFactory); |
112 | 0 | minEdgeRings.push_back(minEr); |
113 | 0 | } |
114 | 0 | de = de->getNext(); |
115 | 0 | } |
116 | 0 | while(de != startDe); |
117 | 0 | } |
118 | | |
119 | | /*public*/ |
120 | | void |
121 | | MaximalEdgeRing::buildMinimalRings(std::vector<EdgeRing*>& minEdgeRings) |
122 | 0 | { |
123 | 0 | DirectedEdge* de = startDe; |
124 | 0 | do { |
125 | 0 | if(de->getMinEdgeRing() == nullptr) { |
126 | 0 | MinimalEdgeRing* minEr = new MinimalEdgeRing(de, geometryFactory); |
127 | 0 | minEdgeRings.push_back(minEr); |
128 | 0 | } |
129 | 0 | de = de->getNext(); |
130 | 0 | } |
131 | 0 | while(de != startDe); |
132 | 0 | } |
133 | | |
134 | | } // namespace geos.operation.overlay |
135 | | } // namespace geos.operation |
136 | | } // namespace geos |