Fréchet View  1.6.0
A Tool for Exploring Fréchet Distance Algorithms
boundary.h
Go to the documentation of this file.
1 #ifndef BOUNDARY_H
2 #define BOUNDARY_H
3 
4 #include <interval.h>
5 #include <linkedlist.h>
6 
7 namespace frechet { namespace reach {
8 
17 enum Type : uint8_t {
24 };
25 
31 enum Orientation : uint8_t {
33 };
34 
40  return (Orientation)(1-ori);
41 }
51  ori = (Orientation)(ori+1);
52  return ori;
53 }
54 
56 
60 typedef BoundarySegment* Pointer;
61 
62 
115 enum Direction : uint8_t {
116  // Two Segments
117  FIRST=0,
118  SECOND=1,
119 
120  // Rectangle sections
123 
124  // l,h pointer direction
127 
128  // interval orientation
133 };
134 
140  return (Direction)(1-dir);
141 }
151  dir = (Direction)(dir+1);
152  return dir;
153 }
154 
163 
166  PointerInterval();
171 
173  operator bool () const;
175  bool operator! () const;
176 
186  PointerInterval& swap(bool doit=true);
190  PointerInterval swapped() const;
191 
197  bool contains(Pointer p) const;
198 
201  PointerInterval normalized() const;
207  PointerInterval operator+ (const PointerInterval& that) const;
208 
214  bool operator== (const PointerInterval& that) const {
215  return (this->l==that.l) && (this->h==that.h);
216  }
220  void clear();
221 };
222 
229 Pointer min(const Pointer a, const Pointer b);
235 Pointer min(const PointerInterval& ival);
242 Pointer min(const PointerInterval& a, const PointerInterval& b);
243 
250 Pointer max(const Pointer a, const Pointer b);
256 Pointer max(const PointerInterval& ival);
263 Pointer max(const PointerInterval& a, const PointerInterval& b);
264 
265 
286  public data::LinkedListElement<BoundarySegment>,
287  public data::Interval, // bounds
288  public PointerInterval // l,h
289 {
290 private:
291  friend class Structure;
293  mutable struct {
294  union {
299  };
300 #ifdef QT_DEBUG
301  void* owner;
303 #endif
304  } temp;
309  Pointer twin(int hops) {
310  Pointer result=this;
311  while(hops--) result = result->temp._twin;
312  return result;
313  }
314 
315 public:
318  const Orientation ori;
319  const Direction dir;
320 
321 public:
327  Pointer clone = new BoundarySegment(*this);
328  temp.clone = clone;
329  clone->temp.clone = (Pointer)this; // non-const, but mostly harmless
330  return clone;
331  }
333  Pointer clone() const { return temp.clone; }
335  void clearClone() const { temp.clone=nullptr; }
336 
337 #ifdef QT_DEBUG
338  void* owner() const { return temp.owner; }
342  void setOwner(void* own) const { temp.owner=own; }
343 #endif
344 
345 public:
354  BoundarySegment(const Interval& ival, Orientation ori, Direction dir, Type t, void* owner=nullptr);
355 
359  void clear() {
362  // NEVER Interval::clear()
363  }
369  bool contains(double x) const {
370  return Interval::contains(x);
371  }
377  bool contains(Pointer p) const {
378  return PointerInterval::contains(p);
379  }
387  return *this;
388  }
395  bool operator== (const BoundarySegment& that) const {
396  return (this->type==that.type)
397  && (this->ori==that.ori)
398  && (this->dir==that.dir)
400  }
401 #ifdef BOUNDARY_VDESTRUCTOR
402 
406  virtual ~BoundarySegment() {
407 #ifdef QT_DEBUG
408  temp.owner=nullptr;
409 #endif
410  }
411 #endif
412 };
413 
428 int compare_interval(const PointerInterval& ival);
435 bool empty_interval(Pointer a, Pointer b);
441 bool empty_interval(const PointerInterval& ival);
449 
458 
462 
464 std::ostream& operator<< (std::ostream& out, const BoundaryList& list);
465 
466 } } // namespace frechet::reach
467 
468 #endif // BOUNDARY_H
bool empty_see_through_interval(Pointer p)
test intersection of intervals. Assumes a SEE_THROUGH segment.
Definition: boundary.cpp:203
Pointer max(const Pointer a, const Pointer b)
maximum of two reachability intervals; compare lower bound, then upper bound
Definition: boundary.cpp:70
Pointer min(const Pointer a, const Pointer b)
minimum of two reachability intervals; compare lower bound, then upper bound
Definition: boundary.cpp:49
PointerInterval operator+(const PointerInterval &that) const
merge operator
Definition: boundary.cpp:105
clockwise interval (bottom-then-left)
Definition: boundary.h:132
reachable: other intervals are reachable
Definition: boundary.h:21
BoundarySegment & operator=(const PointerInterval &lh)
assigment operator from interval
Definition: boundary.h:385
void clear()
clear both pointer (assgin nullptr)
Definition: boundary.cpp:255
bottom and left part of the reachability structure
Definition: boundary.h:121
PointerInterval & swap(bool doit=true)
conditional swap
Definition: boundary.cpp:39
see-through: other interals are visible with a straight line
Definition: boundary.h:23
global definitions for all algorithms.
PointerInterval swapped() const
Definition: boundary.cpp:44
const Orientation ori
horizontal or vertical
Definition: boundary.h:318
non-accesible. no interval is reachable from this one
Definition: boundary.h:19
data::LinkedList< BoundarySegment > BoundaryList
a double-linked list of reachability segments. makes up one of the four edges of a reachability struc...
Definition: boundary.h:461
Pointer createClone() const
create an identical copy of this segment
Definition: boundary.h:326
Direction
direction of a Pointer inside the reachability structure.
Definition: boundary.h:115
Interval()
Default constructor. Creates an invalid Interval.
Definition: interval.h:44
struct frechet::reach::BoundarySegment::@4 temp
temporary data used during merge and split operations
boundary interval in the reachability structure. Represents an interval on the boundary of the FreeSp...
Definition: boundary.h:285
describes l,h pointers. Both pointers are assumed to point into the same rectangle section (right-top...
Definition: boundary.h:160
backward l,h pointer = from second INTO first segment
Definition: boundary.h:126
Pointer twin(int hops)
Definition: boundary.h:309
PointerInterval()
empty constructor; constructs an invalid interval, with both pointers being nullptr
Definition: boundary.cpp:22
int compare_pointers(Pointer a, Pointer b)
compare two pointers on opposite parts of a reachability structure (eitehr left->right-top,...
Definition: boundary.cpp:214
BoundarySegment * Pointer
(dumb) pointer to a BoundarySegment object
Definition: boundary.h:55
Type type
reachability label
Definition: boundary.h:317
PointerInterval normalized() const
assumes identical orientation !!
Definition: boundary.cpp:92
std::ostream & operator<<(std::ostream &out, const BoundaryList &list)
print operator for debugging
Definition: boundary.cpp:272
bool contains(double x) const
containment test
Definition: boundary.h:369
Type
Segment Types.
Definition: boundary.h:17
Pointer clone
points to a clone of this object
Definition: boundary.h:295
PointerInterval & operator=(const Pointer &p)
assigment
Definition: boundary.cpp:34
right and top part of the reachability structure
Definition: boundary.h:122
void clear()
clears pointers, keep interval bounds
Definition: boundary.h:359
Orientation
Segment Orientation.
Definition: boundary.h:31
counter-clockwise interval (right-then-top)
Definition: boundary.h:130
second segment = right and top edge
Definition: boundary.h:118
void clearClone() const
disconnect from clone. Does not release any memory.
Definition: boundary.h:335
bool contains(Pointer p) const
containment test
Definition: boundary.h:377
const Direction dir
left/right or bottom/top
Definition: boundary.h:319
Pointer l
points to the lowest segment of the interval
Definition: boundary.h:161
int compare_interval(Pointer a, Pointer b)
compare two pointers in the same part of a reachability structure (either right-top,...
Definition: boundary.cpp:148
bool contains(Pointer p) const
containment test
Definition: boundary.cpp:248
Orientation opposite(Orientation ori)
Definition: boundary.h:39
forward l,h pointer = from first INTO second segment
Definition: boundary.h:125
Orientation & operator++(Orientation &ori)
pre-increment an orientation variable. Note that an orientation variable can only be incremented once...
Definition: boundary.h:50
bool contains(double x) const
containment test (assumes closed interval, bounds inclusive)
Definition: interval.h:206
bool operator==(const PointerInterval &that) const
comparison operator
Definition: boundary.h:214
BoundarySegment(const Interval &ival, Orientation ori, Direction dir, Type t, void *owner=nullptr)
default constructor
Definition: boundary.cpp:9
The Reachability Structure; maintains a list of intervals on the border of Free Space,...
Definition: structure.h:32
Pointer h
points to the highest segment of the interval
Definition: boundary.h:162
first segment = bottom and left edge
Definition: boundary.h:117
base template for elements of a LinkedList
Definition: linkedlist.h:54
an interval of two double values.
Definition: interval.h:31
Pointer _twin
points to a segment on the opposite edge of the reachability structure. twins have the same boundary ...
Definition: boundary.h:298
bool operator==(const BoundarySegment &that) const
comparison operator
Definition: boundary.h:395
bool empty_interval(Pointer a, Pointer b)
test intersection of intervals
Definition: boundary.cpp:191