-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMap.cc
111 lines (91 loc) · 1.84 KB
/
Map.cc
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
// Copyright 2009 Isis Innovation Limited
#include "Map.h"
#include "MapPoint.h"
#include "KeyFrame.h"
#include "Game.h"
namespace PTAMM {
/**
* Constructor. Calls reset and sets the map ID
*/
Map::Map()
: pGame( NULL )
{
static int nMapCounter = 0;
mnMapNum = nMapCounter++;
Reset();
}
/**
* Destructor
*/
Map::~Map()
{
Reset();
}
/**
* Reset the map
*/
void Map::Reset()
{
//clear map points
for(unsigned int i = 0; i < vpPoints.size(); i++) {
delete vpPoints.at(i);
}
vpPoints.clear();
//clear trash points
EmptyTrash();
//clear keyframes
for(unsigned int i = 0; i < vpKeyFrames.size(); i++) {
delete vpKeyFrames.at(i);
}
vpKeyFrames.clear();
bGood = false; //no longer good
bEditLocked = false; //make editable
sSaveFile = ""; //not associated with a file on disk
//clear queued keyframes.
for(unsigned int i = 0; i < vpKeyFrameQueue.size(); i++) {
delete vpKeyFrameQueue.at(i);
}
vpKeyFrameQueue.clear();
//clear the failure queue
vFailureQueue.clear();
//clear queued new observations.
while(!qNewQueue.empty())
{
// delete qNewQueue.front();
qNewQueue.pop_front();
}
//remove any associated game
if( pGame != NULL ) {
delete pGame;
pGame = NULL;
}
bBundleConverged_Full = true;
bBundleConverged_Recent = true;
// mnMapNum is not reset as this is constant for a map.
}
/**
* Move any points marked as bad to the trash
*/
void Map::MoveBadPointsToTrash()
{
int nBad = 0;
for(int i = vpPoints.size()-1; i>=0; i--)
{
if(vpPoints[i]->bBad)
{
vpPointsTrash.push_back(vpPoints[i]);
vpPoints.erase(vpPoints.begin() + i);
nBad++;
}
};
}
/**
* Delete of the points in the trash
*/
void Map::EmptyTrash()
{
for(unsigned int i=0; i<vpPointsTrash.size(); i++)
delete vpPointsTrash[i];
vpPointsTrash.clear();
}
}