GEOS: NodedSegmentString.h Source File

GEOS 3.3.8

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

- File List

NodedSegmentString.h
1 /**********************************************************************
2 * $Id: NodedSegmentString.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) 2011 Sandro Santilli <strk@keybit.net>
8 * Copyright (C) 2006 Refractions Research Inc.
9 * Copyright (C) 2001-2002 Vivid Solutions Inc.
10 *
11 * This is free software; you can redistribute and/or modify it under
12 * the terms of the GNU Lesser General Public Licence as published
13 * by the Free Software Foundation.
14 * See the COPYING file for more information.
15 *
16 *
17 **********************************************************************
18 *
19 * Last port: noding/NodedSegmentString.java r320 (JTS-1.12)
20 *
21 **********************************************************************/
22
23 #ifndef GEOS_NODING_NODEDSEGMENTSTRING_H
24 #define GEOS_NODING_NODEDSEGMENTSTRING_H
25
26 #include <geos/export.h>
27 #include <geos/noding/NodableSegmentString.h> // for inheritance
28 #include <geos/geom/CoordinateSequence.h> // for inlines
29 #include <geos/algorithm/LineIntersector.h>
30 #include <geos/noding/SegmentNode.h>
31 #include <geos/noding/SegmentNodeList.h>
32 #include <geos/noding/SegmentString.h>
33 //#include <geos/noding/Octant.h>
34 #include <geos/geom/Coordinate.h>
35
36 #include <cstddef>
37
38 #ifdef _MSC_VER
39 #pragma warning(push)
40 #pragma warning(disable: 4251 4355) // warning C4355: 'this' : used in base member initializer list
41 #endif
42
43 namespace geos {
44 namespace noding { // geos::noding
45
58 class GEOS_DLL NodedSegmentString : public NodableSegmentString
59 {
60 public:
61
62 static void getNodedSubstrings(SegmentString::ConstVect* segStrings,
63 SegmentString::NonConstVect* resultEdgelist)
64 {
65 for (ConstVect::size_type i=0, n=segStrings->size(); i<n; i++)
66 {
67 NodedSegmentString const* nss =
68 static_cast<NodedSegmentString const*>((*segStrings)[i]);
69
70 const_cast<NodedSegmentString*>(nss)->getNodeList().addSplitEdges( resultEdgelist);
71 }
72 }
73
74 static void getNodedSubstrings(const SegmentString::NonConstVect& segStrings,
75 SegmentString::NonConstVect* resultEdgeList);
76
78 static SegmentString::NonConstVect* getNodedSubstrings(
79 const SegmentString::NonConstVect& segStrings);
80
81
91 NodedSegmentString(geom::CoordinateSequence *newPts, const void* newContext)
92 : NodableSegmentString(newContext)
93 , nodeList(this)
94 , pts(newPts)
95 {}
96
97 ~NodedSegmentString()
98 {}
99
109 SegmentNode* addIntersectionNode( geom::Coordinate * intPt, std::size_t segmentIndex)
110 {
111 std::size_t normalizedSegmentIndex = segmentIndex;
112
113 // normalize the intersection point location
114 std::size_t nextSegIndex = normalizedSegmentIndex + 1;
115 if (nextSegIndex < size())
116 {
117 geom::Coordinate const& nextPt =
118 getCoordinate(static_cast<unsigned int>(nextSegIndex));
119
120 // Normalize segment index if intPt falls on vertex
121 // The check for point equality is 2D only - Z values are ignored
122 if ( intPt->equals2D( nextPt ))
123 {
124 normalizedSegmentIndex = nextSegIndex;
125 }
126 }
127
128 // Add the intersection point to edge intersection list.
129 SegmentNode * ei = getNodeList().add( *intPt, normalizedSegmentIndex);
130 return ei;
131 }
132
133 SegmentNodeList& getNodeList();
134
135 const SegmentNodeList& getNodeList() const;
136
137 virtual unsigned int size() const
138 {
139 return static_cast<unsigned int>(pts->size());
140 }
141
142 virtual const geom::Coordinate& getCoordinate(unsigned int i) const;
143
144 virtual geom::CoordinateSequence* getCoordinates() const;
145
146 virtual bool isClosed() const;
147
148 virtual std::ostream& print(std::ostream& os) const;
149
150
158 int getSegmentOctant(unsigned int index) const;
159
165 void addIntersections(algorithm::LineIntersector *li,
166 unsigned int segmentIndex, int geomIndex);
167
175 void addIntersection(algorithm::LineIntersector *li,
176 unsigned int segmentIndex,
177 int geomIndex, int intIndex);
178
186 void addIntersection(const geom::Coordinate& intPt,
187 unsigned int segmentIndex);
188
189
190 private:
191
192 SegmentNodeList nodeList;
193
194 geom::CoordinateSequence *pts;
195
196 static int safeOctant(const geom::Coordinate& p0, const geom::Coordinate& p1);
197
198 };
199
200 } // namespace geos::noding
201 } // namespace geos
202
203 #ifdef _MSC_VER
204 #pragma warning(pop)
205 #endif
206
207 #endif // GEOS_NODING_NODEDSEGMENTSTRING_H
208 /**********************************************************************
209 * $Log$
210 **********************************************************************/
211