-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathShot.h
60 lines (49 loc) · 1.63 KB
/
Shot.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
#ifndef SHOT_H
#define SHOT_H
#include <string>
#include <vector>
#include <brlcad/vmath.h>
/*** An rt 'Shot'. Composed of a ray, and a vector of hit partitions ***/
class Shot {
public:
class Ray {
public:
explicit Ray(double tol) : tol(tol), pt{0, 0, 0}, dir{0, 0, 0} {}
point_t pt;
vect_t dir;
const double tol; // comparison tolerance
inline bool operator==(const Ray& other) const {
return VNEAR_EQUAL(pt, other.pt, tol) && VNEAR_EQUAL(dir, other.dir, tol);
}
};
class Partition {
public:
explicit Partition(double tol)
: tol(tol), region(""), in{0, 0, 0}, in_norm{0, 0, 0}, in_dist(0),
out{0, 0, 0}, out_norm{0, 0, 0}, out_dist(0) {}
std::string region;
point_t in;
vect_t in_norm;
double in_dist;
point_t out;
vect_t out_norm;
double out_dist;
const double tol; // comparison tolerance
inline bool operator==(const Partition& other) const {
return region == other.region &&
VNEAR_EQUAL(in, other.in, tol) &&
VNEAR_EQUAL(in_norm, other.in_norm, tol) &&
NEAR_EQUAL(in_dist, other.in_dist, tol) &&
VNEAR_EQUAL(out, other.out, tol) &&
VNEAR_EQUAL(out_norm, other.out_norm, tol) &&
NEAR_EQUAL(out_dist, other.out_dist, tol);
}
};
// Shot members
Ray ray;
std::vector<Partition> parts;
inline bool operator==(const Shot& other) const {
return ray == other.ray && parts == other.parts;
}
};
#endif // SHOT_H