GEOS 3.8.1
HotPixel.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2006 Refractions Research Inc.
7 *
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.
12 *
13 **********************************************************************
14 *
15 * Last port: noding/snapround/HotPixel.java r320 (JTS-1.12)
16 *
17 **********************************************************************/
18
19#ifndef GEOS_NODING_SNAPROUND_HOTPIXEL_H
20#define GEOS_NODING_SNAPROUND_HOTPIXEL_H
21
22#include <geos/export.h>
23
24#include <geos/inline.h>
25
26#include <geos/geom/Coordinate.h> // for composition
27#include <geos/geom/Envelope.h> // for unique_ptr
28
29#ifdef _MSC_VER
30#pragma warning(push)
31#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
32#endif
33
34// Forward declarations
35namespace geos {
36namespace geom {
37class Envelope;
38}
39namespace algorithm {
40class LineIntersector;
41}
42namespace noding {
43class NodedSegmentString;
44}
45}
46
47namespace geos {
48namespace noding { // geos::noding
49namespace snapround { // geos::noding::snapround
50
62class GEOS_DLL HotPixel {
63
64private:
65
67
69 const geom::Coordinate& originalPt;
70 geom::Coordinate ptScaled;
71
72 mutable geom::Coordinate p0Scaled;
73 mutable geom::Coordinate p1Scaled;
74
75 double scaleFactor;
76
77 double minx;
78 double maxx;
79 double miny;
80 double maxy;
81
89 std::vector<geom::Coordinate> corner;
90
92 mutable std::unique_ptr<geom::Envelope> safeEnv;
93
94 void initCorners(const geom::Coordinate& pt);
95
96 double scale(double val) const;
97
98 void copyScaled(const geom::Coordinate& p,
99 geom::Coordinate& pScaled) const;
100
122 bool intersectsToleranceSquare(const geom::Coordinate& p0,
123 const geom::Coordinate& p1) const;
124
125
140 bool intersectsPixelClosure(const geom::Coordinate& p0,
141 const geom::Coordinate& p1);
142
143 bool intersectsScaled(const geom::Coordinate& p0,
144 const geom::Coordinate& p1) const;
145
146 // Declare type as noncopyable
147 HotPixel(const HotPixel& other) = delete;
148 HotPixel& operator=(const HotPixel& rhs) = delete;
149
150public:
151
162 double scaleFact,
164
168 const geom::Coordinate&
170 {
171 return originalPt;
172 }
173
182
191 const geom::Coordinate& p1) const;
192
201 bool addSnappedNode(NodedSegmentString& segStr, std::size_t segIndex);
202
203};
204
205} // namespace geos::noding::snapround
206} // namespace geos::noding
207} // namespace geos
208
209#ifdef _MSC_VER
210#pragma warning(pop)
211#endif
212
213#ifdef GEOS_INLINE
214# include "geos/noding/snapround/HotPixel.inl"
215#endif
216
217#endif // GEOS_NODING_SNAPROUND_HOTPIXEL_H
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition: LineIntersector.h:49
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
Represents a list of contiguous line segments, and supports noding the segments.
Definition: NodedSegmentString.h:57
Implements a "hot pixel" as used in the Snap Rounding algorithm.
Definition: HotPixel.h:62
bool intersects(const geom::Coordinate &p0, const geom::Coordinate &p1) const
bool addSnappedNode(NodedSegmentString &segStr, std::size_t segIndex)
const geom::Coordinate & getCoordinate() const
Return reference to original Coordinate (the one provided at construction time)
Definition: HotPixel.h:169
const geom::Envelope & getSafeEnvelope() const
Returns a "safe" envelope that is guaranteed to contain the hot pixel. Keeps ownership of it.
HotPixel(const geom::Coordinate &pt, double scaleFact, algorithm::LineIntersector &li)
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25