![]() |
Fréchet View
1.6.0
A Tool for Exploring Fréchet Distance Algorithms
|
The FreeSpace class models the Free-Space Diagram calculated from two curves.
Holds a two-dimensional array of free-space Cell objects.
For k-Frechet we keep a map of connected components.
Definition at line 83 of file freespace.h.
#include <freespace.h>
Public Types | |
typedef boost::shared_ptr< FreeSpace > | ptr |
smart pointer to FreeSpace object More... | |
Public Member Functions | |
FreeSpace (const Curve &ap, const Curve &aq) | |
default constructor with two input curves More... | |
FreeSpace (const FreeSpace &that) | |
copy constructor More... | |
Components & | components () |
size_t | component (int i, int j) |
find the component ID for a cell. Empty cells return NO_COMPONENT. More... | |
void | calculateFreeSpace (double epsilon) |
calculate all free space intervals More... | |
void | calculateBounds (double epsilon) |
calculate the bounding boxes of the free-space areas (k-Frechet only) More... | |
Cell & | cell (int x, int y) |
const Cell & | cell (int x, int y) const |
bool | cellEmptyIntervals (int i, int j) const |
test if a cell is empty More... | |
bool | cellEmptyBounds (int i, int j) const |
test if the bounding box of a cell is empty More... | |
bool | cellFull (int i, int j) const |
test if a cell is completely covered by the free-space area More... | |
bool | isParallel (int i, int j) const |
test if the free-space area of a cell is a degenerate ellipse, i.e. two parallel lines. This is the case if the determinant is zero. More... | |
bool | isAlmostParallel (int i, int j) const |
test if the free-space area of a cell is a almost degenerate ellipse, This is the case if the determinant is very close to zero. For visualisation, the ellipse is replaced by two parallel lines. More... | |
bool | wrapRight () const |
if P is a closed curve, the free space diagram wraps at right edge More... | |
bool | wrapTop () const |
if Q is a closed curve, the free space diagram wraps at top edge More... | |
QRectF | segmentBounds (int i, int j) |
std::list< data::Interval > | collectFreeVerticalIntervals (int i) const |
traverse one column of the free-space and find all connected intervals. This method is needed by the algorithm for simple polygons during the computation of valid placements. More... | |
template<typename Float > | |
void | calculateEllipseBoundaries (const Point &p1, const Point &p2, const Point &q1, const Point &q2, double epsilon, double lambda[2]) |
Static Public Member Functions | |
template<typename Float > | |
static void | calculateFreeSpaceSegment (const Point &p, const Point &q, const Point &r, double epsilon, data::Interval &result) |
compute intervals for one point and segment. As parameters we expect a point on one curve (P,or Q) and a line segment on the other curve (Q,or P). More... | |
static void | fixBorderCase (data::Interval *N, data::Interval *E, data::Interval *S, data::Interval *W) |
fix border case at the joint of four intervals More... | |
Public Attributes | |
const Curve & | P |
first input curve More... | |
const Curve & | Q |
second input curve More... | |
const int | n |
number of vertexes in P More... | |
const int | m |
number of vertexes in Q More... | |
Static Public Attributes | |
static const QRectF | UNIT_RECT |
the unit rectangle [0,1]x[0,1] More... | |
static const double | DET_MINIMUM = 1e-12 |
minimum determinant to avoid roundoff errors More... | |
Private Member Functions | |
double | determinant (int i, int j) const |
template<typename Float > | |
void | calculateEllipseBoundaries (const Point &p1, const Point &p2, const Point &q1, const Point &q2, double epsilon, double lambda[2]) |
compute the bounding box of one cell in the free-space are. As parameters we expect two segments of P and Q More... | |
Private Attributes | |
data::Array2D< Cell > | cells |
free line segments as Intervals subset of [0..1] More... | |
Components | _components |
tracks connected components for k-Frechet algorithm More... | |
typedef boost::shared_ptr<FreeSpace> frechet::fs::FreeSpace::ptr |
smart pointer to FreeSpace object
Definition at line 92 of file freespace.h.
default constructor with two input curves
ap | first input curve |
aq | second input curve |
Definition at line 14 of file freespace.cpp.
FreeSpace::FreeSpace | ( | const FreeSpace & | that | ) |
void FreeSpace::calculateBounds | ( | double | epsilon | ) |
calculate the bounding boxes of the free-space areas (k-Frechet only)
epsilon | current value of epsilon |
Definition at line 112 of file freespace.cpp.
void frechet::fs::FreeSpace::calculateEllipseBoundaries | ( | const Point & | p1, |
const Point & | p2, | ||
const Point & | q1, | ||
const Point & | q2, | ||
double | epsilon, | ||
double | lambda[2] | ||
) |
Definition at line 281 of file freespace.cpp.
|
private |
compute the bounding box of one cell in the free-space are. As parameters we expect two segments of P and Q
p1 | start point of segment on P |
p2 | end point of segment on P |
q1 | start point of segment on Q |
q2 | end point of segment on Q |
epsilon | value of epsilon |
lambda | on return, holds two bounding intervals 'long double' values may be used for improved accuracy. End results are always 'double' precision. |
Float | floating point type for intermediate results. |
void FreeSpace::calculateFreeSpace | ( | double | epsilon | ) |
calculate all free space intervals
epsilon | current value of epsilon |
Supports parallel computation. On multi-core systems, the computation is distributed over all processors. Each processor copmutes a number of columns of the free-space.
Definition at line 35 of file freespace.cpp.
|
static |
compute intervals for one point and segment. As parameters we expect a point on one curve (P,or Q) and a line segment on the other curve (Q,or P).
p | point on P (resp. Q) |
q | start of segment on Q (resp. P) |
r | end of segment on Q (resp. P) |
epsilon | value of epsilon |
Float | floating point type for intermediate results. 'long double' values may be used for improved accuracy. End results are always 'double' precision. |
result | on return, holds the free-space interval (L_ij, resp. B_ij) |
Definition at line 8 of file freespace_impl.h.
|
inline |
x | grid column |
y | grid row |
Definition at line 160 of file freespace.h.
|
inline |
x | grid column |
y | grid row |
Definition at line 170 of file freespace.h.
bool FreeSpace::cellEmptyBounds | ( | int | i, |
int | j | ||
) | const |
test if the bounding box of a cell is empty
i | grid column |
j | grid row |
Definition at line 174 of file freespace.cpp.
bool FreeSpace::cellEmptyIntervals | ( | int | i, |
int | j | ||
) | const |
test if a cell is empty
i | grid column |
j | grid row |
Definition at line 182 of file freespace.cpp.
bool FreeSpace::cellFull | ( | int | i, |
int | j | ||
) | const |
test if a cell is completely covered by the free-space area
i | grid column |
j | grid row |
Definition at line 190 of file freespace.cpp.
std::list< Interval > FreeSpace::collectFreeVerticalIntervals | ( | int | i | ) | const |
traverse one column of the free-space and find all connected intervals. This method is needed by the algorithm for simple polygons during the computation of valid placements.
i | grid column |
Definition at line 217 of file freespace.cpp.
|
inline |
find the component ID for a cell. Empty cells return NO_COMPONENT.
i | grid column |
j | grid row |
Definition at line 133 of file freespace.h.
|
inline |
Definition at line 124 of file freespace.h.
|
private |
i | grid column |
j | grid row |
Definition at line 200 of file freespace.cpp.
|
static |
fix border case at the joint of four intervals
N | north interval |
E | east interval |
S | south interval |
W | west interval |
If (0,0) is in L, it must also be in B. ...unless it slipped out by numerical precision.
We make sure that adjacent intervals are consistent. This is especially important for "critical values".
Definition at line 252 of file freespace.cpp.
|
inline |
test if the free-space area of a cell is a almost degenerate ellipse, This is the case if the determinant is very close to zero. For visualisation, the ellipse is replaced by two parallel lines.
i | grid column |
j | grid row |
Definition at line 217 of file freespace.h.
|
inline |
test if the free-space area of a cell is a degenerate ellipse, i.e. two parallel lines. This is the case if the determinant is zero.
i | grid column |
j | grid row |
Definition at line 205 of file freespace.h.
QRectF FreeSpace::segmentBounds | ( | int | i, |
int | j | ||
) |
i | grid column |
j | grid row |
Definition at line 211 of file freespace.cpp.
|
inline |
if P is a closed curve, the free space diagram wraps at right edge
Definition at line 225 of file freespace.h.
|
inline |
if Q is a closed curve, the free space diagram wraps at top edge
Definition at line 230 of file freespace.h.
|
private |
tracks connected components for k-Frechet algorithm
Definition at line 108 of file freespace.h.
|
private |
free line segments as Intervals subset of [0..1]
Question: Is is really necessary to store the whole array of cells? A workings sets of two columns would be sufficient.
Answer: the algorithm for simple polygons needs the complete information. Memory requirements are modest, anywway.
Definition at line 106 of file freespace.h.
|
static |
minimum determinant to avoid roundoff errors
Definition at line 97 of file freespace.h.
const int frechet::fs::FreeSpace::m |
number of vertexes in Q
Definition at line 89 of file freespace.h.
const int frechet::fs::FreeSpace::n |
number of vertexes in P
Definition at line 88 of file freespace.h.
const Curve& frechet::fs::FreeSpace::P |
first input curve
Definition at line 86 of file freespace.h.
const Curve& frechet::fs::FreeSpace::Q |
second input curve
Definition at line 87 of file freespace.h.
|
static |
the unit rectangle [0,1]x[0,1]
Definition at line 95 of file freespace.h.