Complete Note#1 in the http://wiki.osgeo.org/wiki/GEOS_Provenance_Review to get out...
[geos.git] / include / geos / algorithm / MinimumDiameter.h
blobac82cdd7b87648dace10e8be7c45f20f8c13f51c
1 /**********************************************************************
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
6 * Copyright (C) 2005-2006 Refractions Research Inc.
7 * Copyright (C) 2001-2002 Vivid Solutions Inc.
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
14 **********************************************************************/
16 #ifndef GEOS_ALGORITHM_MINIMUMDIAMETER_H
17 #define GEOS_ALGORITHM_MINIMUMDIAMETER_H
19 #include <geos/export.h>
21 // Forward declarations
22 namespace geos {
23 namespace geom {
24 class Geometry;
25 class LineSegment;
26 class LineString;
27 class Coordinate;
28 class CoordinateSequence;
33 namespace geos {
34 namespace algorithm { // geos::algorithm
36 /** \brief
37 * Computes the minimum diameter of a geom::Geometry
39 * The minimum diameter is defined to be the
40 * width of the smallest band that
41 * contains the geometry,
42 * where a band is a strip of the plane defined
43 * by two parallel lines.
44 * This can be thought of as the smallest hole that the geometry can be
45 * moved through, with a single rotation.
46 * <p>
47 * The first step in the algorithm is computing the convex hull of the Geometry.
48 * If the input Geometry is known to be convex, a hint can be supplied to
49 * avoid this computation.
51 * @see ConvexHull
54 class GEOS_DLL MinimumDiameter {
55 private:
56 const geom::Geometry* inputGeom;
57 bool isConvex;
58 geom::LineSegment* minBaseSeg;
59 geom::Coordinate* minWidthPt;
60 int minPtIndex;
61 double minWidth;
62 void computeMinimumDiameter();
63 void computeWidthConvex(const geom::Geometry* geom);
65 /**
66 * Compute the width information for a ring of {@link geom::Coordinate}s.
67 * Leaves the width information in the instance variables.
69 * @param pts
70 * @return
72 void computeConvexRingMinDiameter(const geom::CoordinateSequence *pts);
74 unsigned int findMaxPerpDistance(const geom::CoordinateSequence* pts,
75 geom::LineSegment* seg, unsigned int startIndex);
77 static unsigned int getNextIndex(const geom::CoordinateSequence* pts,
78 unsigned int index);
80 public:
81 ~MinimumDiameter();
83 /** \brief
84 * Compute a minimum diameter for a giver {@link Geometry}.
86 * @param geom a Geometry
88 MinimumDiameter(const geom::Geometry* newInputGeom);
90 /** \brief
91 * Compute a minimum diameter for a given Geometry,
92 * with a hint if the Geometry is convex
93 * (e.g. a convex Polygon or LinearRing,
94 * or a two-point LineString, or a Point).
96 * @param geom a Geometry which is convex
97 * @param isConvex <code>true</code> if the input geometry is convex
99 MinimumDiameter(const geom::Geometry* newInputGeom,
100 const bool newIsConvex);
102 /** \brief
103 * Gets the length of the minimum diameter of the input Geometry
105 * @return the length of the minimum diameter
107 double getLength();
109 /** \brief
110 * Gets the {@link geom::Coordinate} forming one end of the minimum diameter
112 * @return a coordinate forming one end of the minimum diameter
114 geom::Coordinate* getWidthCoordinate();
116 /** \brief
117 * Gets the segment forming the base of the minimum diameter
119 * @return the segment forming the base of the minimum diameter
121 geom::LineString* getSupportingSegment();
123 /** \brief
124 * Gets a LineString which is a minimum diameter
126 * @return a LineString which is a minimum diameter
128 geom::LineString* getDiameter();
131 } // namespace geos::algorithm
132 } // namespace geos
134 #endif // GEOS_ALGORITHM_MINIMUMDIAMETER_H
136 /**********************************************************************
137 * $Log$
138 * Revision 1.1 2006/03/09 16:46:48 strk
139 * geos::geom namespace definition, first pass at headers split
141 **********************************************************************/