OGS
Polygon.h
Go to the documentation of this file.
1 
15 #pragma once
16 
17 #include <list>
18 #include <vector>
19 
20 #include "AABB.h"
21 #include "Point.h"
22 #include "Polyline.h"
23 
24 namespace GeoLib
25 {
33 enum class EdgeType
34 {
35  TOUCHING,
36  CROSSING,
38 };
39 
43 class Polygon : public Polyline
44 {
45 public:
52  explicit Polygon(const Polyline& ply, bool init = true);
53 
54  Polygon(Polygon const& other);
55  Polygon& operator=(Polygon const& rhs) = delete;
56 
57  ~Polygon() override;
58 
59  bool initialise ();
60 
67  bool isPntInPolygon(const MathLib::Point3d& pnt) const;
68 
74  bool containsSegment(GeoLib::LineSegment const& segment) const;
75 
80  bool isPolylineInPolygon (const Polyline& ply) const;
88  bool isPartOfPolylineInPolygon (const Polyline& ply) const;
89 
100  GeoLib::Point& intersection_pnt,
101  std::size_t& seg_num) const;
102 
105  std::list<Polygon*> const& computeListOfSimplePolygons();
106 
107  friend bool operator==(Polygon const& lhs, Polygon const& rhs);
108 private:
114  std::vector<GeoLib::Point> getAllIntersectionPoints(
115  GeoLib::LineSegment const& segment) const;
116 
124  EdgeType getEdgeType(std::size_t k, MathLib::Point3d const& pnt) const;
125 
126  void ensureCCWOrientation ();
127 
129  const std::list<Polygon*>::const_iterator& polygon_it);
130 
131  void splitPolygonAtPoint (const std::list<Polygon*>::iterator& polygon_it);
132  std::list<Polygon*> _simple_polygon_list;
134 };
135 
142 bool operator==(Polygon const& lhs, Polygon const& rhs);
143 
144 } // end namespace GeoLib
Definition of the AABB class.
Definition of the PolyLine class.
Class AABB is an axis aligned bounding box around a given set of geometric points of (template) type ...
Definition: AABB.h:49
std::list< Polygon * > const & computeListOfSimplePolygons()
Definition: Polygon.cpp:618
friend bool operator==(Polygon const &lhs, Polygon const &rhs)
Definition: Polygon.cpp:521
bool isPolylineInPolygon(const Polyline &ply) const
Definition: Polygon.cpp:215
void splitPolygonAtPoint(const std::list< Polygon * >::iterator &polygon_it)
Definition: Polygon.cpp:457
std::vector< GeoLib::Point > getAllIntersectionPoints(GeoLib::LineSegment const &segment) const
Definition: Polygon.cpp:128
void splitPolygonAtIntersection(const std::list< Polygon * >::const_iterator &polygon_it)
Definition: Polygon.cpp:398
bool isPartOfPolylineInPolygon(const Polyline &ply) const
Definition: Polygon.cpp:222
bool isPntInPolygon(const MathLib::Point3d &pnt) const
Definition: Polygon.cpp:71
bool containsSegment(GeoLib::LineSegment const &segment) const
Definition: Polygon.cpp:144
~Polygon() override
Definition: Polygon.cpp:47
EdgeType getEdgeType(std::size_t k, MathLib::Point3d const &pnt) const
Definition: Polygon.cpp:282
std::list< Polygon * > _simple_polygon_list
Definition: Polygon.h:132
bool getNextIntersectionPointPolygonLine(GeoLib::LineSegment const &seg, GeoLib::Point &intersection_pnt, std::size_t &seg_num) const
Definition: Polygon.cpp:248
bool initialise()
Definition: Polygon.cpp:60
void ensureCCWOrientation()
Definition: Polygon.cpp:317
Polygon & operator=(Polygon const &rhs)=delete
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
Definition: Polyline.h:53
friend class Polygon
Definition: Polyline.h:94
EdgeType
Definition: Polygon.h:34
@ INESSENTIAL
INESSENTIAL.
@ CROSSING
CROSSING.
@ TOUCHING
TOUCHING.
bool operator==(LineSegment const &s0, LineSegment const &s1)