-
Notifications
You must be signed in to change notification settings - Fork 2
/
Polyhedron.h
96 lines (77 loc) · 2.15 KB
/
Polyhedron.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//
// Created by Ryan.Zurrin001 on 12/16/2021.
//
#ifndef PHYSICSFORMULA_POLYHEDRON_H
#define PHYSICSFORMULA_POLYHEDRON_H
#pragma once
#include <vector>
#include "Polygon.h" // For vertex
#include "Plane.h"
namespace rez {
struct Face;
struct Vertex3d {
Point3d* point = nullptr;
bool processed = false;
Vertex3d() {}
Vertex3d(Point3d* _point)
{
point = _point;
processed = false;
}
};
struct Edge3d {
Vertex3d* vertices[2];
Face* faces[2] = { nullptr, nullptr };
Edge3d(Vertex3d* p1, Vertex3d* p2)
{
vertices[0] = p1;
vertices[1] = p2;
}
bool operator==(const Edge3d& _other) const
{
if (*vertices[0]->point == *_other.vertices[0]->point
&& *vertices[1]->point == *_other.vertices[1]->point)
return true;
return false;
}
};
struct Face {
std::vector<Edge3d*> edges;
std::vector<Vertex3d*> vertices;
Planef plane;
bool visible = false;
bool normal_switch_needed = false;
Face() {}
Face(Vertex3d* p1, Vertex3d* p2, Vertex3d* p3)
{
vertices.push_back(p1);
vertices.push_back(p2);
vertices.push_back(p3);
plane = Planef(*p1->point, *p2->point, *p3->point);
}
bool operator==(const Face& _other)
{
if (vertices.size() != _other.vertices.size())
return false;
bool ret = true;
for (size_t i = 0; i < vertices.size(); i++)
{
if (vertices[i]->point != _other.vertices[i]->point)
{
ret = false;
break;
}
}
return ret;
}
void addEdge(Edge3d* edg_ptr)
{
edges.push_back(edg_ptr);
}
};
class Polyhedron {
std::vector<Face> faces;
public:
};
}
#endif //PHYSICSFORMULA_POLYHEDRON_H