GEOS 3.15.0dev
ExactMaxInscribedCircle.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (c) 2020 Martin Davis
7 * Copyright (C) 2020 Paul Ramsey <pramsey@cleverelephant.ca>
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 **********************************************************************
15 *
16 * Last port: algorithm/construct/ExactMaxInscribedCircle.java
17 * https://github.com/locationtech/jts/commit/8d5ced1b784d232e1eecf5df4b71873e8822336a
18 *
19 **********************************************************************/
20
21#pragma once
22
23#include <geos/geom/Coordinate.h>
24#include <geos/geom/LineSegment.h>
25
26#include <array>
27// #include <queue>
28
29
30
31namespace geos {
32namespace geom {
33class CoordinateSequence;
34class Geometry;
35class Polygon;
36}
37}
38
39namespace geos {
40namespace algorithm { // geos::algorithm
41namespace construct { // geos::algorithm::construct
42
54
56 using CoordinateXY = geos::geom::CoordinateXY;
59
60public:
61
63
71 static bool isSupported(const geom::Geometry* geom);
72
73 static std::pair<CoordinateXY, CoordinateXY> computeRadius(const Polygon* polygon);
74
75
76private:
77
78 static bool isTriangle(const Polygon* polygon);
79
80 static bool isQuadrilateral(const Polygon* polygon);
81
82 static std::pair<CoordinateXY, CoordinateXY> computeTriangle(const CoordinateSequence* ring);
83
95 static std::pair<CoordinateXY, CoordinateXY> computeConvexQuadrilateral(const CoordinateSequence* ring);
96
97 static std::array<LineSegment, 4> computeBisectors(const CoordinateSequence* ptsCW,
98 double diameter);
99
100 static CoordinateXY nearestEdgePt(const CoordinateSequence* ring,
101 const CoordinateXY& pt);
102
103 static LineSegment computeConvexBisector(const CoordinateSequence* pts,
104 std::size_t index, double len);
105
106 static bool isConvex(const Polygon* polygon);
107
108 static bool isConvex(const CoordinateSequence* ring);
109
110 static bool isConcave(const CoordinateXY& p0,
111 const CoordinateXY& p1,
112 const CoordinateXY& p2);
113
114 static bool isPointInConvexRing(const CoordinateSequence* ringCW,
115 const CoordinateXY& p);
116
117};
118
119
120} // geos::algorithm::construct
121} // geos::algorithm
122} // geos
Definition ExactMaxInscribedCircle.h:53
static bool isSupported(const geom::Geometry *geom)
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
Definition LineSegment.h:61
Represents a linear polygon, which may include holes.
Definition Polygon.h:61
Basic namespace for all GEOS functionalities.
Definition geos.h:38