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
28 class CoordinateSequence
;
34 namespace algorithm
{ // geos::algorithm
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.
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.
54 class GEOS_DLL MinimumDiameter
{
56 const geom::Geometry
* inputGeom
;
58 geom::LineSegment
* minBaseSeg
;
59 geom::Coordinate
* minWidthPt
;
62 void computeMinimumDiameter();
63 void computeWidthConvex(const geom::Geometry
* geom
);
66 * Compute the width information for a ring of {@link geom::Coordinate}s.
67 * Leaves the width information in the instance variables.
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
,
84 * Compute a minimum diameter for a giver {@link Geometry}.
86 * @param geom a Geometry
88 MinimumDiameter(const geom::Geometry
* newInputGeom
);
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
);
103 * Gets the length of the minimum diameter of the input Geometry
105 * @return the length of the minimum diameter
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();
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();
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
134 #endif // GEOS_ALGORITHM_MINIMUMDIAMETER_H
136 /**********************************************************************
138 * Revision 1.1 2006/03/09 16:46:48 strk
139 * geos::geom namespace definition, first pass at headers split
141 **********************************************************************/