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 <memory>
24 #include <geos/export.h>
25 
26 // Forward declarations
27 namespace geos {
28 namespace geom {
29 class Geometry;
30 class LineSegment;
31 class LineString;
32 class Coordinate;
33 class CoordinateSequence;
34 }
35 }
36 
37 
38 namespace geos {
39 namespace algorithm { // geos::algorithm
40 
62 class GEOS_DLL MinimumDiameter {
63 private:
64  const geom::Geometry* inputGeom;
65  bool isConvex;
66 
67  std::unique_ptr<geom::CoordinateSequence> convexHullPts;
68 
69  geom::LineSegment* minBaseSeg;
70  geom::Coordinate* minWidthPt;
71  int minPtIndex;
72  double minWidth;
73  void computeMinimumDiameter();
74  void computeWidthConvex(const geom::Geometry* geom);
75 
83  void computeConvexRingMinDiameter(const geom::CoordinateSequence* pts);
84 
85  unsigned int findMaxPerpDistance(const geom::CoordinateSequence* pts,
86  geom::LineSegment* seg, unsigned int startIndex);
87 
88  static unsigned int getNextIndex(const geom::CoordinateSequence* pts,
89  unsigned int index);
90 
91  static double computeC(double a, double b, const geom::Coordinate& p);
92 
93  static geom::LineSegment computeSegmentForLine(double a, double b, double c);
94 
95 public:
96  ~MinimumDiameter();
97 
103  MinimumDiameter(const geom::Geometry* newInputGeom);
104 
114  MinimumDiameter(const geom::Geometry* newInputGeom,
115  const bool newIsConvex);
116 
122  double getLength();
123 
129  geom::Coordinate* getWidthCoordinate();
130 
136  geom::LineString* getSupportingSegment();
137 
143  geom::LineString* getDiameter();
144 
156  geom::Geometry* getMinimumRectangle();
157 
164  static geom::Geometry* getMinimumRectangle(geom::Geometry* geom);
165 
171  static geom::Geometry* getMinimumDiameter(geom::Geometry* geom);
172 
173 };
174 
175 } // namespace geos::algorithm
176 } // namespace geos
177 
178 #endif // GEOS_ALGORITHM_MINIMUMDIAMETER_H
179 
Definition: LineSegment.h:59
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:188
Definition: LineString.h:68
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Computes the minimum diameter of a geom::Geometry.
Definition: MinimumDiameter.h:62
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58