-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmesh.h
49 lines (39 loc) · 1.48 KB
/
mesh.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
#pragma once
#include <vector>
#include <Eigen/Dense>
#include "intersectable.h"
#include "rtree_util.h"
class Mesh : public Intersectable {
public:
struct Face {
Eigen::Vector3f v0, v1, v2;
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};
private:
typedef unsigned int faceID;
typedef unsigned int vertexID;
struct MeshIntersectReport {
Face face;
faceID faceid;
Eigen::Vector3f normal;
Eigen::Vector3f intersect_point;
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};
std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f>> vertices;
std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f>> vertex_normals;
std::vector<std::array<vertexID, 3>> face_index;
std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f>> face_normals;
std::vector<std::vector<faceID>> vertex_to_face;
MyTree tree;
public:
Mesh();
void readPlyFile(const char *file);
virtual Eigen::AlignedBox3f getBoundingBox() const override;
virtual bool rayIntersect(const Eigen::Vector3f &rayO,
const Eigen::Vector3f &rayD,
IntersectReport &report) const override;
virtual bool rayIntersectWithIntervals(const Eigen::Vector3f &rayO,
const Eigen::Vector3f &rayD,
DisjointIntervals &intervals) const override;
Face getFace(faceID id) const;
};