GEOS  3.4.2
ScaledNoder.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/ScaledNoder.java rev. 1.3 (JTS-1.7.1)
16  *
17  **********************************************************************/
18 
19 #ifndef GEOS_NODING_SCALEDNODER_H
20 #define GEOS_NODING_SCALEDNODER_H
21 
22 #include <geos/export.h>
23 
24 #include <cassert>
25 #include <vector>
26 
27 #include <geos/inline.h>
28 #include <geos/noding/Noder.h> // for inheritance
29 //#include <geos/geom/CoordinateFilter.h> // for inheritance
30 #include <geos/util.h>
31 
32 #ifdef _MSC_VER
33 #pragma warning(push)
34 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
35 #endif
36 
37 // Forward declarations
38 namespace geos {
39  namespace geom {
40  class Coordinate;
41  class CoordinateSequence;
42  }
43  namespace noding {
44  class SegmentString;
45  }
46 }
47 
48 namespace geos {
49 namespace noding { // geos.noding
50 
61 class GEOS_DLL ScaledNoder : public Noder { // , public geom::CoordinateFilter { // implements Noder
62 
63 public:
64 
65  bool isIntegerPrecision() { return (scaleFactor == 1.0); }
66 
67  ScaledNoder(Noder& n, double nScaleFactor,
68  double nOffsetX=0.0, double nOffsetY=0.0)
69  :
70  noder(n),
71  scaleFactor(nScaleFactor),
72  offsetX(nOffsetX),
73  offsetY(nOffsetY),
74  isScaled(nScaleFactor!=1.0)
75  {}
76 
77  ~ScaledNoder();
78 
79  std::vector<SegmentString*>* getNodedSubstrings() const;
80 
81  void computeNodes(std::vector<SegmentString*>* inputSegStr);
82 
83  //void filter(Coordinate& c);
84 
85  void filter_ro(const geom::Coordinate* c)
86  {
87  ::geos::ignore_unused_variable_warning(c);
88  assert(0);
89  }
90 
91  void filter_rw(geom::Coordinate* c) const;
92 
93 private:
94 
95  Noder& noder;
96 
97  double scaleFactor;
98 
99  double offsetX;
100 
101  double offsetY;
102 
103  bool isScaled;
104 
105  void rescale(std::vector<SegmentString*>& segStrings) const;
106 
107  void scale(std::vector<SegmentString*>& segStrings) const;
108 
109  class Scaler;
110 
111  class ReScaler;
112 
113  friend class ScaledNoder::Scaler;
114 
115  friend class ScaledNoder::ReScaler;
116 
117  mutable std::vector<geom::CoordinateSequence*> newCoordSeq;
118 
119  // Declare type as noncopyable
120  ScaledNoder(const ScaledNoder& other);
121  ScaledNoder& operator=(const ScaledNoder& rhs);
122 };
123 
124 } // namespace geos.noding
125 } // namespace geos
126 
127 #ifdef _MSC_VER
128 #pragma warning(pop)
129 #endif
130 
131 #endif // GEOS_NODING_SCALEDNODER_H
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Wraps a Noder and transforms its input into the integer domain.
Definition: ScaledNoder.h:61
Computes all intersections between segments in a set of SegmentString.
Definition: Noder.h:49