-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cell.cpp
96 lines (79 loc) · 1.64 KB
/
Cell.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
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
#include "Cell.h"
using namespace std;
Cell::Cell()
{
cell_x = 0;
cell_y = 0;
mbb = MBB(0, 0, 0, 0);
subTraNum = 0;
subTraPtr = NULL;
}
Cell::Cell(int x, int y, const MBB& val_mbb) {
cell_x = x;
cell_y = y;
mbb = val_mbb;
subTraNum = 0;
subTraPtr = NULL;
}
bool Cell::initial(int x, int y, const MBB& val_mbb) {
cell_x = x;
cell_y = y;
mbb = val_mbb;
anchorPointX = int((mbb.xmin + mbb.xmax) / 2 * 1000000);
anchorPointY = int((mbb.ymin + mbb.ymax) / 2 * 1000000);
subTraNum = 0;
totalPointNum = 0;
subTraEntry.next = NULL;
subTraPtr = &subTraEntry;
subTraTable = NULL;
return true;
}
// 负责加入子轨迹
int Cell::addSubTra(int traID, int startIdx, int endIdx, int numOfPoints)
{
subTra* newSubTra = (subTra*)malloc(sizeof(subTra));//记得free!!!
if (newSubTra == NULL)
return 1;
newSubTra->numOfPoint = numOfPoints;
newSubTra->traID = traID;
newSubTra->startpID = startIdx;
newSubTra->endpID = endIdx;
newSubTra->next = NULL;
subTraPtr->next = newSubTra;
subTraPtr = newSubTra;
subTraNum++;
return 0;
}
int Cell::buildSubTraTable()
{
int countPoints = 0;
subTraTable = (subTra*)malloc(sizeof(subTra)*subTraNum);
if (subTraTable == NULL)
return 1;
subTra* ptr = subTraEntry.next;
subTra* nextptr;
int idx = 0;
while (ptr!= NULL) {
nextptr = ptr->next;
subTraTable[idx] = (*ptr);
countPoints += (*ptr).numOfPoint;
free(ptr);
ptr = nextptr;
idx++;
}
if (idx != subTraNum) //debug info
{
cout << idx << "vs" << endl;
getchar();
}
// throw("error in cell buildSubTraTable");
this->totalPointNum = countPoints;
return 0;
}
int Cell::writeCellToFile(string fileName)
{
return 0;
}
Cell::~Cell()
{
}