00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GEOS_ALGORITHM_MINIMUMDIAMETER_H
00021 #define GEOS_ALGORITHM_MINIMUMDIAMETER_H
00022
00023 #include <geos/export.h>
00024
00025
00026 namespace geos {
00027 namespace geom {
00028 class Geometry;
00029 class LineSegment;
00030 class LineString;
00031 class Coordinate;
00032 class CoordinateSequence;
00033 }
00034 }
00035
00036
00037 namespace geos {
00038 namespace algorithm {
00039
00065 class GEOS_DLL MinimumDiameter {
00066 private:
00067 const geom::Geometry* inputGeom;
00068 bool isConvex;
00069
00070 geom::CoordinateSequence* convexHullPts;
00071
00072 geom::LineSegment* minBaseSeg;
00073 geom::Coordinate* minWidthPt;
00074 int minPtIndex;
00075 double minWidth;
00076 void computeMinimumDiameter();
00077 void computeWidthConvex(const geom::Geometry* geom);
00078
00086 void computeConvexRingMinDiameter(const geom::CoordinateSequence *pts);
00087
00088 unsigned int findMaxPerpDistance(const geom::CoordinateSequence* pts,
00089 geom::LineSegment* seg, unsigned int startIndex);
00090
00091 static unsigned int getNextIndex(const geom::CoordinateSequence* pts,
00092 unsigned int index);
00093
00094 static double computeC(double a, double b, const geom::Coordinate &p);
00095
00096 static geom::LineSegment computeSegmentForLine(double a, double b, double c);
00097
00098 public:
00099 ~MinimumDiameter();
00100
00106 MinimumDiameter(const geom::Geometry* newInputGeom);
00107
00117 MinimumDiameter(const geom::Geometry* newInputGeom,
00118 const bool newIsConvex);
00119
00125 double getLength();
00126
00132 geom::Coordinate* getWidthCoordinate();
00133
00139 geom::LineString* getSupportingSegment();
00140
00146 geom::LineString* getDiameter();
00147
00157 geom::Geometry* getMinimumRectangle();
00158
00165 static geom::Geometry* getMinimumRectangle(geom::Geometry* geom);
00166
00172 static geom::Geometry* getMinimumDiameter(geom::Geometry* geom);
00173
00174 };
00175
00176 }
00177 }
00178
00179 #endif // GEOS_ALGORITHM_MINIMUMDIAMETER_H
00180