-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGhostTreePopulation.cpp
More file actions
78 lines (65 loc) · 2.38 KB
/
GhostTreePopulation.cpp
File metadata and controls
78 lines (65 loc) · 2.38 KB
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
#include <stddef.h>
#include <math.h>
#include "GhostTreePopulation.h"
#include "Tree.h"
#include "DeadTree.h"
#include "SimManager.h"
#include "ModelMath.h"
/////////////////////////////////////////////////////////////////////////////
// Destructor
/////////////////////////////////////////////////////////////////////////////
clGhostTreePopulation::~clGhostTreePopulation() {
TimestepCleanup();
}
/////////////////////////////////////////////////////////////////////////////
// Constructor
/////////////////////////////////////////////////////////////////////////////
clGhostTreePopulation::clGhostTreePopulation(clSimManager * p_oSimManager) :
clWorkerBase(p_oSimManager), clPopulationBase(p_oSimManager) {
m_sNameString = "GhostTreePopulation";
mp_oTrees = NULL;
//Allowed file types
m_iNumAllowedTypes = 5;
mp_iAllowedFileTypes = new int[m_iNumAllowedTypes];
mp_iAllowedFileTypes[0] = parfile;
mp_iAllowedFileTypes[1] = tree;
mp_iAllowedFileTypes[2] = treemap;
mp_iAllowedFileTypes[3] = detailed_output_timestep;
mp_iAllowedFileTypes[4] = detailed_output;
}
///////////////////////////////////////////////////////////////////////////
// AddTree()
///////////////////////////////////////////////////////////////////////////
void clGhostTreePopulation::AddTree(clTree * p_oTree, deadCode iDeadReasonCode) {
clDeadTree *p_oDeadClone = p_oTree->MakeDeadClone();
//*p_oNextTree = NULL, *p_oTreeHolder = NULL;
p_oDeadClone->SetDeadReasonCode(iDeadReasonCode);
p_oDeadClone->mp_oNext = mp_oTrees;
mp_oTrees = p_oDeadClone;
//Go through that grid cell and insert the tree in the right place
/*if (NULL == mp_oTrees) {
mp_oTrees = p_oDeadClone;
} else {
p_oNextTree = mp_oTrees;
p_oTreeHolder = p_oNextTree->GetNext();
while (p_oTreeHolder != NULL) {
p_oNextTree = p_oTreeHolder;
p_oTreeHolder = p_oNextTree->GetNext();
}
p_oNextTree->mp_oNext = p_oDeadClone;
p_oDeadClone->mp_oNext = NULL;
}*/
}
//////////////////////////////////////////////////////////////////////////////
// TimestepCleanup()
//////////////////////////////////////////////////////////////////////////////
void clGhostTreePopulation::TimestepCleanup() {
clDeadTree * p_oTree = NULL, *p_oNextTree = NULL;
p_oTree = mp_oTrees;
while (p_oTree != NULL) {
p_oNextTree = p_oTree->GetNext();
delete p_oTree;
p_oTree = p_oNextTree;
}
mp_oTrees = NULL;
}