-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtriangle.h
59 lines (46 loc) · 1023 Bytes
/
triangle.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
#ifndef TRIANGLE_H
#define TRIANGLE_H
#include <vector>
#include "point.h"
// We're too lazy to figure out what to do for triangles so, we'll work it out later.
struct Triangle
{
Triangle(unsigned a, unsigned b, unsigned c)
{
vtxes[0] = a, vtxes[1] = b, vtxes[2] = c;
}
Triangle(unsigned (&vs)[3])
{
vtxes[0] = vs[0], vtxes[1] = vs[1], vtxes[2] = vs[2];
}
unsigned vtxes[3];
};
class TriangleBunch
{
public:
TriangleBunch()
{}
TriangleBunch(Points const& pts)
: points_(pts)
{}
void set_points(Points const& pts)
{
points_ = pts;
}
void add_point(PointType const& pt)
{
points_.push_back(pt);
}
void add_triangle(unsigned a, unsigned b, unsigned c)
{
assert(a < points_.size());
assert(b < points_.size());
assert(c < points_.size());
triangles_.push_back(Triangle(a, b, c));
}
private:
typedef std::vector<Triangle> Triangles;
Triangles triangles_;
Points points_;
};
#endif // TRIANGLE_H