codac 1.5.6
Loading...
Searching...
No Matches
codac2_Polygon.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include <list>
13#include <vector>
14#include <utility>
16#include "codac2_BoolInterval.h"
17#include "codac2_Segment.h"
18
19namespace codac2
20{
28 class Polygon
29 {
30 public:
31
37 Polygon(std::initializer_list<Vector> vertices);
38
44 Polygon(const std::vector<Vector>& vertices);
45
51 explicit Polygon(const std::vector<IntervalVector>& vertices);
52
58 Polygon(std::initializer_list<Segment> edges);
59
65 Polygon(const std::vector<Segment>& edges);
66
74 explicit Polygon(const IntervalVector& x);
75
81 const std::vector<Segment>& edges() const;
82
91 std::list<IntervalVector> unsorted_vertices() const;
92
98 std::vector<IntervalVector> sorted_vertices() const;
99
105 bool is_empty() const;
106
113 BoolInterval contains(const IntervalVector& p) const;
114
124 bool operator==(const Polygon& p) const;
125
131 static Polygon empty();
132
133 protected:
134
139
143 const std::vector<Segment> _edges;
144 };
145
153 std::ostream& operator<<(std::ostream& str, const Polygon& p);
154}
Represents a polygon (convex or non-convex) defined by its vertices enclosed in IntervalVectors.
Definition codac2_Polygon.h:29
Polygon()
Default protected constructor used internally.
std::vector< IntervalVector > sorted_vertices() const
Returns the list of vertices sorted in polygonal order.
const std::vector< Segment > _edges
Internal representation of the polygon as a list of edges.
Definition codac2_Polygon.h:143
Polygon(const std::vector< Vector > &vertices)
Constructs a Polygon from a vector of Vector vertices.
Polygon(const std::vector< Segment > &edges)
Constructs a Polygon from a vector of Segment edges.
bool is_empty() const
Checks whether the polygon is empty (has no vertex).
Polygon(const IntervalVector &x)
Constructs a box as a Polygon.
BoolInterval contains(const IntervalVector &p) const
Checks whether the polygon contains a given point.
Polygon(std::initializer_list< Segment > edges)
Constructs a Polygon from an initializer list of Segment edges.
Polygon(std::initializer_list< Vector > vertices)
Constructs a Polygon from an initializer list of Vector vertices.
bool operator==(const Polygon &p) const
Comparison operator.
const std::vector< Segment > & edges() const
Returns the list of edges of the polygon.
static Polygon empty()
Provides an empty polygon.
std::list< IntervalVector > unsorted_vertices() const
Returns the list of unique vertices in no particular order.
Polygon(const std::vector< IntervalVector > &vertices)
Constructs a Polygon from a vector of IntervalVector vertices.
std::ostream & operator<<(std::ostream &os, const BoolInterval &x)
Streams out a BoolInterval.
Definition codac2_BoolInterval.h:45
BoolInterval
Enumeration representing a boolean interval.
Definition codac2_BoolInterval.h:23