-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathgeometry.h
158 lines (130 loc) · 2.69 KB
/
geometry.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#ifndef GEOMETRY_H
#define GEOMETRY_H
#include "circle.h"
#include "plane.h"
#include "cylinder.h"
#include "connection.h"
class Geometry
{
public:
Geometry()
{
}
~Geometry()
{
clearPrimitives();
}
void addCircle(Circle *circle)
{
mCircles.push_back(circle);
}
void removeCircle(size_t index)
{
delete mCircles[index];
mCircles.erase(mCircles.begin() + index);
}
size_t numCircles() const
{
return mCircles.size();
}
Circle* circle(size_t index) const
{
return mCircles[index];
}
void clearCircles()
{
for (Circle *circle : mCircles)
{
delete circle;
}
mCircles.clear();
}
void addPlane(Plane *plane)
{
mPlanes.push_back(plane);
}
void removePlane(size_t index)
{
delete mPlanes[index];
mPlanes.erase(mPlanes.begin() + index);
}
size_t numPlanes() const
{
return mPlanes.size();
}
Plane* plane(size_t index) const
{
return mPlanes[index];
}
void clearPlanes()
{
for (Plane *plane : mPlanes)
{
delete plane;
}
mPlanes.clear();
}
void addCylinder(Cylinder *cylinder)
{
mCylinders.push_back(cylinder);
}
void removeCylinder(size_t index)
{
delete mCylinders[index];
mCylinders.erase(mCylinders.begin() + index);
}
size_t numCylinders() const
{
return mCylinders.size();
}
Cylinder* cylinder(size_t index) const
{
return mCylinders[index];
}
void clearCylinders()
{
for (Cylinder *cylinder : mCylinders)
{
delete cylinder;
}
mCylinders.clear();
clearConnections();
}
void addConnection(Connection *connection)
{
mConnections.push_back(connection);
}
void removeConnection(size_t index)
{
delete mConnections[index];
mConnections.erase(mConnections.begin() + index);
}
size_t numConnections() const
{
return mConnections.size();
}
Connection* connection(size_t index) const
{
return mConnections[index];
}
void clearConnections()
{
for (Connection *connection : mConnections)
{
delete connection;
}
mConnections.clear();
}
void clearPrimitives()
{
clearCircles();
clearPlanes();
clearCylinders();
}
private:
std::vector<Circle*> mCircles;
std::vector<Plane*> mPlanes;
std::vector<Cylinder*> mCylinders;
std::vector<Connection*> mConnections;
};
#endif // GEOMETRY_H