forked from facontidavide/PointCloudProcessing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grid.h
50 lines (42 loc) · 1.3 KB
/
grid.h
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
#ifndef FIXED_GRID_H
#define FIXED_GRID_H
#include <fstream>
#include <vector>
#include "CMesh.h"
using namespace std;
class CGrid
{
public:
std::vector<CVertex *> samples;
std::vector<int> index; // the start index of each grid in the sample points which is order by Zsort
int xside, yside, zside;
double radius;
typedef std::vector<CVertex *>::iterator iterator;
CGrid()
{
}
void init(std::vector<CVertex> &vert, vcg::Box3f &box, double radius);
// compute the repulsion terms, update vertex.p & vertex.wp
void iterate(void (*self)(iterator starta, iterator enda, double radius),
void (*other)(iterator starta, iterator enda, iterator startb, iterator endb, double radius));
// compute the data loyalty terms, update vertex.s & vertex.ws
void sample(CGrid &points,
void (*sample)(iterator starta, iterator enda, iterator startb, iterator endb, double radius));
int cell(int x, int y, int z)
{
return x + xside * (y + yside * z);
}
bool isEmpty(int cell)
{
return index[cell + 1] == index[cell];
}
iterator startV(int origin)
{
return samples.begin() + index[origin];
}
iterator endV(int origin)
{
return samples.begin() + index[origin + 1];
}
};
#endif