/src/geos/include/geos/noding/BasicSegmentString.h
Line | Count | Source |
1 | | /********************************************************************** |
2 | | * |
3 | | * GEOS - Geometry Engine Open Source |
4 | | * http://geos.osgeo.org |
5 | | * |
6 | | * Copyright (C) 2009 Sandro Santilli <strk@kbt.io> |
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/BasicSegmentString.java rev. 1.1 (JTS-1.9) |
16 | | * |
17 | | **********************************************************************/ |
18 | | |
19 | | #pragma once |
20 | | |
21 | | #include <geos/export.h> |
22 | | #include <geos/noding/BasicSegmentString.h> |
23 | | #include <geos/noding/Octant.h> |
24 | | #include <geos/noding/SegmentString.h> // for inheritance |
25 | | #include <geos/geom/CoordinateSequence.h> // for inlines (size()) |
26 | | |
27 | | |
28 | | #include <vector> |
29 | | |
30 | | // Forward declarations |
31 | | |
32 | | namespace geos { |
33 | | namespace noding { // geos.noding |
34 | | |
35 | | /** \brief |
36 | | * Represents a list of contiguous line segments, and supports noding the segments. |
37 | | * |
38 | | * The line segments are represented by an array of [Coordinates](@ref geom::Coordinate). |
39 | | * Intended to optimize the noding of contiguous segments by reducing the number |
40 | | * of allocated objects. SegmentStrings can carry a context object, which is |
41 | | * useful for preserving topological or parentage information. |
42 | | * All noded substrings are initialized with the same context object. |
43 | | */ |
44 | | class GEOS_DLL BasicSegmentString : public SegmentString { |
45 | | |
46 | | public: |
47 | | |
48 | | /// \brief Construct a BasicSegmentString. |
49 | | /// |
50 | | /// @param newPts CoordinateSequence representing the string, externally owned |
51 | | /// @param newContext the context associated to this SegmentString |
52 | | /// |
53 | | BasicSegmentString(geom::CoordinateSequence* newPts, |
54 | | const void* newContext) |
55 | | : |
56 | 0 | SegmentString(newContext, newPts) |
57 | 0 | {} |
58 | | |
59 | | ~BasicSegmentString() override |
60 | 0 | {} |
61 | | |
62 | | // see dox in SegmentString.h |
63 | | std::ostream& print(std::ostream& os) const override; |
64 | | |
65 | | /** \brief |
66 | | * Gets the octant of the segment starting at vertex index. |
67 | | * |
68 | | * @param index the index of the vertex starting the segment. |
69 | | * Must not be the last index in the vertex list |
70 | | * @return the octant of the segment at the vertex |
71 | | */ |
72 | | int getSegmentOctant(std::size_t index) const |
73 | 0 | { |
74 | 0 | if(index >= size() - 1) { |
75 | 0 | return -1; |
76 | 0 | } |
77 | 0 | return Octant::octant(getCoordinate(index), getCoordinate(index + 1)); |
78 | 0 | }; |
79 | | |
80 | | private: |
81 | | |
82 | | // Declare type as noncopyable |
83 | | BasicSegmentString(const BasicSegmentString& other) = delete; |
84 | | BasicSegmentString& operator=(const BasicSegmentString& rhs) = delete; |
85 | | |
86 | | }; |
87 | | |
88 | | } // namespace geos.noding |
89 | | } // namespace geos |