GEOS 3.15.0dev
CircularArcIntersector.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2024 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/geom/Coordinate.h>
22#include <geos/geom/CircularArc.h>
23#include <geos/geom/LineSegment.h>
24
25namespace geos::algorithm {
26
27class GEOS_DLL CircularArcIntersector {
28public:
29 using CoordinateXY = geom::CoordinateXY;
30 using CircularArc = geom::CircularArc;
31 using Envelope = geom::Envelope;
32
33 enum intersection_type : uint8_t {
34 NO_INTERSECTION = 0,
35 ONE_POINT_INTERSECTION = 1,
36 TWO_POINT_INTERSECTION = 2,
37 COCIRCULAR_INTERSECTION = 3,
38 };
39
40 intersection_type getResult() const
41 {
42 return result;
43 }
44
45 const CoordinateXY& getPoint(std::uint8_t i) const
46 {
47 return intPt[i];
48 }
49
50 const CircularArc& getArc(std::uint8_t i) const
51 {
52 return intArc[i];
53 }
54
55 std::uint8_t getNumPoints() const
56 {
57 return nPt;
58 }
59
60 std::uint8_t getNumArcs() const
61 {
62 return nArc;
63 }
64
69 void intersects(const CircularArc& arc, const CoordinateXY& p0, const CoordinateXY& p1);
70
71 void intersects(const CircularArc& arc, const geom::LineSegment& seg)
72 {
73 intersects(arc, seg.p0, seg.p1);
74 }
75
80 void intersects(const CircularArc& arc1, const CircularArc& arc2);
81
82 static int
83 circleIntersects(const CoordinateXY& center, double r, const CoordinateXY& p0, const CoordinateXY& p1, CoordinateXY& isect0, CoordinateXY& isect1);
84
85private:
86
87 void intersects(const CoordinateXY& p0, const CoordinateXY& p1, const CoordinateXY& q0, const CoordinateXY& q1);
88
89 std::array<CoordinateXY, 2> intPt;
90 std::array<CircularArc, 2> intArc;
91 intersection_type result = NO_INTERSECTION;
92 std::uint8_t nPt = 0;
93 std::uint8_t nArc = 0;
94
95};
96
97}
Contains classes and interfaces implementing fundamental computational geometry algorithms.
Definition Angle.h:32