GEOS  3.6.2
ScaledNoder.h
00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2006      Refractions Research Inc.
00007  *
00008  * This is free software; you can redistribute and/or modify it under
00009  * the terms of the GNU Lesser General Public Licence as published
00010  * by the Free Software Foundation. 
00011  * See the COPYING file for more information.
00012  *
00013  **********************************************************************
00014  *
00015  * Last port: noding/ScaledNoder.java rev. 1.3 (JTS-1.7.1)
00016  *
00017  **********************************************************************/
00018 
00019 #ifndef GEOS_NODING_SCALEDNODER_H
00020 #define GEOS_NODING_SCALEDNODER_H
00021 
00022 #include <geos/export.h>
00023 
00024 #include <cassert>
00025 #include <vector>
00026 
00027 #include <geos/inline.h>
00028 #include <geos/noding/Noder.h> // for inheritance
00029 //#include <geos/geom/CoordinateFilter.h> // for inheritance
00030 #include <geos/util.h>
00031 
00032 #ifdef _MSC_VER
00033 #pragma warning(push)
00034 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00035 #endif
00036 
00037 // Forward declarations
00038 namespace geos {
00039         namespace geom {
00040                 class Coordinate;
00041                 class CoordinateSequence;
00042         }
00043         namespace noding {
00044                 class SegmentString;
00045         }
00046 }
00047 
00048 namespace geos {
00049 namespace noding { // geos.noding
00050 
00061 class GEOS_DLL ScaledNoder : public Noder { // , public geom::CoordinateFilter { // implements Noder
00062 
00063 public:
00064 
00065         bool isIntegerPrecision() { return (scaleFactor == 1.0); }
00066 
00067         ScaledNoder(Noder& n, double nScaleFactor,
00068                         double nOffsetX=0.0, double nOffsetY=0.0)
00069                 :
00070                 noder(n),
00071                 scaleFactor(nScaleFactor),
00072                 offsetX(nOffsetX),
00073                 offsetY(nOffsetY),
00074                 isScaled(nScaleFactor!=1.0)
00075         {}
00076 
00077         ~ScaledNoder();
00078 
00079         std::vector<SegmentString*>* getNodedSubstrings() const;
00080 
00081         void computeNodes(std::vector<SegmentString*>* inputSegStr);
00082 
00083         //void filter(Coordinate& c);
00084 
00085         void filter_ro(const geom::Coordinate* c)
00086     {
00087         ::geos::ignore_unused_variable_warning(c);
00088         assert(0);
00089     }
00090 
00091         void filter_rw(geom::Coordinate* c) const;
00092 
00093 private:
00094 
00095         Noder& noder;
00096 
00097         double scaleFactor;
00098 
00099         double offsetX;
00100 
00101         double offsetY;
00102 
00103         bool isScaled;
00104 
00105         void rescale(std::vector<SegmentString*>& segStrings) const;
00106 
00107         void scale(std::vector<SegmentString*>& segStrings) const;
00108 
00109         class Scaler;
00110 
00111         class ReScaler;
00112 
00113         friend class ScaledNoder::Scaler;
00114 
00115         friend class ScaledNoder::ReScaler;
00116 
00117     mutable std::vector<geom::CoordinateSequence*> newCoordSeq;
00118 
00119     // Declare type as noncopyable
00120     ScaledNoder(const ScaledNoder& other);
00121     ScaledNoder& operator=(const ScaledNoder& rhs);
00122 };
00123 
00124 } // namespace geos.noding
00125 } // namespace geos
00126 
00127 #ifdef _MSC_VER
00128 #pragma warning(pop)
00129 #endif
00130 
00131 #endif // GEOS_NODING_SCALEDNODER_H