GEOS
3.6.2
|
00001 /********************************************************************** 00002 * 00003 * GEOS - Geometry Engine Open Source 00004 * http://geos.osgeo.org 00005 * 00006 * Copyright (C) 2005-2006 Refractions Research Inc. 00007 * Copyright (C) 2001-2002 Vivid Solutions Inc. 00008 * 00009 * This is free software; you can redistribute and/or modify it under 00010 * the terms of the GNU Lesser General Public Licence as published 00011 * by the Free Software Foundation. 00012 * See the COPYING file for more information. 00013 * 00014 ********************************************************************** 00015 * 00016 * Last port: algorithm/MinimumDiameter.java r966 00017 * 00018 **********************************************************************/ 00019 00020 #ifndef GEOS_ALGORITHM_MINIMUMDIAMETER_H 00021 #define GEOS_ALGORITHM_MINIMUMDIAMETER_H 00022 00023 #include <geos/export.h> 00024 00025 // Forward declarations 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 { // geos::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 } // namespace geos::algorithm 00177 } // namespace geos 00178 00179 #endif // GEOS_ALGORITHM_MINIMUMDIAMETER_H 00180