-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTriangle.hh
51 lines (46 loc) · 1.11 KB
/
Triangle.hh
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
#pragma once
/*
@author: Xinqi Bao
Triangle with 3 3-D vectors.
*/
#include <iostream>
#include "Vec3d.hh"
#include "BufferReadBinary.hh"
class Skip {
public:
friend std::istream& operator >>(std::istream& s, Skip& skip) {
while (isspace(s.get()) && !s.eof());
while (!isspace(s.get()) && !s.eof());
return s;
}
};
extern Skip skip;
class Triangle {
public:
Vec3d normal, v1, v2, v3;
Triangle() {}
Triangle(std::istream& s){
s >> skip >> skip >> normal;
s.ignore(1);s.ignore(256, '\n');
s >> skip >> v1;
s >> skip >> v2;
s >> skip >> v3;
s.ignore(1);s.ignore(256, '\n');
s.ignore(256, '\n');
}
Triangle(BufferReadBinary& buffer) {
normal.readBuffer(buffer);
v1.readBuffer(buffer);
v2.readBuffer(buffer);
v3.readBuffer(buffer);
buffer.step2Bytes();
}
Triangle(Vec3d& normal, Vec3d& v1, Vec3d& v2, Vec3d& v3) : normal(normal), v1(v1), v2(v2), v3(v3) {}
friend std::ostream& operator <<(std::ostream& s, Triangle& tri) {
return s <<
"normal: " << tri.normal << '\n' <<
"vertex: " << tri.v1 << '\n' <<
"vertex: " << tri.v2 << '\n' <<
"vertex: " << tri.v3 << '\n';
}
};