/src/geos/include/geos/noding/ScaledNoder.h
Line | Count | Source (jump to first uncovered line) |
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/ScaledNoder.java rev. 1.3 (JTS-1.7.1) |
16 | | * |
17 | | **********************************************************************/ |
18 | | |
19 | | #pragma once |
20 | | |
21 | | #include <geos/export.h> |
22 | | |
23 | | #include <cassert> |
24 | | #include <vector> |
25 | | |
26 | | #include <geos/noding/Noder.h> // for inheritance |
27 | | #include <geos/util.h> |
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 |
35 | | namespace geos { |
36 | | namespace geom { |
37 | | class Coordinate; |
38 | | class CoordinateSequence; |
39 | | } |
40 | | namespace noding { |
41 | | class SegmentString; |
42 | | } |
43 | | } |
44 | | |
45 | | namespace geos { |
46 | | namespace noding { // geos.noding |
47 | | |
48 | | /** \brief |
49 | | * Wraps a {@link Noder} and transforms its input |
50 | | * into the integer domain. |
51 | | * |
52 | | * This is intended for use with Snap-Rounding noders, |
53 | | * which typically are only intended to work in the integer domain. |
54 | | * Offsets can be provided to increase the number of digits of |
55 | | * available precision. |
56 | | * |
57 | | */ |
58 | | class GEOS_DLL ScaledNoder : public Noder { // , public geom::CoordinateFilter { // implements Noder |
59 | | |
60 | | public: |
61 | | |
62 | | bool |
63 | | isIntegerPrecision() |
64 | 0 | { |
65 | 0 | return (scaleFactor == 1.0); |
66 | 0 | } |
67 | | |
68 | | ScaledNoder(Noder& n, double nScaleFactor, |
69 | | double nOffsetX = 0.0, double nOffsetY = 0.0) |
70 | | : |
71 | 0 | noder(n), |
72 | 0 | scaleFactor(nScaleFactor), |
73 | 0 | offsetX(nOffsetX), |
74 | 0 | offsetY(nOffsetY), |
75 | 0 | isScaled(nScaleFactor != 1.0) |
76 | 0 | {} |
77 | | |
78 | | ~ScaledNoder() override; |
79 | | |
80 | | std::vector<SegmentString*>* getNodedSubstrings() const override; |
81 | | |
82 | | void computeNodes(std::vector<SegmentString*>* inputSegStr) override; |
83 | | |
84 | | //void filter(Coordinate& c); |
85 | | |
86 | | void |
87 | | filter_ro(const geom::Coordinate* c) |
88 | 0 | { |
89 | 0 | ::geos::ignore_unused_variable_warning(c); |
90 | 0 | assert(0); |
91 | 0 | } |
92 | | |
93 | | void filter_rw(geom::Coordinate* c) const; |
94 | | |
95 | | private: |
96 | | |
97 | | Noder& noder; |
98 | | |
99 | | double scaleFactor; |
100 | | |
101 | | double offsetX; |
102 | | |
103 | | double offsetY; |
104 | | |
105 | | bool isScaled; |
106 | | |
107 | | void rescale(std::vector<SegmentString*>& segStrings) const; |
108 | | |
109 | | void scale(std::vector<SegmentString*>& segStrings) const; |
110 | | |
111 | | class Scaler; |
112 | | |
113 | | class ReScaler; |
114 | | |
115 | | friend class ScaledNoder::Scaler; |
116 | | |
117 | | friend class ScaledNoder::ReScaler; |
118 | | |
119 | | mutable std::vector<geom::CoordinateSequence*> newCoordSeq; |
120 | | |
121 | | // Declare type as noncopyable |
122 | | ScaledNoder(const ScaledNoder& other) = delete; |
123 | | ScaledNoder& operator=(const ScaledNoder& rhs) = delete; |
124 | | }; |
125 | | |
126 | | } // namespace geos.noding |
127 | | } // namespace geos |
128 | | |
129 | | #ifdef _MSC_VER |
130 | | #pragma warning(pop) |
131 | | #endif |
132 | | |