-
Notifications
You must be signed in to change notification settings - Fork 3
/
cleaner.cpp
230 lines (208 loc) · 5.19 KB
/
cleaner.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
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#include "cleaner.h"
#include <iostream>
using namespace std;
bool Cleaner::releaseScales(vector<Image*> &scales)
{
vector<Image *>::iterator it;
Image *tempim = NULL;
for(it = scales.begin(); it != scales.end(); it++)
{
tempim = *it;
delete tempim;
}
scales.clear();
return true;
}
bool Cleaner::releaseBoards(vector<Board*> &scales)
{
vector<Board *>::iterator it;
Board *tempim = NULL;
for(it = scales.begin(); it != scales.end(); it++)
{
tempim = *it;
delete tempim;
}
scales.clear();
return true;
}
bool Cleaner::releaseOctaves(vector<vector<Image*> > &octaves)
{
vector<Image *>::iterator it;
Image *tempim;
for (unsigned i = 0; i < octaves.size(); i++)
{
for(it=octaves[i].begin(); it!=octaves[i].end(); it++)
{
tempim = *it;
delete tempim;
}
octaves[i].clear();
}
octaves.clear();
return true;
}
bool Cleaner::releaseOctaves(vector<vector<ImageSymmMat*> > &octaves)
{
vector<ImageSymmMat *>::iterator it;
ImageSymmMat *tempim;
for (unsigned i = 0; i < octaves.size(); i++)
{
for(it = octaves[i].begin(); it!=octaves[i].end(); it++)
{
tempim = *it;
delete tempim;
}
octaves[i].clear();
}
octaves.clear();
return true;
}
bool Cleaner::clearParas(map<string,const char*> ¶s)
{
map<string, const char*>::iterator mit;
string crnt_str;
for(mit = paras.begin(); mit != paras.end(); mit++)
{
crnt_str = mit->first;
crnt_str.clear();
const char *val = mit->second;
delete [] val;
}
paras.clear();
return true;
}
void Cleaner::clearCurves(vector<HCPoint*> &curves)
{
vector<HCPoint*>::iterator it;
CPoint *crnt_pt = NULL, *nxt_pt;
HCPoint *crnt_head = NULL;
/**1. calc curvature**/
for(it = curves.begin(); it != curves.end(); it++)
{
crnt_head = *it;
crnt_pt = crnt_head->next;
while(crnt_pt != NULL)
{
nxt_pt = crnt_pt->next;
delete crnt_pt;
crnt_pt = nxt_pt;
}
delete crnt_head;
}
curves.clear();
return ;
}
void Cleaner::clearSegment(vector<LPoint*> *segment)
{
vector<LPoint*>::iterator vit;
LPoint* crnt_pt = NULL;
for(vit = segment->begin(); vit != segment->end(); vit++)
{
crnt_pt = *vit;
delete crnt_pt;
}
segment->clear();
return ;
}
void Cleaner::clearAdjTab(map<unsigned int, list<unsigned int>*> &AdjTable)
{
map<unsigned int, list<unsigned int>*>::iterator mit;
list<unsigned int>* crnt_lst;
list<unsigned int>::iterator lit;
for(mit = AdjTable.begin(); mit != AdjTable.end(); mit++)
{
crnt_lst = mit->second;
crnt_lst->clear();
delete crnt_lst;
}
AdjTable.clear();
return ;
}
void Cleaner::clearSegTab(map<unsigned int, map<unsigned int, vector<LPoint*>* >* > &SegTable)
{
LPoint* crnt_pt;
map<unsigned int, vector<LPoint*>* >* crnt_map;
vector<LPoint*>* crnt_seg;
vector<LPoint*>::iterator it;
map<unsigned int, map<unsigned int, vector<LPoint*>* >* >::iterator mit;
map<unsigned int, vector<LPoint*>* >::iterator cmit;
for(mit = SegTable.begin(); mit != SegTable.end(); mit++)
{
crnt_map = mit->second;
for(cmit = crnt_map->begin(); cmit != crnt_map->end(); cmit++)
{
crnt_seg = cmit->second;
for(it = crnt_seg->begin(); it != crnt_seg->end(); it++)
{
crnt_pt = *it;
delete crnt_pt;
}
crnt_seg->clear();
}
crnt_map->clear();
}
SegTable.clear();
}
void Cleaner::clearDistMap(map<unsigned int, map<unsigned int, float >* > &distMap)
{
map<unsigned int, map<unsigned int, float >* >::iterator mit;
map<unsigned int, float > *DMap;
for(mit = distMap.begin(); mit != distMap.end(); mit++)
{
DMap = mit->second;
DMap->clear();
delete DMap;
}
distMap.clear();
}
void Cleaner::clearKeyPoint(vector<KeyPoint*> &mykps)
{
vector<KeyPoint*>::iterator itkp;
KeyPoint* crntkp;
for(itkp = mykps.begin(); itkp != mykps.end(); itkp++)
{
crntkp = *itkp;
delete crntkp;
}
mykps.clear();
return ;
}
void Cleaner::clearRangeMap(map<int, vector<int> *> &rangeTab)
{
map<int, vector<int> *>::iterator mit;
vector<int> *crnt_pts;
for(mit = rangeTab.begin(); mit != rangeTab.end(); mit++)
{
crnt_pts = mit->second;
crnt_pts->clear();
delete crnt_pts;
}
return ;
}
void Cleaner::clearXPoint(vector<XPoint*> &segment)
{
vector<XPoint*>::iterator vit;
XPoint *crnt_pt;
for(vit = segment.begin(); vit != segment.end(); vit++)
{
crnt_pt = *vit;
delete crnt_pt;
}
segment.clear();
}
void Cleaner::clear2DArray(vector<vector<float> > &array2D)
{
vector<vector<float> >::iterator vit;
for(vit = array2D.begin(); vit != array2D.end(); vit++)
{
vector<float> array = *vit;
array.clear();
}
array2D.clear();
return ;
}
void Cleaner::clear1DArray(vector<float> &array1D)
{
array1D.clear();
return ;
}