GEOS 3.3.4

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

- File List

CentroidArea.h
1 /**********************************************************************
2 * $Id: CentroidArea.h 2556 2009-06-06 22:22:28Z strk $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
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 #ifndef GEOS_ALGORITHM_CENTROIDAREA_H
18 #define GEOS_ALGORITHM_CENTROIDAREA_H
19
20
21 #include <geos/export.h>
22 #include <geos/geom/Coordinate.h>
23
24 // Forward declarations
25 namespace geos {
26 namespace geom {
27 class CoordinateSequence;
28 class Geometry;
29 class Polygon;
30 }
31 }
32
33 namespace geos {
34 namespace algorithm { // geos::algorithm
35
50 class GEOS_DLL CentroidArea {
51
52 public:
53
54 CentroidArea()
55 :
56 basePt(0.0, 0.0),
57 areasum2(0)
58 {}
59
60 ~CentroidArea() {}
61
68 void add(const geom::Geometry *geom);
69
76 void add(const geom::CoordinateSequence *ring);
77
78 geom::Coordinate* getCentroid() const;
79
81 bool getCentroid(geom::Coordinate& ret) const;
82
83 private:
84
86 geom::Coordinate basePt;
87
88 // temporary variable to hold centroid of triangle
89 geom::Coordinate triangleCent3;
90
92 double areasum2;
93
95 geom::Coordinate cg3;
96
97 void setBasePoint(const geom::Coordinate &newbasePt);
98
99 void add(const geom::Polygon *poly);
100
101 void addShell(const geom::CoordinateSequence *pts);
102
103 void addHole(const geom::CoordinateSequence *pts);
104
105 void addTriangle(const geom::Coordinate &p0, const geom::Coordinate &p1,
106 const geom::Coordinate &p2,bool isPositiveArea);
107
108 static void centroid3(const geom::Coordinate &p1, const geom::Coordinate &p2,
109 const geom::Coordinate &p3, geom::Coordinate &c);
110
111 static double area2(const geom::Coordinate &p1, const geom::Coordinate &p2,
112 const geom::Coordinate &p3);
113
114 };
115
116 } // namespace geos::algorithm
117 } // namespace geos
118
119
120 #endif // GEOS_ALGORITHM_CENTROIDAREA_H
121
122 /**********************************************************************
123 * $Log$
124 * Revision 1.1 2006/03/09 16:46:48 strk
125 * geos::geom namespace definition, first pass at headers split
126 *
127 **********************************************************************/
128