Fréchet View  1.6.0
A Tool for Exploring Fréchet Distance Algorithms
types.h
Go to the documentation of this file.
1 #ifndef POLY_TYPES_H
2 #define POLY_TYPES_H
3 
4 #include <utility>
5 #include <list>
6 #include <set>
7 #include <data/types.h>
8 #include <data/linkedlist.h>
9 #include <QDebug>
10 #include <QLineF>
11 
12 namespace frechet {
13 
14 using namespace data;
15 
16 namespace poly {
17 
21 static const int SOUTH_POLE_INDEX = -2;
22 
39 class Segment: public std::pair<int,int>
40 {
41 public:
45  Segment() : std::pair<int,int> (-1,-1) { }
53  Segment(int i, int j)
54  {
55  first = std::min(i,j);
56  second = std::max(i,j);
57  Q_ASSERT((first>=0 || first==SOUTH_POLE_INDEX) && second>=0);
58  }
62  bool empty() const {
63  return first==second;
64  }
69  bool is_diagonal(int n) const {
70  return ! is_edge(n);
71  }
76  bool is_edge(int n) const {
77  return (second==(first+1)) || ((first==0) && (second==(n-1)));
78  }
86  bool operator< (const Segment& that) const
87  {
88  if (this->first != that.first)
89  return this->first < that.first;
90  else
91  return this->second > that.second;
92  }
98  QLineF map(const Curve& curve) const {
99  return QLineF(map(curve,first),map(curve,second));
100  }
107  static QPointF map(const Curve& curve, int i) {
108  return curve[i % (curve.size()-1)];
109  }
110 };
111 
113 typedef std::vector<int> Polygon;
115 typedef std::set<Segment> Segments;
117 typedef std::list<Polygon> Partition;
118 
125 std::ostream& operator<< (std::ostream& out, const Segment& seg);
126 
127 } } // namespace frechet::poly
128 
129 #endif // POLY_TYPES_H
Represents a polygon line segment from node i to j.
Definition: types.h:39
global definitions for all algorithms.
std::set< Segment > Segments
a set of Segment objects
Definition: types.h:115
Segment(int i, int j)
default constructor with vertices. For poylgon edge segments, j==i+1 or j+1==i is expected....
Definition: types.h:53
bool is_edge(int n) const
Definition: types.h:76
Segment()
empty constructor; creates an invalid polygon segment
Definition: types.h:45
std::ostream & operator<<(std::ostream &stream, const frechet::data::Interval &ival)
operator for printing debug info to a std::ostream
Definition: interval.cpp:79
static bool is_edge(int a, int b, int n)
Definition: poly_utils.cpp:216
static const int SOUTH_POLE_INDEX
artifical vertex used by Triangulation
Definition: types.h:21
QPolygonF Curve
a polygonal curve in the plane; with double floating point precision. This type is heavily used throu...
Definition: types.h:20
bool is_diagonal(int n) const
Definition: types.h:69
std::list< Polygon > Partition
a partitioning of a polygon, that is a list of sub-sets
Definition: types.h:117
double min(double a, double b)
minimum function with checks for NAN
Definition: numeric.h:222
bool empty() const
Definition: types.h:62
QLineF map(const Curve &curve) const
map (embed) segment to a line in the plane
Definition: types.h:98
static QPointF map(const Curve &curve, int i)
map a polygon vertex to a point in the plane
Definition: types.h:107
std::vector< int > Polygon
Polygon a sub-set of vertex indexes.
Definition: types.h:113
double max(double a, double b)
maximum function with checks for NAN
Definition: numeric.h:233