Newer
Older
#pragma once
#include <assert.h>
#include <iostream>
#include "Utils.h"
//! @brief Helper class for slicing containers.
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
class Slicer
{
public:
Slicer();
protected:
// Slicing.
template <class Container1, class Container2>
void update (const Container1 &source, Container2 &slice);
template <class Container1, class Container2>
void next (const Container1 &source, Container2 &slice);
template <class Container1, class Container2>
void previous (const Container1 &source, Container2 &slice);
template <class Container1, class Container2>
void reset (const Container1 &source, Container2 &slice);
public:
// Slicing parameters.
//! @brief Sets the overlap.
//!
//! @param overlap The number of overlapping vertices
//! between on and the next slice.
void setOverlap (uint32_t overlap);
//! @brief Sets the number of vertices per slice.
//!
//! @param N The number of vertices per slice.
void setN (std::uint32_t N);
//! @brief Sets the start index.
//!
//! @param idxStart The start index.
void setStartIndex (int idxStart);
//! @return Returns the overlap.
uint32_t overlap ();
//! @return Returns the number of vertices per slice N.
uint32_t N ();
//! @return Returns the start index.
int startIndex ();
private:
Valentin Platzgummer
committed
void _updateIdx(long size);
long _idxStart;
long _idxEnd;
long _idxNext;
long _idxPrevious;
Valentin Platzgummer
committed
long _overlap;
long _N;
};
template <class Container1, class Container2>
void Slicer::update(const Container1 &source, Container2 &slice){
WaypointManager::Utils::extract(source, slice, _idxStart, _idxEnd);
}
template <class Container1, class Container2>
void Slicer::next(const Container1 &source, Container2 &slice){
setStartIndex(_idxNext);
update(source, slice);
}
template <class Container1, class Container2>
void Slicer::previous(const Container1 &source, Container2 &slice){
setStartIndex(_idxPrevious);
update(source, slice);
}
template <class Container1, class Container2>
void Slicer::reset(const Container1 &source, Container2 &slice){
setStartIndex(0);
update(source, slice);
}