1 /**********************************************************************
3 * GEOS - Geometry Engine Open Source
4 * http://geos.refractions.net
6 * Copyright (C) 2006 Refractions Research Inc.
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
13 **********************************************************************
15 * Last port: noding/snapround/MCIndexSnapRounder.java r480 (JTS-1.12)
17 **********************************************************************/
19 #ifndef GEOS_NODING_SNAPROUND_MCINDEXSNAPROUNDER_H
20 #define GEOS_NODING_SNAPROUND_MCINDEXSNAPROUNDER_H
22 #include <geos/export.h>
24 #include <geos/noding/Noder.h> // for inheritance
25 #include <geos/noding/NodedSegmentString.h> // for inlines
26 #include <geos/noding/snapround/MCIndexPointSnapper.h> // for inines
27 #include <geos/algorithm/LineIntersector.h> // for composition
28 #include <geos/geom/Coordinate.h> // for use in vector
29 #include <geos/geom/PrecisionModel.h> // for inlines
35 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
38 // Forward declarations
41 class LineIntersector
;
50 namespace noding
{ // geos::noding
51 namespace snapround
{ // geos::noding::snapround
55 * Uses Snap Rounding to compute a rounded,
56 * fully noded arrangement from a set of SegmentString
58 * Implements the Snap Rounding technique described in Hobby, Guibas & Marimont,
61 * Snap Rounding assumes that all vertices lie on a uniform grid
62 * (hence the precision model of the input must be fixed precision,
63 * and all the input vertices must be rounded to that precision).
65 * This implementation uses a monotone chains and a spatial index to
66 * speed up the intersection tests.
68 * This implementation appears to be fully robust using an integer
71 * It will function with non-integer precision models, but the
72 * results are not 100% guaranteed to be correctly noded.
74 class GEOS_DLL MCIndexSnapRounder
: public Noder
{ // implments Noder
78 MCIndexSnapRounder(geom::PrecisionModel
& nPm
)
81 scaleFactor(nPm
.getScale()),
84 li
.setPrecisionModel(&pm
);
87 std::vector
<SegmentString
*>* getNodedSubstrings() const {
88 return NodedSegmentString::getNodedSubstrings(*nodedSegStrings
);
91 void computeNodes(std::vector
<SegmentString
*>* segStrings
);
94 * Computes nodes introduced as a result of
95 * snapping segments to vertices of other segments
97 * @param edges the list of segment strings to snap together
98 * NOTE: they *must* be instances of NodedSegmentString, or
99 * an assertion will fail.
101 void computeVertexSnaps(std::vector
<SegmentString
*>& edges
);
106 geom::PrecisionModel
& pm
;
108 algorithm::LineIntersector li
;
112 std::vector
<SegmentString
*>* nodedSegStrings
;
114 std::auto_ptr
<MCIndexPointSnapper
> pointSnapper
;
116 void snapRound(MCIndexNoder
& noder
, std::vector
<SegmentString
*>* segStrings
);
120 * Computes all interior intersections in the collection of SegmentStrings,
121 * and push their Coordinate to the provided vector.
123 * Does NOT node the segStrings.
126 void findInteriorIntersections(MCIndexNoder
& noder
,
127 std::vector
<SegmentString
*>* segStrings
,
128 std::vector
<geom::Coordinate
>& intersections
);
131 * Computes nodes introduced as a result of snapping
132 * segments to snap points (hot pixels)
134 void computeIntersectionSnaps(std::vector
<geom::Coordinate
>& snapPts
);
137 * Performs a brute-force comparison of every segment in each {@link SegmentString}.
138 * This has n^2 performance.
140 void computeVertexSnaps(NodedSegmentString
* e
);
142 void checkCorrectness(std::vector
<SegmentString
*>& inputSegmentStrings
);
144 // Declare type as noncopyable
145 MCIndexSnapRounder(const MCIndexSnapRounder
& other
);
146 MCIndexSnapRounder
& operator=(const MCIndexSnapRounder
& rhs
);
149 } // namespace geos::noding::snapround
150 } // namespace geos::noding
157 #endif // GEOS_NODING_SNAPROUND_MCINDEXSNAPROUNDER_H
159 /**********************************************************************
161 * Revision 1.2 2006/03/24 09:52:41 strk
162 * USE_INLINE => GEOS_INLINE
164 * Revision 1.1 2006/03/14 12:55:56 strk
165 * Headers split: geomgraphindex.h, nodingSnapround.h
167 **********************************************************************/