GEOS  3.4.2
MCIndexSnapRounder.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/snapround/MCIndexSnapRounder.java r486 (JTS-1.12+)
00016  *
00017  **********************************************************************/
00018 
00019 #ifndef GEOS_NODING_SNAPROUND_MCINDEXSNAPROUNDER_H
00020 #define GEOS_NODING_SNAPROUND_MCINDEXSNAPROUNDER_H
00021 
00022 #include <geos/export.h>
00023 
00024 #include <geos/noding/Noder.h> // for inheritance
00025 #include <geos/noding/NodedSegmentString.h> // for inlines
00026 #include <geos/noding/snapround/MCIndexPointSnapper.h> // for inines
00027 #include <geos/algorithm/LineIntersector.h> // for composition
00028 #include <geos/geom/Coordinate.h> // for use in vector
00029 #include <geos/geom/PrecisionModel.h> // for inlines
00030 
00031 #include <vector>
00032 
00033 #ifdef _MSC_VER
00034 #pragma warning(push)
00035 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00036 #endif
00037 
00038 // Forward declarations
00039 namespace geos {
00040         namespace algorithm {
00041                 class LineIntersector;
00042         }
00043         namespace noding {
00044                 class SegmentString;
00045                 class MCIndexNoder;
00046         }
00047 }
00048 
00049 namespace geos {
00050 namespace noding { // geos::noding
00051 namespace snapround { // geos::noding::snapround
00052 
00053 
00074 class GEOS_DLL MCIndexSnapRounder: public Noder { // implments Noder
00075 
00076 public:
00077 
00078         MCIndexSnapRounder(const geom::PrecisionModel& nPm)
00079     :
00080                 pm(nPm),
00081                 scaleFactor(nPm.getScale()),
00082                 pointSnapper(0)
00083   {
00084     li.setPrecisionModel(&pm);
00085   }
00086 
00087         std::vector<SegmentString*>* getNodedSubstrings() const {
00088           return NodedSegmentString::getNodedSubstrings(*nodedSegStrings);
00089   }
00090 
00091         void computeNodes(std::vector<SegmentString*>* segStrings);
00092  
00101         void computeVertexSnaps(std::vector<SegmentString*>& edges);
00102 
00103 private:
00104 
00106         const geom::PrecisionModel& pm;
00107 
00108         algorithm::LineIntersector li;
00109 
00110         double scaleFactor;
00111 
00112         std::vector<SegmentString*>* nodedSegStrings;
00113 
00114         std::auto_ptr<MCIndexPointSnapper> pointSnapper;
00115 
00116         void snapRound(MCIndexNoder& noder, std::vector<SegmentString*>* segStrings);
00117 
00118         
00126         void findInteriorIntersections(MCIndexNoder& noder,
00127                         std::vector<SegmentString*>* segStrings,
00128                         std::vector<geom::Coordinate>& intersections);
00129 
00134         void computeIntersectionSnaps(std::vector<geom::Coordinate>& snapPts);
00135 
00140         void computeVertexSnaps(NodedSegmentString* e);
00141         
00142         void checkCorrectness(std::vector<SegmentString*>& inputSegmentStrings);
00143 
00144     // Declare type as noncopyable
00145     MCIndexSnapRounder(const MCIndexSnapRounder& other);
00146     MCIndexSnapRounder& operator=(const MCIndexSnapRounder& rhs);
00147 };
00148 
00149 } // namespace geos::noding::snapround
00150 } // namespace geos::noding
00151 } // namespace geos
00152 
00153 #ifdef _MSC_VER
00154 #pragma warning(pop)
00155 #endif
00156 
00157 #endif // GEOS_NODING_SNAPROUND_MCINDEXSNAPROUNDER_H