GEOS 3.9.1
ConvexHull.h
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: algorithm/ConvexHull.java r407 (JTS-1.12+)
18 *
19 **********************************************************************/
20
21#ifndef GEOS_ALGORITHM_CONVEXHULL_H
22#define GEOS_ALGORITHM_CONVEXHULL_H
23
24#include <geos/export.h>
25#include <memory>
26#include <vector>
27
28// FIXME: avoid using Cordinate:: typedefs to avoid full include
29#include <geos/geom/Coordinate.h>
30#include <geos/geom/CoordinateSequence.h>
31
32#ifdef _MSC_VER
33#pragma warning(push)
34#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
35#endif
36
37// Forward declarations
38namespace geos {
39namespace geom {
40class Geometry;
41class GeometryFactory;
42}
43}
44
45namespace geos {
46namespace algorithm { // geos::algorithm
47
59class GEOS_DLL ConvexHull {
60private:
61 const geom::GeometryFactory* geomFactory;
63
64 void extractCoordinates(const geom::Geometry* geom);
65
70 std::unique_ptr<geom::CoordinateSequence> toCoordinateSequence(geom::Coordinate::ConstVect& cv);
71
72 void computeOctPts(const geom::Coordinate::ConstVect& src,
74
75 bool computeOctRing(const geom::Coordinate::ConstVect& src,
77
102 void reduce(geom::Coordinate::ConstVect& pts);
103
105 void padArray3(geom::Coordinate::ConstVect& pts);
106
108 void preSort(geom::Coordinate::ConstVect& pts);
109
127 int polarCompare(const geom::Coordinate& o,
128 const geom::Coordinate& p, const geom::Coordinate& q);
129
130 void grahamScan(const geom::Coordinate::ConstVect& c,
132
142 std::unique_ptr<geom::Geometry> lineOrPolygon(const geom::Coordinate::ConstVect& vertices);
143
148 void cleanRing(const geom::Coordinate::ConstVect& input,
150
155 bool isBetween(const geom::Coordinate& c1, const geom::Coordinate& c2, const geom::Coordinate& c3);
156
157public:
158
162 ConvexHull(const geom::Geometry* newGeometry);
163
164
165 ~ConvexHull();
166
179 std::unique_ptr<geom::Geometry> getConvexHull();
180};
181
182} // namespace geos::algorithm
183} // namespace geos
184
185#ifdef _MSC_VER
186#pragma warning(pop)
187#endif
188
189#ifdef GEOS_INLINE
190# include "geos/algorithm/ConvexHull.inl"
191#endif
192
193#endif // GEOS_ALGORITHM_CONVEXHULL_H
Computes the convex hull of a Geometry.
Definition ConvexHull.h:59
std::unique_ptr< geom::Geometry > getConvexHull()
ConvexHull(const geom::Geometry *newGeometry)
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:60
std::vector< const Coordinate * > ConstVect
A vector of const Coordinate pointers.
Definition Coordinate.h:71
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:68
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:188
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:26