Coverage Report

Created: 2026-04-01 06:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/geos/include/geos/geomgraph/DirectedEdgeStar.h
Line
Count
Source
1
/**********************************************************************
2
 *
3
 * GEOS - Geometry Engine Open Source
4
 * http://geos.osgeo.org
5
 *
6
 * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
7
 * Copyright (C) 2005-2006 Refractions Research Inc.
8
 * Copyright (C) 2001-2002 Vivid Solutions Inc.
9
 *
10
 * This is free software; you can redistribute and/or modify it under
11
 * the terms of the GNU Lesser General Public Licence as published
12
 * by the Free Software Foundation.
13
 * See the COPYING file for more information.
14
 *
15
 **********************************************************************
16
 *
17
 * Last port: geomgraph/DirectedEdgeStar.java r428 (JTS-1.12+)
18
 *
19
 **********************************************************************/
20
21
22
#pragma once
23
24
#include <memory>
25
#include <geos/export.h>
26
#include <set>
27
#include <string>
28
#include <vector>
29
30
#include <geos/geomgraph/EdgeEndStar.h>  // for inheritance
31
#include <geos/geomgraph/Label.h>  // for private member
32
#include <geos/geom/Coordinate.h>  // for p0,p1
33
34
35
// Forward declarations
36
namespace geos {
37
namespace geomgraph {
38
class DirectedEdge;
39
class EdgeRing;
40
}
41
}
42
43
namespace geos {
44
namespace geomgraph { // geos.geomgraph
45
46
/**
47
 * \brief
48
 * A DirectedEdgeStar is an ordered list of **outgoing** DirectedEdges around a node.
49
 *
50
 * It supports labelling the edges as well as linking the edges to form both
51
 * MaximalEdgeRings and MinimalEdgeRings.
52
 *
53
 */
54
class GEOS_DLL DirectedEdgeStar: public EdgeEndStar {
55
56
public:
57
58
    DirectedEdgeStar()
59
        :
60
0
        EdgeEndStar(),
61
0
        label(),
62
0
        resultAreaEdgesComputed(false)
63
0
    {}
64
65
0
    ~DirectedEdgeStar() override = default;
66
67
    /// Insert a directed edge in the list
68
    void insert(EdgeEnd* ee) override;
69
70
    Label&
71
    getLabel()
72
0
    {
73
0
        return label;
74
0
    }
75
76
    int getOutgoingDegree();
77
78
    int getOutgoingDegree(EdgeRing* er);
79
80
    DirectedEdge* getRightmostEdge();
81
82
    /** \brief
83
     * Compute the labelling for all dirEdges in this star, as well as the overall labelling
84
     */
85
    void computeLabelling(const std::vector<std::unique_ptr<GeometryGraph>>&geom) override; // throw(TopologyException *);
86
87
    /** \brief
88
     * For each dirEdge in the star, merge the label from the sym dirEdge into the label
89
     */
90
    void mergeSymLabels();
91
92
    /// \brief Update incomplete dirEdge labels from the labelling for the node
93
    void updateLabelling(const Label& nodeLabel);
94
95
96
    /** \brief
97
     * Traverse the star of DirectedEdges, linking the included edges together.
98
     *
99
     * To link two dirEdges, the `next` pointer for an incoming dirEdge
100
     * is set to the next outgoing edge.
101
     *
102
     * DirEdges are only linked if:
103
     *
104
     * - they belong to an area (i.e. they have sides)
105
     * - they are marked as being in the result
106
     *
107
     * Edges are linked in CCW order (the order they are stored). This means
108
     * that rings have their face on the Right (in other words, the topological
109
     * location of the face is given by the RHS label of the DirectedEdge)
110
     *
111
     * PRECONDITION: No pair of dirEdges are both marked as being in the result
112
     */
113
    void linkResultDirectedEdges(); // throw(TopologyException *);
114
115
    void linkMinimalDirectedEdges(EdgeRing* er);
116
117
    void linkAllDirectedEdges();
118
119
    /** \brief
120
     * Traverse the star of edges, maintaining the current location in the result
121
     * area at this node (if any).
122
     *
123
     * If any L edges are found in the interior of the result, mark them as covered.
124
     */
125
    void findCoveredLineEdges();
126
127
    /** \brief
128
     * Compute the DirectedEdge depths for a subsequence of the edge array.
129
     */
130
    void computeDepths(DirectedEdge* de);
131
132
    std::string print() const override;
133
134
private:
135
136
    /**
137
     * A list of all outgoing edges in the result, in CCW order
138
     */
139
    std::vector<DirectedEdge*> resultAreaEdgeList;
140
141
    Label label;
142
143
    bool resultAreaEdgesComputed;
144
145
    /// \brief
146
    /// Returned vector is owned by DirectedEdgeStar object, but
147
    /// lazily created
148
    const std::vector<DirectedEdge*>& getResultAreaEdges();
149
150
151
    /// States for linResultDirectedEdges
152
    enum {
153
        SCANNING_FOR_INCOMING = 1,
154
        LINKING_TO_OUTGOING
155
    };
156
157
    int computeDepths(EdgeEndStar::iterator startIt,
158
                      EdgeEndStar::iterator endIt, int startDepth);
159
};
160
161
162
} // namespace geos.geomgraph
163
} // namespace geos
164