File size: 3,865 Bytes
9375c9a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
// Copyright (C) 2011 Davis E. King ([email protected])
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_BORDER_EnUMERATOR_ABSTRACT_H_
#ifdef DLIB_BORDER_EnUMERATOR_ABSTRACT_H_
#include "rectangle_abstract.h"
namespace dlib
{
// ----------------------------------------------------------------------------------------
class border_enumerator
{
/*!
POINTERS AND REFERENCES TO INTERNAL DATA
All operations on this object other than calling element() invalidate
pointers and references to internal data.
WHAT THIS OBJECT REPRESENTS
This object is an enumerator over the border points of a rectangle.
!*/
public:
border_enumerator(
);
/*!
ensures
- #move_next() == false
(i.e. this object is "empty" and won't enumerate anything)
- current_element_valid() == false
- at_start() == true
- size() == 0
!*/
border_enumerator(
const rectangle& rect,
unsigned long border_size
);
/*!
ensures
- This object will enumerate over the border points which are inside rect
but within border_size of the edge. For example, if border_size == 1
then it enumerates over the single point wide strip of points all around
the interior edge of rect.
- current_element_valid() == false
- at_start() == true
- size() == rect.area() - shrink_rect(rect,border_size).area()
(i.e. the number of points in the border area of rect)
!*/
border_enumerator(
const rectangle& rect,
const rectangle& non_border_region
);
/*!
ensures
- This object will enumerate over all points which are in rect but
not in non_border_region.
- current_element_valid() == false
- at_start() == true
- size() == rect.area() - rect.intersect(non_border_region).area()
!*/
bool at_start (
) const;
/*!
ensures
- returns true if *this represents one position before the first point
(this would also make the current element invalid) else returns false
!*/
void reset (
);
/*!
ensures
- #current_element_valid() == false
- #at_start() == true
!*/
bool current_element_valid(
) const;
/*!
ensures
- returns true if we are currently at a valid element else
returns false
!*/
bool move_next(
);
/*!
ensures
- moves to the next element. i.e. #element() will now
return the next border point.
- the return value will be equal to #current_element_valid()
- #at_start() == false
- returns true if there is another element
- returns false if there are no more elements in the container
!*/
size_t size (
) const;
/*!
ensures
- returns the number of border points
!*/
const point& element (
) const;
/*!
requires
- current_element_valid() == true
ensures
- returns the current border point
!*/
};
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_BORDER_EnUMERATOR_ABSTRACT_H_
|