GEOS  3.13.0dev
HullTri.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2021 Paul Ramsey <pramsey@cleverelephant.ca>
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU Lesser General Public Licence as published
10  * by the Free Software Foundation.
11  * See the COPYING file for more information.
12  *
13  **********************************************************************/
14 
15 #pragma once
16 
17 #include <geos/geom/Triangle.h>
18 #include <geos/triangulate/tri/Tri.h>
19 #include <geos/triangulate/tri/TriList.h>
20 #include <geos/triangulate/quadedge/TriangleVisitor.h>
21 
22 #include <queue>
23 #include <deque>
24 
25 
26 namespace geos {
27 namespace geom {
28 class Coordinate;
29 }
30 namespace triangulate {
31 namespace quadedge {
32 }
33 }
34 }
35 
40 
41 namespace geos {
42 namespace algorithm { // geos::algorithm
43 namespace hull { // geos::algorithm::hull
44 
45 
46 
47 class HullTri : public Tri
48 {
49  private:
50 
51  double m_size;
52  bool m_isMarked = false;
53 
54  bool isBoundaryTouch(TriIndex index) const;
55 
56 
57  public:
58 
59  HullTri(const Coordinate& c0, const Coordinate& c1, const Coordinate& c2)
60  : Tri(c0, c1, c2)
61  , m_size(Triangle::longestSideLength(c0, c1, c2))
62  {};
63 
64  class HullTriCompare {
65  public:
66  HullTriCompare() {};
67  bool operator()(const HullTri* a, const HullTri* b)
68  {
69  if (a->getSize() == b->getSize())
70  return a->getArea() < b->getArea();
71  else
72  return a->getSize() < b->getSize();
73  }
74  };
75 
76 
77  double getSize() const;
78 
84  void setSizeToBoundary();
85 
86  void setSizeToLongestEdge();
87  void setSizeToCircumradius();
88 
89 
90  bool isMarked() const;
91  void setMarked(bool marked);
92  bool isRemoved();
93  TriIndex boundaryIndex() const;
94  TriIndex boundaryIndexCCW() const;
95  TriIndex boundaryIndexCW() const;
96 
104  bool isConnecting() const;
105 
111  int adjacent2VertexIndex() const;
112 
121  TriIndex isolatedVertexIndex(TriList<HullTri>& triList) const;
122 
123  double lengthOfLongestEdge() const;
124 
131  bool hasBoundaryTouch() const;
132 
133  static HullTri* findTri(TriList<HullTri>& triList, Tri* exceptTri);
134  static bool isAllMarked(TriList<HullTri>& triList);
135  static void clearMarks(TriList<HullTri>& triList);
136  static void markConnected(HullTri* triStart, HullTri* exceptTri);
137  static bool isConnected(TriList<HullTri>& triList, HullTri* exceptTri);
138 
139  friend std::ostream& operator<<(std::ostream& os, const HullTri& ht);
140 
141  double lengthOfBoundary() const;
142 
143  void remove(TriList<HullTri>& triList);
144 
145 
146 }; // HullTri
147 
148 
149 
150 
151 
152 
153 } // geos::algorithm::hull
154 } // geos::algorithm
155 } // geos
156 
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:216
Represents a planar triangle, and provides methods for calculating various properties of triangles.
Definition: Triangle.h:28
Definition: TriList.h:54
Definition: Tri.h:49
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25