Parasol Planning Library (PPL)
GMSPolygon.h
Go to the documentation of this file.
1 #ifndef GMS_POLYGON_H_
2 #define GMS_POLYGON_H_
3 
4 #include <cstddef>
5 #include <utility>
6 #include <vector>
7 
8 #include "Orientation.h"
9 #include "Vector.h"
10 using namespace mathtool;
11 
12 
21 class GMSPolygon {
22 
23  public:
24 
27 
28  typedef typename std::vector<Point3d> PointList;
29  typedef typename std::vector<int> IndexList;
30 
31  typedef typename IndexList::const_iterator const_iterator;
32 
36 
40 
46  GMSPolygon(const int _v1, const int _v2, const int _v3,
47  const PointList& _pts);
48 
54  const PointList& _pts);
55 
60 
61  const_iterator begin() const noexcept;
62  const_iterator end() const noexcept;
63 
67 
71  const int& operator[](const size_t _i) const noexcept;
72 
74  size_t GetNumVertices() const noexcept;
75 
79  const Point3d& GetPoint(const size_t _i) const noexcept;
80 
82  Vector3d& GetNormal() noexcept;
83  const Vector3d& GetNormal() const noexcept;
84 
86  double GetArea() const noexcept;
87 
91 
92  void Reverse();
93  void ComputeNormal();
94 
98 
99  bool operator==(const GMSPolygon& _p) const noexcept;
100  bool operator!=(const GMSPolygon& _p) const noexcept;
101 
106 
107  bool operator<(const GMSPolygon& _other) const noexcept;
108  bool operator>(const GMSPolygon& _other) const noexcept;
109 
113 
115  const bool IsTriangle() const noexcept;
116 
118  const Point3d FindCenter() const noexcept;
119 
124  const bool PointIsAbove(const Point3d& _p) const noexcept;
125 
129  const int CommonVertex(const GMSPolygon& _p) const noexcept;
130 
135  const std::pair<int, int> CommonEdge(const GMSPolygon& _p) const noexcept;
136 
138 
139  private:
140 
143 
148  void AlignIndexes() noexcept;
149 
153 
154  IndexList m_indexes;
155  Vector3d m_normal;
156  double m_area{0};
157 
159  const PointList* m_pointList{nullptr};
160 
162 };
163 
164 #endif
Definition: GMSPolygon.h:21
std::vector< Point3d > PointList
Definition: GMSPolygon.h:28
std::vector< int > IndexList
Definition: GMSPolygon.h:29
IndexList::const_iterator const_iterator
Definition: GMSPolygon.h:31
Definition: Cfg.h:23