ConvexHull.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
* Copyright (C) 2005-2006 Refractions Research Inc.
* Copyright (C) 2001-2002 Vivid Solutions Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: algorithm/ConvexHull.java r407 (JTS-1.12+)
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <memory>
#include <vector>
#include <cassert>
// FIXME: avoid using Coordinate:: typedefs to avoid full include
#include <geos/algorithm/ConvexHull.h>
#include <geos/geom/Coordinate.h>
#include <geos/geom/CoordinateSequence.h>
#include <geos/geom/Geometry.h>
#include <geos/util/UniqueCoordinateArrayFilter.h>
#include <geos/util/CoordinateArrayFilter.h>
#include "geos/util.h"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
#endif
// Forward declarations
namespace geos {
namespace geom {
class GeometryFactory;
}
}
namespace geos {
namespace algorithm { // geos::algorithm
class GEOS_DLL ConvexHull {
private:
static constexpr std::size_t TUNING_REDUCE_SIZE = 50;
const geom::Geometry* inputGeom;
const geom::GeometryFactory* geomFactory;
geom::Coordinate::ConstVect inputPts;
std::unique_ptr<geom::CoordinateSequence> toCoordinateSequence(geom::Coordinate::ConstVect& cv);
void computeInnerOctolateralPts(
const geom::Coordinate::ConstVect& src,
geom::Coordinate::ConstVect& tgt);
bool computeInnerOctolateralRing(
const geom::Coordinate::ConstVect& src,
geom::Coordinate::ConstVect& tgt);
void reduce(geom::Coordinate::ConstVect& pts);
void padArray3(geom::Coordinate::ConstVect& pts);
void preSort(geom::Coordinate::ConstVect& pts);
int polarCompare(const geom::Coordinate& o,
const geom::Coordinate& p,
const geom::Coordinate& q);
void grahamScan(const geom::Coordinate::ConstVect& c,
geom::Coordinate::ConstVect& ps);
std::unique_ptr<geom::Geometry> lineOrPolygon(const geom::Coordinate::ConstVect& vertices);
void cleanRing(const geom::Coordinate::ConstVect& input,
geom::Coordinate::ConstVect& cleaned);
bool isBetween(
const geom::Coordinate& c1,
const geom::Coordinate& c2,
const geom::Coordinate& c3);
bool extractUnique(geom::Coordinate::ConstVect& pts, std::size_t maxPts);
std::unique_ptr<geom::Geometry> createFewPointsResult();
public:
ConvexHull(const geom::Geometry* newGeometry)
: inputGeom(newGeometry)
, geomFactory(newGeometry->getFactory())
{
util::ensureNoCurvedComponents(inputGeom);
};
~ConvexHull() {};
std::unique_ptr<geom::Geometry> getConvexHull();
};
} // namespace geos::algorithm
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif
geos::algorithm::ConvexHull
Computes the convex hull of a Geometry.
Definition ConvexHull.h:64
geos::algorithm::ConvexHull::getConvexHull
std::unique_ptr< geom::Geometry > getConvexHull()
geos::algorithm::ConvexHull::ConvexHull
ConvexHull(const geom::Geometry *newGeometry)
Definition ConvexHull.h:180
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::geom::Coordinate::ConstVect
std::vector< const Coordinate * > ConstVect
A vector of const Coordinate pointers.
Definition Coordinate.h:229
geos::geom::GeometryFactory
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
geos::algorithm
Contains classes and interfaces implementing fundamental computational geometry algorithms.
Definition Angle.h:32
geos::geom
Definition Angle.h:26
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38