GEOS 3.11.1
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
26namespace geos {
27namespace geom {
28class Coordinate;
29}
30namespace triangulate {
31namespace quadedge {
32}
33}
34}
35
40
41namespace geos {
42namespace algorithm { // geos::algorithm
43namespace hull { // geos::algorithm::hull
44
45
46
47class 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 bool isMarked() const;
87 void setMarked(bool marked);
88 bool isRemoved();
89 TriIndex boundaryIndex() const;
90 TriIndex boundaryIndexCCW() const;
91 TriIndex boundaryIndexCW() const;
92
100 bool isConnecting() const;
101
107 int adjacent2VertexIndex() const;
108
117 TriIndex isolatedVertexIndex(TriList<HullTri>& triList) const;
118
119 double lengthOfLongestEdge() const;
120
127 bool hasBoundaryTouch() const;
128
129 static HullTri* findTri(TriList<HullTri>& triList, Tri* exceptTri);
130 static bool isAllMarked(TriList<HullTri>& triList);
131 static void clearMarks(TriList<HullTri>& triList);
132 static void markConnected(HullTri* triStart, HullTri* exceptTri);
133 static bool isConnected(TriList<HullTri>& triList, HullTri* exceptTri);
134
135 friend std::ostream& operator<<(std::ostream& os, const HullTri& ht);
136
137 double lengthOfBoundary() const;
138
139 void remove(TriList<HullTri>& triList);
140
141
142}; // HullTri
143
144
145
146
147
148
149} // geos::algorithm::hull
150} // geos::algorithm
151} // geos
152
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
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: geos.h:39