GEOS 3.11.1
LinkedRing.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2021 Paul Ramsey <pramsey@cleverelephant.ca>
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#pragma once
16
17#include <memory>
18
19#include <geos/geom/Coordinate.h>
20
21namespace geos {
22namespace geom {
23class Coordinate;
25}
26namespace triangulate {
27namespace quadedge {
28}
29}
30}
31
34
35namespace geos {
36namespace simplify { // geos::simplify
37
38
39
40class LinkedRing
41{
42 private:
43
44 static constexpr std::size_t
45 NO_COORD_INDEX = std::numeric_limits<std::size_t>::max();
46
47 const std::vector<Coordinate>& m_coord;
48 std::size_t m_size;
49 std::vector<std::size_t> m_next;
50 std::vector<std::size_t> m_prev;
51
52 static std::vector<std::size_t> createNextLinks(std::size_t size);
53 static std::vector<std::size_t> createPrevLinks(std::size_t size);
54
55
56 public:
57
58 LinkedRing(const std::vector<Coordinate>& cs)
59 : m_coord(cs)
60 , m_size(cs.size()-1)
61 , m_next(createNextLinks(m_size))
62 , m_prev(createPrevLinks(m_size))
63 {};
64
65 std::size_t size() const;
66 std::size_t next(std::size_t i) const;
67 std::size_t prev(std::size_t i) const;
68 const Coordinate& getCoordinate(std::size_t index) const;
69 const Coordinate& prevCoordinate(std::size_t index) const;
70 const Coordinate& nextCoordinate(std::size_t index) const;
71 bool hasCoordinate(std::size_t index) const;
72 void remove(std::size_t index);
73 std::unique_ptr<CoordinateArraySequence> getCoordinates() const;
74
75
76}; // LinkedRing
77
78
79} // geos::simplify
80} // geos
81
The default implementation of CoordinateSequence.
Definition: CoordinateArraySequence.h:35
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
Basic namespace for all GEOS functionalities.
Definition: geos.h:39