GEOS  3.13.0dev
MCIndexSnapRounder.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/MCIndexSnapRounder.java r486 (JTS-1.12+)
16  *
17  **********************************************************************/
18 
19 #pragma once
20 
21 #include <geos/export.h>
22 
23 #include <geos/noding/Noder.h> // for inheritance
24 #include <geos/noding/NodedSegmentString.h> // for inlines
25 #include <geos/noding/snapround/MCIndexPointSnapper.h> // for inlines
26 #include <geos/algorithm/LineIntersector.h> // for composition
27 #include <geos/geom/Coordinate.h> // for use in vector
28 #include <geos/geom/PrecisionModel.h> // for inlines
29 
30 #include <vector>
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 algorithm {
40 class LineIntersector;
41 }
42 namespace noding {
43 class SegmentString;
44 class MCIndexNoder;
45 }
46 }
47 
48 namespace geos {
49 namespace noding { // geos::noding
50 namespace snapround { // geos::noding::snapround
51 
52 
73 class GEOS_DLL MCIndexSnapRounder: public Noder { // implements Noder
74 
75 public:
76 
78  :
79  pm(nPm),
80  scaleFactor(nPm.getScale()),
81  pointSnapper(nullptr)
82  {
83  li.setPrecisionModel(&pm);
84  }
85 
86  std::vector<SegmentString*>*
87  getNodedSubstrings() const override
88  {
89  return NodedSegmentString::getNodedSubstrings(*nodedSegStrings);
90  }
91 
92  void computeNodes(std::vector<SegmentString*>* segStrings) override;
93 
102  void computeVertexSnaps(std::vector<SegmentString*>& edges);
103 
104 private:
105 
107  const geom::PrecisionModel& pm;
108 
110 
111  double scaleFactor;
112 
113  std::vector<SegmentString*>* nodedSegStrings;
114 
115  std::unique_ptr<MCIndexPointSnapper> pointSnapper;
116 
117  void snapRound(MCIndexNoder& noder, std::vector<SegmentString*>* segStrings);
118 
119 
127  void findInteriorIntersections(MCIndexNoder& noder,
128  std::vector<SegmentString*>* segStrings,
129  std::vector<geom::Coordinate>& intersections);
130 
135  void computeIntersectionSnaps(std::vector<geom::Coordinate>& snapPts);
136 
141  void computeVertexSnaps(NodedSegmentString* e);
142 
143  void checkCorrectness(std::vector<SegmentString*>& inputSegmentStrings);
144 
145  // Declare type as noncopyable
146  MCIndexSnapRounder(const MCIndexSnapRounder& other) = delete;
147  MCIndexSnapRounder& operator=(const MCIndexSnapRounder& rhs) = delete;
148 };
149 
150 } // namespace geos::noding::snapround
151 } // namespace geos::noding
152 } // namespace geos
153 
154 #ifdef _MSC_VER
155 #pragma warning(pop)
156 #endif
157 
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition: LineIntersector.h:53
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:88
double getScale() const
Returns the multiplying factor used to obtain a precise coordinate.
Definition: PrecisionModel.h:230
Nodes a set of SegmentString using a index based on MonotoneChain and a SpatialIndex.
Definition: MCIndexNoder.h:65
Represents a list of contiguous line segments, and supports noding the segments.
Definition: NodedSegmentString.h:58
Computes all intersections between segments in a set of SegmentString.
Definition: Noder.h:46
Uses Snap Rounding to compute a rounded, fully noded arrangement from a set of SegmentString.
Definition: MCIndexSnapRounder.h:73
void computeVertexSnaps(std::vector< SegmentString * > &edges)
std::vector< SegmentString * > * getNodedSubstrings() const override
Returns a collection of fully noded SegmentStrings. The SegmentStrings have the same context as their...
Definition: MCIndexSnapRounder.h:87
void computeNodes(std::vector< SegmentString * > *segStrings) override
Computes the noding for a collection of SegmentStrings.
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25