32 std::vector<Index>
tl;
42 N.
use.resize(maxIndex+1);
43 const Index *end = idx+size;
44 for (
const Index *v = idx; v<end; ++v) {
68 for (
size_t i=0; i<size; ++i) {
80void tipsify(Index *idx,
size_t num,
int cachesize=20,
int batchsize=-1) {
82 enum IndexValues : Index {
83 InvalidIndex = ~Index(0)
86 using namespace Tipsify;
91 auto N = buildNeighbours<Index>(idx, num, num);
93 std::vector<Index> out;
96 std::vector<char> emitted(N.tl.size());
98 std::vector<Index> deadEndStack;
99 std::vector<int> cachetime(N.maxIndexP1);
100 int time=cachesize+1;
102 Index f = num > 0 ? idx[0] : InvalidIndex;
103 int remaininbatch = batchsize;
104 while (f != InvalidIndex) {
106 std::set<Index> candidates;
107 for (Index i=N.offset[f]; i<N.offset[f+1]; ++i) {
111 for (
int i=0; i<3; ++i) {
113 Index v = idx[t*3+i];
115 deadEndStack.push_back(v);
116 candidates.insert(v);
118 if (time-cachetime[v] > cachesize) {
128 bool startFresh =
false;
130 startFresh = remaininbatch==0;
132 while (remaininbatch <= 0)
133 remaininbatch += batchsize;
137 deadEndStack.clear();
143 int maxPriority = -1;
144 for (
auto v: candidates) {
149 if (time - cachetime[v] + 2*N.use[v] <= cachesize && (batchsize<0 || N.use[v]<=remaininbatch))
150 priority = time-cachetime[v];
151 if (priority > maxPriority) {
152 maxPriority = priority;
156 if (f == InvalidIndex) {
158 while (!deadEndStack.empty()) {
159 Index v = deadEndStack.back();
160 deadEndStack.pop_back();
168 if (f == InvalidIndex) {
170 for (; cursor < num; ++cursor) {
171 Index v = idx[cursor];
180 assert(out.size() == num);
181 std::copy(out.begin(), out.end(), idx);
Definition: ARToolKit.h:33
void tipsify(Index *idx, size_t num, int cachesize=20, int batchsize=-1)
Definition: Tipsify.h:80
Neighbors< Index > buildNeighbours(const Index *idx, size_t size, Index maxIndex)
Definition: Tipsify.h:38
std::vector< Index > offset
Definition: Tipsify.h:33
std::vector< int > use
Definition: Tipsify.h:31
std::vector< Index > tl
Definition: Tipsify.h:32
Index maxIndexP1
Definition: Tipsify.h:30