GEOS 3.15.0dev
Traversal.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2018-2025 ISciences, LLC
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 <geos/export.h>
18#include <geos/geom/Coordinate.h>
19#include <geos/operation/grid/Side.h>
20
21#include <vector>
22
23namespace geos::operation::grid {
24
30class GEOS_DLL Traversal
31{
32 public:
33 Traversal()
34 : m_entry{ Side::NONE }
35 , m_exit{ Side::NONE }
36 , m_parentage{ nullptr }
37 {
38 }
39
40 bool isClosedRing() const;
41
42 bool isClosedRingWithArea() const;
43
44 bool isEmpty() const;
45
46 bool isEntered() const;
47
48 bool isExited() const;
49
50 bool isTraversed() const;
51
52 bool hasMultipleUniqueCoordinates() const;
53
55 void enter(const geom::CoordinateXY& c, Side s, const void* parentage);
56
58 void exit(const geom::CoordinateXY& c, Side s);
59
60 Side getEntrySide() const { return m_entry; }
61
62 Side getExitSide() const { return m_exit; }
63
64 const geom::CoordinateXY& getFirstCoordinate() const;
65
66 const geom::CoordinateXY& getLastCoordinate() const;
67
68 const geom::CoordinateXY& getExitCoordinate() const;
69
70 void add(const geom::CoordinateXY& c);
71
72 void forceExit(Side s) { m_exit = s; }
73
74 const std::vector<geom::CoordinateXY>& getCoordinates() const { return m_coords; }
75
76 const void* getParentage() const { return m_parentage; }
77
78 private:
79 std::vector<geom::CoordinateXY> m_coords;
80 Side m_entry;
81 Side m_exit;
82 const void* m_parentage;
83};
84
85}
The Traversal class records the coordinates of a line that are within a grid cell,...
Definition Traversal.h:31
void exit(const geom::CoordinateXY &c, Side s)
Complete a Traversal on the specified Side
void enter(const geom::CoordinateXY &c, Side s, const void *parentage)
Begin a Traversal on the specified Side