GEOS 3.15.0dev
CircularArcIntersector.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2024-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 <array>
18#include <cstdint>
19
20#include <geos/export.h>
21#include <geos/algorithm/LineIntersector.h>
22#include <geos/geom/Coordinate.h>
23#include <geos/geom/CircularArc.h>
24
25namespace geos::algorithm {
26
27class GEOS_DLL CircularArcIntersector {
28public:
29 using CoordinateXY = geom::CoordinateXY;
30 using CoordinateXYZM = geom::CoordinateXYZM;
31 using CircularArc = geom::CircularArc;
32 using Envelope = geom::Envelope;
33
34 enum intersection_type : uint8_t {
35 NO_INTERSECTION = 0,
36 ONE_POINT_INTERSECTION = 1,
37 TWO_POINT_INTERSECTION = 2,
38 COCIRCULAR_INTERSECTION = 3,
39 };
40
41 explicit CircularArcIntersector(const geom::PrecisionModel* pm = nullptr)
42 : precisionModel(pm)
43 {}
44
45 intersection_type getResult() const
46 {
47 return result;
48 }
49
50 const CoordinateXYZM& getPoint(std::uint8_t i) const
51 {
52 return intPt[i];
53 }
54
55 const CircularArc& getArc(std::uint8_t i) const
56 {
57 return intArc[i];
58 }
59
60 std::uint8_t getNumPoints() const
61 {
62 return nPt;
63 }
64
65 std::uint8_t getNumArcs() const
66 {
67 return nArc;
68 }
69
81 void intersects(const CircularArc& arc, const geom::CoordinateSequence& seq, std::size_t pos0, std::size_t pos1, bool useSegEndpoints);
82
88 void intersects(const CircularArc& arc1, const CircularArc& arc2);
89
95 void intersects(const geom::CoordinateSequence& p, std::size_t p0, std::size_t p1,
96 const geom::CoordinateSequence& q, std::size_t q0, std::size_t q1);
97
98private:
99 void reset() {
100 nPt = 0;
101 nArc = 0;
102 }
103
110 void addCocircularIntersection(double startAngle, double endAngle, int orientation, const CircularArc& arc1, const CircularArc& arc2);
111
120 void addArcArcIntersectionPoint(const CoordinateXY& computedIntPt, const CircularArc& arc1, const CircularArc& arc2);
121
130 void addArcSegmentIntersectionPoint(const CoordinateXY& computedIntPt, const CircularArc& lhs,
131 const geom::CoordinateSequence& seq, std::size_t pos0, std::size_t pos1, bool useSegEndpoints);
132
143 static int
144 circleIntersects(const CoordinateXY& center, double r, const CoordinateXY& p0, const CoordinateXY& p1, CoordinateXY& isect0, CoordinateXY& isect1);
145
146 void computeCocircularIntersection(const CircularArc& arc1, const CircularArc& arc2);
147
149 bool hasIntersection(const geom::CoordinateXY& p) const;
150
151 std::array<CoordinateXYZM, 2> intPt;
152 std::array<CircularArc, 2> intArc;
153 const geom::PrecisionModel* precisionModel;
154 intersection_type result = NO_INTERSECTION;
155 std::uint8_t nPt = 0;
156 std::uint8_t nArc = 0;
157};
158
159}
Contains classes and interfaces implementing fundamental computational geometry algorithms.
Definition Angle.h:32