- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# ConvexHull.h

    00001 /**********************************************************************
    00002  * $Id: ConvexHull.h 1820 2006-09-06 16:54:23Z mloskot $
    00003  *
    00004  * GEOS - Geometry Engine Open Source
    00005  * http://geos.refractions.net
    00006  *
    00007  * Copyright (C) 2005-2006 Refractions Research Inc.
    00008  * Copyright (C) 2001-2002 Vivid Solutions Inc.
    00009  *
    00010  * This is free software; you can redistribute and/or modify it under
    00011  * the terms of the GNU Lesser General Public Licence as published
    00012  * by the Free Software Foundation.
    00013  * See the COPYING file for more information.
    00014  *
    00015  **********************************************************************/
    00016
    00017 #ifndef GEOS_ALGORITHM_CONVEXHULL_H
    00018 #define GEOS_ALGORITHM_CONVEXHULL_H
    00019
    00020 #include <vector>
    00021
    00022 // FIXME: avoid using Cordinate:: typedefs to avoid full include
    00023 #include <geos/geom/Coordinate.h>
    00024
    00025 // Forward declarations
    00026 namespace geos {
    00027         namespace geom {
    00028                 class Geometry;
    00029                 class GeometryFactory;
    00030                 class CoordinateSequence;
    00031         }
    00032 }
    00033
    00034 namespace geos {
    00035 namespace algorithm { // geos::algorithm
    00036
    00048 class ConvexHull {
    00049 private:
    00050         const geom::GeometryFactory *geomFactory;
    00051         geom::Coordinate::ConstVect inputPts;
    00052
    00053         void extractCoordinates(const geom::Geometry *geom);
    00054
    00059         geom::CoordinateSequence *toCoordinateSequence(geom::Coordinate::ConstVect &cv);
    00060
    00061         void computeOctPts(const geom::Coordinate::ConstVect &src,
    00062                         geom::Coordinate::ConstVect &tgt);
    00063
    00064         bool computeOctRing(const geom::Coordinate::ConstVect &src,
    00065                         geom::Coordinate::ConstVect &tgt);
    00066
    00089         void reduce(geom::Coordinate::ConstVect &pts);
    00090
    00091
    00093         void preSort(geom::Coordinate::ConstVect &pts);
    00094
    00112         int polarCompare(const geom::Coordinate &o,
    00113                         const geom::Coordinate &p, const geom::Coordinate &q);
    00114
    00115         void grahamScan(const geom::Coordinate::ConstVect &c,
    00116                         geom::Coordinate::ConstVect &ps);
    00117
    00127         geom::Geometry* lineOrPolygon(const geom::Coordinate::ConstVect &vertices);
    00128
    00133         void cleanRing(const geom::Coordinate::ConstVect &input,
    00134                         geom::Coordinate::ConstVect &cleaned);
    00135
    00140         bool isBetween(const geom::Coordinate& c1, const geom::Coordinate& c2, const geom::Coordinate& c3);
    00141
    00142 public:
    00143
    00147         ConvexHull(const geom::Geometry *newGeometry);
    00148
    00149
    00150         ~ConvexHull();
    00151
    00164         geom::Geometry* getConvexHull();
    00165 };
    00166
    00167 } // namespace geos::algorithm
    00168 } // namespace geos
    00169
    00170 #ifdef GEOS_INLINE
    00171 # include "geos/algorithm/ConvexHull.inl"
    00172 #endif
    00173
    00174 #endif // GEOS_ALGORITHM_CONVEXHULL_H
    00175
    00176 /**********************************************************************
    00177  * $Log$
    00178  * Revision 1.2  2006/03/24 09:52:41  strk
    00179  * USE_INLINE => GEOS_INLINE
    00180  *
    00181  * Revision 1.1  2006/03/09 16:46:48  strk
    00182  * geos::geom namespace definition, first pass at headers split
    00183  *
    00184  **********************************************************************/
    00185