Fréchet View  1.6.0
A Tool for Exploring Fréchet Distance Algorithms
grid.h
Go to the documentation of this file.
1 #ifndef GRID_H
2 #define GRID_H
3 
4 #include <vector>
5 #include <types.h>
6 #include <interval.h>
7 
8 #include <boost/smart_ptr.hpp>
9 
15 enum LineStyle {
18  DEFAULT=0,
20  THIN,
23 };
26 typedef std::vector<LineStyle> LineStyleVector;
27 
28 namespace frechet { namespace fs {
29 
42 class GridAxis : public std::vector<data::Interval>
43 {
44 private:
49 
50 public:
52  GridAxis();
53 
58  void setCurve(const Curve& P);
64  void setLineStyles(const LineStyleVector& linesStyles, LineStyle defaultLineStyle);
65 
70  LineStyle lineStyle(int i) const;
71 
77  double map(double x) const;
83  data::Interval map(const Interval& other) const;
87  double length() const;
88 };
89 
118 class Grid {
119 
120 private:
125 
126 public:
128  typedef boost::shared_ptr<Grid> ptr;
129 public:
131  Grid() : _hor(), _vert() {}
132 
138  void setCurves(const Curve& P, const Curve& Q);
139 
141  const GridAxis& hor() const { return _hor; }
143  const GridAxis& vert() const { return _vert; }
144 
146  GridAxis& hor() { return _hor; }
148  GridAxis& vert() { return _vert; }
149 
150 
154  QSizeF size() const {
155  return QSizeF(_hor.size(),_vert.size());
156  }
160  QSizeF extent() const;
161 
167  QRectF cellBounds(int i, int j) const;
168 
174  Point mapPoint(Point p);
175 
181  QLineF mapLine(QLineF l);
182 
188  QRectF mapRect(QRectF r);
189 
195  Curve mapCurve(Curve c);
196 
202  QLineF verticalGridLine(int i);
203 
209  QLineF horizontalGridLine(int j);
210 
214  QRectF sceneRect();
215 
222  static Point mapToPoint(const Curve &C, double x);
230  static QLineF mapToSegment(const Curve &C, double x1, double x2);
238  static Curve mapToSequence(const Curve& C, double x1, double x2);
245  static Curve mapToSequence(const Curve& C, const std::vector<double>& seq);
246 };
247 
248 } } // namespace
249 
250 #endif // GRID_H
static Curve mapToSequence(const Curve &C, double x1, double x2)
given a polygonal curve and two offsets, compute the sequence of line segment connecting both offsets
Definition: grid.cpp:149
QSizeF extent() const
Definition: grid.cpp:70
double map(double x) const
maps a value from [0..n] onto the axis [0..|P|]
Definition: grid.cpp:44
QRectF sceneRect()
Definition: grid.cpp:124
GridAxis _vert
arc lengths of Q == vertical grid coordinates
Definition: grid.h:124
LineStyle lineStyle(int i) const
Definition: grid.cpp:35
QSizeF size() const
Definition: grid.h:154
const GridAxis & vert() const
Definition: grid.h:143
static Point mapToPoint(const Curve &C, double x)
given a polygonal curve and an offset, compute the point on the curve
Definition: grid.cpp:130
global definitions for all algorithms.
std::vector< LineStyle > LineStyleVector
Definition: grid.h:26
LineStyle defaultLineStyle
default line style for drawing a grid line
Definition: grid.h:46
GridAxis & hor()
Definition: grid.h:146
LineStyleVector lineStyles
custom line styles for grid lines
Definition: grid.h:48
static QLineF mapToSegment(const Curve &C, double x1, double x2)
given a polygonal curve and two offsets, compute the corresponding line segment
Definition: grid.cpp:144
void setCurve(const Curve &P)
compute the length of each polygon segment
Definition: grid.cpp:14
void setLineStyles(const LineStyleVector &linesStyles, LineStyle defaultLineStyle)
assign line styles for visualisation
Definition: grid.cpp:28
QLineF verticalGridLine(int i)
map a vertical line
Definition: grid.cpp:112
draw a dotted line
Definition: grid.h:21
QRectF mapRect(QRectF r)
map a rectangle from [0..n]x[0..m] to the grid coordinates [0..|P|]x[0..|Q|]
Definition: grid.cpp:99
GridAxis & vert()
Definition: grid.h:148
draw a solid line
Definition: grid.h:19
QPointF Point
a point in the plane; with double floating point precision. This type is heavily used throughout all ...
Definition: types.h:14
a grid axis maps the segments of the input curve to an axis of the free-space diagram.
Definition: grid.h:42
void setCurves(const Curve &P, const Curve &Q)
calculate grid from input curves
Definition: grid.cpp:64
performs mappings to and from the free-space grid
Definition: grid.h:118
draw a thin, solid line
Definition: grid.h:20
QPolygonF Curve
a polygonal curve in the plane; with double floating point precision. This type is heavily used throu...
Definition: types.h:20
Curve mapCurve(Curve c)
map a sequence of line segments from [0..n]x[0..m] to the grid coordinates [0..|P|]x[0....
Definition: grid.cpp:105
Definition: grid.h:18
GridAxis()
empty constructor
Definition: grid.cpp:8
draw no grid line
Definition: grid.h:22
boost::shared_ptr< Grid > ptr
smart pointer to a Grid object
Definition: grid.h:128
Point mapPoint(Point p)
map a point from [0..n]x[0..m] to the grid coordinates [0..|P|]x[0..|Q|]
Definition: grid.cpp:87
const GridAxis & hor() const
Definition: grid.h:141
LineStyle
display style of grid lines in free-space diagram
Definition: grid.h:15
QRectF cellBounds(int i, int j) const
Definition: grid.cpp:76
GridAxis _hor
arc lengths of P == horizontal grid coordinates
Definition: grid.h:122
QLineF horizontalGridLine(int j)
map a horizontal line
Definition: grid.cpp:118
Grid()
empty constructor
Definition: grid.h:131
an interval of two double values.
Definition: interval.h:31
double length() const
Definition: grid.cpp:60
QLineF mapLine(QLineF l)
map a line segment from [0..n]x[0..m] to the grid coordinates [0..|P|]x[0..|Q|]
Definition: grid.cpp:93