-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cluster.cpp
48 lines (39 loc) · 963 Bytes
/
Cluster.cpp
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
#include "Cluster.h"
Cluster::Cluster(int clusterId, PointBGR centroid) {
this->clusterId = clusterId;
for (int i = 0; i < centroid.getDimensions(); i++) {
this->centroid.push_back(centroid.getVal(i));
}
this->addPoint(centroid);
}
void Cluster::addPoint(PointBGR p) {
p.setCluster(this->clusterId);
points.push_back(p);
}
bool Cluster::removePoint(int pointId) {
int size = points.size();
for (int i = 0; i < size; i++)
{
if (points[i].getID() == pointId)
{
points.erase(points.begin() + i);
return true;
}
}
return false;
}
int Cluster::getId() {
return clusterId;
}
PointBGR Cluster::getPoint(int pos) {
return points[pos];
}
int Cluster::getSize() {
return points.size();
}
cv::Vec3d Cluster::getCentroidByPos(int pos) {
return centroid[pos];
}
void Cluster::setCentroidByPos(int pos, cv::Vec3d val) {
this->centroid[pos] = val;
}