File Coverage

/usr/local/lib/perl5/site_perl/5.26.1/x86_64-linux/XS/libgeos.x/i/geos/noding/IntersectionAdder.h
Criterion Covered Total %
statement 7 7 100.0
branch n/a
condition n/a
subroutine n/a
pod n/a
total 7 7 100.0


line stmt bran cond sub pod time code
1             /**********************************************************************
2             *
3             * GEOS - Geometry Engine Open Source
4             * http://geos.osgeo.org
5             *
6             * Copyright (C) 2006 Refractions Research Inc.
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/IntersectionAdder.java rev. 1.6 (JTS-1.9)
16             *
17             **********************************************************************/
18              
19             #ifndef GEOS_NODING_INTERSECTIONADDER_H
20             #define GEOS_NODING_INTERSECTIONADDER_H
21              
22             #include
23              
24             #include
25             #include
26             #include // for abs()
27              
28             #include
29              
30             #include
31             #include // for inheritance
32              
33             // Forward declarations
34             namespace geos {
35             namespace geom {
36             class Coordinate;
37             }
38             namespace noding {
39             class SegmentString;
40             }
41             namespace algorithm {
42             class LineIntersector;
43             }
44             }
45              
46             namespace geos {
47             namespace noding { // geos.noding
48              
49             /**
50             * Computes the intersections between two line segments in SegmentString
51             * and adds them to each string.
52             * The {@link SegmentIntersector} is passed to a {@link Noder}.
53             * The {@link addIntersections} method is called whenever the {@link Noder}
54             * detects that two SegmentStrings might intersect.
55             * This class is an example of the Strategy pattern.
56             *
57             */
58             class GEOS_DLL IntersectionAdder: public SegmentIntersector {
59              
60             private:
61              
62             /**
63             * These variables keep track of what types of intersections were
64             * found during ALL edges that have been intersected.
65             */
66             bool hasIntersectionVar;
67             bool hasProper;
68             bool hasProperInterior;
69             bool hasInterior;
70              
71             // the proper intersection point found
72             const geom::Coordinate* properIntersectionPoint;
73              
74             algorithm::LineIntersector& li;
75             bool isSelfIntersection;
76             //bool intersectionFound;
77              
78             /**
79             * A trivial intersection is an apparent self-intersection which
80             * in fact is simply the point shared by adjacent line segments.
81             * Note that closed edges require a special check for the point
82             * shared by the beginning and end segments.
83             */
84             bool isTrivialIntersection(const SegmentString* e0, int segIndex0,
85             const SegmentString* e1, int segIndex1);
86              
87             // Declare type as noncopyable
88             IntersectionAdder(const IntersectionAdder& other) = delete;
89             IntersectionAdder& operator=(const IntersectionAdder& rhs) = delete;
90              
91             public:
92              
93             int numIntersections;
94             int numInteriorIntersections;
95             int numProperIntersections;
96              
97             // testing only
98             int numTests;
99              
100 2           IntersectionAdder(algorithm::LineIntersector& newLi)
101             :
102             hasIntersectionVar(false),
103             hasProper(false),
104             hasProperInterior(false),
105             hasInterior(false),
106             properIntersectionPoint(nullptr),
107             li(newLi),
108             numIntersections(0),
109             numInteriorIntersections(0),
110             numProperIntersections(0),
111 2           numTests(0)
112 2           {}
113              
114             algorithm::LineIntersector& getLineIntersector() { return li; }
115              
116             /**
117             * @return the proper intersection point, or NULL
118             * if none was found
119             */
120             const geom::Coordinate* getProperIntersectionPoint() {
121             return properIntersectionPoint;
122             }
123              
124 2           bool hasIntersection() { return hasIntersectionVar; }
125              
126             /**
127             * A proper intersection is an intersection which is interior to
128             * at least two line segments. Note that a proper intersection
129             * is not necessarily in the interior of the entire Geometry,
130             * since another edge may have an endpoint equal to the intersection,
131             * which according to SFS semantics can result in the point being
132             * on the Boundary of the Geometry.
133             */
134 2           bool hasProperIntersection() { return hasProper; }
135              
136             /**
137             * A proper interior intersection is a proper intersection which is
138             * not contained in the set of boundary nodes set for this
139             * SegmentIntersector.
140             */
141 2           bool hasProperInteriorIntersection() { return hasProperInterior; }
142              
143             /**
144             * An interior intersection is an intersection which is
145             * in the interior of some segment.
146             */
147 2           bool hasInteriorIntersection() { return hasInterior; }
148              
149              
150             /**
151             * This method is called by clients
152             * of the {@link SegmentIntersector} class to process
153             * intersections for two segments of the SegmentStrings being
154             * intersected.
155             * Note that some clients (such as MonotoneChains) may optimize away
156             * this call for segment pairs which they have determined do not
157             * intersect (e.g. by an disjoint envelope test).
158             */
159             void processIntersections(
160             SegmentString* e0, int segIndex0,
161             SegmentString* e1, int segIndex1) override;
162              
163              
164             static bool isAdjacentSegments(int i1, int i2) {
165             return std::abs(i1 - i2) == 1;
166             }
167              
168             /**
169             * Always process all intersections
170             *
171             * @return false always
172             */
173             bool isDone() const override {
174             return false;
175             }
176             };
177              
178              
179             } // namespace geos.noding
180             } // namespace geos
181              
182             #endif // GEOS_NODING_INTERSECTIONADDER_H