61 class BoundaryChainMap {
67 std::vector<bool> isBoundary;
69 static std::unique_ptr<SegmentString> createChain(
71 std::size_t startIndex,
76 std::size_t findChainStart(std::size_t index)
const;
77 std::size_t findChainEnd(std::size_t index)
const;
83 isBoundary.resize(ss->size()-1,
false);
86 void setBoundarySegment(std::size_t index);
87 void createChains(std::vector<std::unique_ptr<SegmentString>> &chains,
bool constructZ,
bool constructM);
93 BoundaryChainMap& segMap,
98 , m_flip(seq.
getAt<geom::CoordinateXY>(index).compareTo(seq.
getAt<geom::CoordinateXY>(index + 1)) < 0)
101 const geom::CoordinateXY& p0()
const {
102 return m_seq.getAt<geom::CoordinateXY>(m_flip ? m_index : m_index + 1);
105 const geom::CoordinateXY& p1()
const {
106 return m_seq.getAt<geom::CoordinateXY>(m_flip ? m_index + 1 : m_index);
109 void markBoundary()
const {
110 m_segMap.setBoundarySegment(m_index);
113 bool operator==(
const Segment& other)
const {
114 return p0().equals2D(other.p0()) && p1().equals2D(other.p1());
118 std::size_t operator()(
const Segment& s)
const {
119 std::size_t h = std::hash<double>{}(s.p0().x);
120 h ^= (std::hash<double>{}(s.p0().y) << 1);
121 h ^= (std::hash<double>{}(s.p1().x) << 1);
122 h ^= (std::hash<double>{}(s.p1().y) << 1);
129 BoundaryChainMap& m_segMap;
137 using SegmentSet = std::unordered_set<Segment, Segment::HashCode>;
140 : m_constructZ(
false)
141 , m_constructM(
false)
146 void computeNodes(
const std::vector<SegmentString*>& inputSegStrings)
override;
152 std::vector<std::unique_ptr<SegmentString>> m_chainList;
153 std::vector<std::unique_ptr<geom::CoordinateSequence>> m_substrings;
158 void addSegments(
const std::vector<SegmentString*>& segStrings,
160 std::vector<BoundaryChainMap>& includedSegs);
163 BoundaryChainMap& segInclude,
166 static bool segSetContains(
167 SegmentSet& segSet, Segment& seg);
169 static void markBoundarySegments(SegmentSet& segSet);
171 std::vector<std::unique_ptr<SegmentString>> extractChains(std::vector<BoundaryChainMap>& sections)
const;
173 static Coordinate::UnorderedSet findNodePts(
174 const std::vector<std::unique_ptr<SegmentString>>& segStrings);
176 static std::vector<std::unique_ptr<SegmentString>> nodeChains(
177 std::vector<std::unique_ptr<SegmentString>> &chains,
178 const Coordinate::UnorderedSet &nodePts);
180 static void nodeChain(
181 std::unique_ptr<SegmentString> chain,
182 const Coordinate::UnorderedSet &nodePts,
183 std::vector<std::unique_ptr<SegmentString>> &nodedChains);
185 static std::size_t findNodeIndex(
188 const Coordinate::UnorderedSet& nodePts);
190 static std::unique_ptr<BasicSegmentString> substring(
192 std::size_t start, std::size_t end);