17 const EdgeHandling& edgeHandling,
const size_t windowSize)
19 edgeHandling_(edgeHandling),
61 const Index centerIndex(*(*
this));
63 const Index originalTopLeftIndex(centerIndex - windowMargin);
64 Index topLeftIndex(originalTopLeftIndex);
66 Index bottomRightIndex(centerIndex + windowMargin);
68 const Size adjustedWindowSize(bottomRightIndex - topLeftIndex + Size::Ones());
73 return data_.block(topLeftIndex(0), topLeftIndex(1), adjustedWindowSize(0), adjustedWindowSize(1));
76 const Matrix data =
data_.block(topLeftIndex(0), topLeftIndex(1), adjustedWindowSize(0), adjustedWindowSize(1));
79 returnData.setConstant(NAN);
81 returnData.setConstant(data.meanOfFinites());
83 const Index topLeftIndexShift(topLeftIndex - originalTopLeftIndex);
84 returnData.block(topLeftIndexShift(0), topLeftIndexShift(1), adjustedWindowSize(0), adjustedWindowSize(1)) =
85 data_.block(topLeftIndex(0), topLeftIndex(1), adjustedWindowSize(0), adjustedWindowSize(1));
88 return Matrix::Zero(0, 0);
94 throw std::runtime_error(
"SlidingWindowIterator cannot be used with grid maps that don't have a default buffer start index.");
97 throw std::runtime_error(
"SlidingWindowIterator has a wrong window size!");
110 const Index centerIndex(*(*
this));
112 const Index topLeftIndex(centerIndex - windowMargin);
113 const Index bottomRightIndex(centerIndex + windowMargin);
const EdgeHandling edgeHandling_
Edge handling method.
bool dataInsideMap() const
Check if data for current index is fully inside map.
size_t windowSize_
Size of the sliding window.
bool isDefaultStartIndex() const
size_t windowMargin_
Size of the border of the window around the center cell.
double getResolution() const
void setWindowLength(const GridMap &gridMap, double windowLength)
Size size_
Size of the buffer.
void setup(const GridMap &gridMap)
Setup members.
void boundIndexToRange(Index &index, const Size &bufferSize)
bool checkIfIndexInRange(const Index &index, const Size &bufferSize)
SlidingWindowIterator & operator++() override
SlidingWindowIterator(const GridMap &gridMap, const std::string &layer, const EdgeHandling &edgeHandling=EdgeHandling::CROP, size_t windowSize=3)
virtual GridMapIterator & operator++()
const Matrix & data_
Data.