-
Notifications
You must be signed in to change notification settings - Fork 5
/
Resln.h
61 lines (51 loc) · 1.4 KB
/
Resln.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
51
52
53
54
55
56
57
58
59
60
61
#ifndef __RESLN_H__
#define __RESLN_H__
#include "./bigint/BigUnsigned.hh"
#include "./bigint/BigIntegerUtils.hh"
namespace Karras {
// typedef unsigned int Morton;
// typedef unsigned long Morton;
typedef BigUnsigned Morton;
// Stores resolution and octree height values
struct Resln {
public:
Resln()
: width(8), volume(64), bits(3), mbits(3*DIM) {}
Resln(const int width_)
: width(width_) {
if (width == 0) {
throw std::logic_error("No support for width of 0");
}
volume = width;
for (int i = 1; i < DIM; ++i) {
volume *= width;
}
bits = 0;
int w = width;
while (!(w & 1)) {
++bits;
w = w >> 1;
}
mbits = bits * DIM;
}
friend std::ostream& operator<<(std::ostream& out, const Resln& resln);
friend std::istream& operator>>(std::istream& in, Resln& resln);
// width is the quantized width in one dimension.
int width;
int volume;
// Number of bits per dimension is bits = log(width).
int bits;
// Total number of bits for morton code is mbits = bits * DIM.
int mbits;
};
inline std::ostream& operator<<(std::ostream& out, const Resln& resln) {
out << resln.width << " " << resln.volume << " "
<< resln.bits << " " << resln.mbits;
return out;
}
inline std::istream& operator>>(std::istream& in, Resln& resln) {
in >> resln.width >> resln.volume >> resln.bits >> resln.mbits;
return in;
}
} // namespace
#endif