00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef GEOS_ALGORITHM_CONVEXHULL_H
00018 #define GEOS_ALGORITHM_CONVEXHULL_H
00019
00020 #include <geos/export.h>
00021 #include <vector>
00022
00023
00024 #include <geos/geom/Coordinate.h>
00025
00026
00027 namespace geos {
00028 namespace geom {
00029 class Geometry;
00030 class GeometryFactory;
00031 class CoordinateSequence;
00032 }
00033 }
00034
00035 namespace geos {
00036 namespace algorithm {
00037
00049 class GEOS_DLL ConvexHull {
00050 private:
00051 const geom::GeometryFactory *geomFactory;
00052 geom::Coordinate::ConstVect inputPts;
00053
00054 void extractCoordinates(const geom::Geometry *geom);
00055
00060 geom::CoordinateSequence *toCoordinateSequence(geom::Coordinate::ConstVect &cv);
00061
00062 void computeOctPts(const geom::Coordinate::ConstVect &src,
00063 geom::Coordinate::ConstVect &tgt);
00064
00065 bool computeOctRing(const geom::Coordinate::ConstVect &src,
00066 geom::Coordinate::ConstVect &tgt);
00067
00090 void reduce(geom::Coordinate::ConstVect &pts);
00091
00092
00094 void preSort(geom::Coordinate::ConstVect &pts);
00095
00113 int polarCompare(const geom::Coordinate &o,
00114 const geom::Coordinate &p, const geom::Coordinate &q);
00115
00116 void grahamScan(const geom::Coordinate::ConstVect &c,
00117 geom::Coordinate::ConstVect &ps);
00118
00128 geom::Geometry* lineOrPolygon(const geom::Coordinate::ConstVect &vertices);
00129
00134 void cleanRing(const geom::Coordinate::ConstVect &input,
00135 geom::Coordinate::ConstVect &cleaned);
00136
00141 bool isBetween(const geom::Coordinate& c1, const geom::Coordinate& c2, const geom::Coordinate& c3);
00142
00143 public:
00144
00148 ConvexHull(const geom::Geometry *newGeometry);
00149
00150
00151 ~ConvexHull();
00152
00165 geom::Geometry* getConvexHull();
00166 };
00167
00168 }
00169 }
00170
00171 #ifdef GEOS_INLINE
00172 # include "geos/algorithm/ConvexHull.inl"
00173 #endif
00174
00175 #endif // GEOS_ALGORITHM_CONVEXHULL_H
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186