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

- File List

# CentroidArea.h

    00001 /**********************************************************************
    00002  * $Id: CentroidArea.h 2556 2009-06-06 22:22:28Z strk $
    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_CENTROIDAREA_H
    00018 #define GEOS_ALGORITHM_CENTROIDAREA_H
    00019
    00020
    00021 #include <geos/export.h>
    00022 #include <geos/geom/Coordinate.h>
    00023
    00024 // Forward declarations
    00025 namespace geos {
    00026         namespace geom {
    00027                 class CoordinateSequence;
    00028                 class Geometry;
    00029                 class Polygon;
    00030         }
    00031 }
    00032
    00033 namespace geos {
    00034 namespace algorithm { // geos::algorithm
    00035
    00050 class GEOS_DLL CentroidArea {
    00051
    00052 public:
    00053
    00054         CentroidArea()
    00055                 :
    00056                 basePt(0.0, 0.0),
    00057                 areasum2(0)
    00058         {}
    00059
    00060         ~CentroidArea() {}
    00061
    00068         void add(const geom::Geometry *geom);
    00069
    00076         void add(const geom::CoordinateSequence *ring);
    00077
    00078         geom::Coordinate* getCentroid() const;
    00079
    00081         bool getCentroid(geom::Coordinate& ret) const;
    00082
    00083 private:
    00084
    00086         geom::Coordinate basePt;
    00087
    00088         // temporary variable to hold centroid of triangle
    00089         geom::Coordinate triangleCent3;
    00090
    00092         double areasum2;
    00093
    00095         geom::Coordinate cg3;
    00096
    00097         void setBasePoint(const geom::Coordinate &newbasePt);
    00098
    00099         void add(const geom::Polygon *poly);
    00100
    00101         void addShell(const geom::CoordinateSequence *pts);
    00102
    00103         void addHole(const geom::CoordinateSequence *pts);
    00104
    00105         void addTriangle(const geom::Coordinate &p0, const geom::Coordinate &p1,
    00106                         const geom::Coordinate &p2,bool isPositiveArea);
    00107
    00108         static void centroid3(const geom::Coordinate &p1, const geom::Coordinate &p2,
    00109                         const geom::Coordinate &p3, geom::Coordinate &c);
    00110
    00111         static double area2(const geom::Coordinate &p1, const geom::Coordinate &p2,
    00112                         const geom::Coordinate &p3);
    00113
    00114 };
    00115
    00116 } // namespace geos::algorithm
    00117 } // namespace geos
    00118
    00119
    00120 #endif // GEOS_ALGORITHM_CENTROIDAREA_H
    00121
    00122 /**********************************************************************
    00123  * $Log$
    00124  * Revision 1.1  2006/03/09 16:46:48  strk
    00125  * geos::geom namespace definition, first pass at headers split
    00126  *
    00127  **********************************************************************/
    00128