GEOS  3.8.0dev
MinimumDiameter.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2005-2006 Refractions Research Inc.
7  * Copyright (C) 2001-2002 Vivid Solutions Inc.
8  *
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.
13  *
14  **********************************************************************
15  *
16  * Last port: algorithm/MinimumDiameter.java r966
17  *
18  **********************************************************************/
19 
20 #ifndef GEOS_ALGORITHM_MINIMUMDIAMETER_H
21 #define GEOS_ALGORITHM_MINIMUMDIAMETER_H
22 
23 #include <geos/export.h>
24 
25 // Forward declarations
26 namespace geos {
27 namespace geom {
28 class Geometry;
29 class LineSegment;
30 class LineString;
31 class Coordinate;
32 class CoordinateSequence;
33 }
34 }
35 
36 
37 namespace geos {
38 namespace algorithm { // geos::algorithm
39 
65 class GEOS_DLL MinimumDiameter {
66 private:
67  const geom::Geometry* inputGeom;
68  bool isConvex;
69 
70  geom::CoordinateSequence* convexHullPts;
71 
72  geom::LineSegment* minBaseSeg;
73  geom::Coordinate* minWidthPt;
74  int minPtIndex;
75  double minWidth;
76  void computeMinimumDiameter();
77  void computeWidthConvex(const geom::Geometry* geom);
78 
86  void computeConvexRingMinDiameter(const geom::CoordinateSequence* pts);
87 
88  unsigned int findMaxPerpDistance(const geom::CoordinateSequence* pts,
89  geom::LineSegment* seg, unsigned int startIndex);
90 
91  static unsigned int getNextIndex(const geom::CoordinateSequence* pts,
92  unsigned int index);
93 
94  static double computeC(double a, double b, const geom::Coordinate& p);
95 
96  static geom::LineSegment computeSegmentForLine(double a, double b, double c);
97 
98 public:
99  ~MinimumDiameter();
100 
106  MinimumDiameter(const geom::Geometry* newInputGeom);
107 
117  MinimumDiameter(const geom::Geometry* newInputGeom,
118  const bool newIsConvex);
119 
125  double getLength();
126 
132  geom::Coordinate* getWidthCoordinate();
133 
139  geom::LineString* getSupportingSegment();
140 
146  geom::LineString* getDiameter();
147 
157  geom::Geometry* getMinimumRectangle();
158 
165  static geom::Geometry* getMinimumRectangle(geom::Geometry* geom);
166 
172  static geom::Geometry* getMinimumDiameter(geom::Geometry* geom);
173 
174 };
175 
176 } // namespace geos::algorithm
177 } // namespace geos
178 
179 #endif // GEOS_ALGORITHM_MINIMUMDIAMETER_H
180 
Definition: LineSegment.h:57
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:187
Definition: LineString.h:69
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Computes the minimum diameter of a geom::Geometry.
Definition: MinimumDiameter.h:65
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58