17 const EdgeHandling& edgeHandling,
const size_t windowSize)
19 edgeHandling_(edgeHandling),
57 const Index centerIndex(*(*
this));
59 const Index originalTopLeftIndex(centerIndex - windowMargin);
60 Index topLeftIndex(originalTopLeftIndex);
62 Index bottomRightIndex(centerIndex + windowMargin);
64 const Size adjustedWindowSize(bottomRightIndex - topLeftIndex + Size::Ones());
69 return data_.block(topLeftIndex(0), topLeftIndex(1), adjustedWindowSize(0), adjustedWindowSize(1));
72 const Matrix data =
data_.block(topLeftIndex(0), topLeftIndex(1), adjustedWindowSize(0), adjustedWindowSize(1));
76 const Index topLeftIndexShift(topLeftIndex - originalTopLeftIndex);
77 returnData.block(topLeftIndexShift(0), topLeftIndexShift(1), adjustedWindowSize(0), adjustedWindowSize(1)) =
78 data_.block(topLeftIndex(0), topLeftIndex(1), adjustedWindowSize(0), adjustedWindowSize(1));
81 return Matrix::Zero(0, 0);
87 "SlidingWindowIterator cannot be used with grid maps that don't have a default buffer start index.");
89 "SlidingWindowIterator has a wrong window size!");
101 const Index centerIndex(*(*
this));
103 const Index topLeftIndex(centerIndex - windowMargin);
104 const Index bottomRightIndex(centerIndex + windowMargin);
bool dataInsideMap() const
Check if data for current index is fully inside map.
const EdgeHandling edgeHandling_
Edge handling method.
size_t windowSize_
Size of the sliding window.
size_t windowMargin_
Size of the border of the window around the center cell.
SlidingWindowIterator(const GridMap &gridMap, const std::string &layer, const EdgeHandling &edgeHandling=EdgeHandling::CROP, const size_t windowSize=3)
const Matrix getData() const
double getResolution() const
SlidingWindowIterator & operator++()
Size size_
Size of the buffer.
bool isDefaultStartIndex() const
void setup(const GridMap &gridMap)
Setup members.
void boundIndexToRange(Index &index, const Size &bufferSize)
bool checkIfIndexInRange(const Index &index, const Size &bufferSize)
void setWindowLength(const GridMap &gridMap, const double windowLength)
virtual GridMapIterator & operator++()
const Matrix & data_
Data.