-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.h
60 lines (49 loc) · 1.4 KB
/
util.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
#pragma once
#define BT_BUF_SIZE 100
#include <execinfo.h>
#include <stdlib.h>
#include <iostream>
struct StackException {
StackException(const std::string &errstr) {
int nptrs = backtrace(buffer, BT_BUF_SIZE);
strings = backtrace_symbols(buffer, nptrs);
std::cout << "Exception: " << errstr << std::endl;
for(int i=0; i<nptrs; i++) {
std::cout << "\t" << strings[i] << std::endl;
}
exit(255);
}
private:
void *buffer[BT_BUF_SIZE];
char **strings;
};
#include <tuple>
struct float3 {
float3() : x{0}, y{0}, z{0} {}
float3(float x, float y, float z) : x{x}, y{y}, z{z} {}
float x, y, z;
bool operator==(const float3& other) {
return (x==other.x) && (y==other.y) && (z==other.z);
}
bool operator!=(const float3& other) {
return !(*this == other);
}
};
struct int3 {
int3(int a, int b, int c) : a{a}, b{b}, c{c} {}
int a, b, c;
};
struct float2 {
float2() : s{0}, t{0} {}
float2(float s, float t) : s{s}, t{t} {}
float s, t;
bool operator==(const float2& other) {
return (s==other.s) && (t==other.t);
}
bool operator!=(const float2& other) {
return !(*this == other);
}
};
std::ostream &operator<<(std::ostream &os, int3 const &m);
std::ostream &operator<<(std::ostream &os, float3 const &m);
std::ostream &operator<<(std::ostream &os, float2 const &m);