iLand
stampcontainer.h
Go to the documentation of this file.
1/********************************************************************************************
2** iLand - an individual based forest landscape and disturbance model
3** http://iland-model.org
4** Copyright (C) 2009- Werner Rammer, Rupert Seidl
5**
6** This program is free software: you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation, either version 3 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU General Public License
17** along with this program. If not, see <http://www.gnu.org/licenses/>.
18********************************************************************************************/
19
20#ifndef STAMPCONTAINER_H
21#define STAMPCONTAINER_H
22
23#include "stamp.h"
24#include "grid.h"
25
33{
34public:
37 void useLookup(const bool use) { m_useLookup = use; }
40 void addStamp(Stamp* stamp, const float dbh, const float hd_value, const float crown_radius);
41 void addReaderStamp(Stamp *stamp, const float crown_radius_m);
42 const Stamp* stamp(const float bhd_cm, const float height_m) const;
43 const Stamp* readerStamp(const float crown_radius_m) const;
44 int count() const { return m_stamps.count(); }
46 void save(QDataStream &out);
48 void load(QDataStream &in);
49 void load(const QString &fileName);
50
54 void attachReaderStamps(const StampContainer &source);
56 static const Grid<float> &distanceGrid() { return m_distance; }
57 void invert();
58 // description
59 const QString &description() { return m_desc; }
60 void setDescription(const QString s) { m_desc = s; }
61 QString dump();
62
63private:
64 void finalizeSetup();
65 void setupDistanceGrid(const int size);
66
67 static const int cBHDclassWidth;
68 static const int cHDclassWidth;
69 static const int cBHDclassLow;
70 static const int cHDclassLow;
71 static const int cBHDclassCount;
72 static const int cHDclassCount;
73 struct StampItem {
74 Stamp* stamp;
75 float dbh;
76 float hd;
77 float crown_radius;
78 };
79 inline void getKey(const float dbh, const float hd_value, int &dbh_class, int &hd_class) const;
80 void addStamp(Stamp* stamp, const int cls_dbh, const int cls_hd, const float crown_radius_m, const float dbh, const float hd_value);
81 int m_maxBhd;
82 bool m_useLookup; // use lookup table?
83 QList<StampItem> m_stamps;
84 Grid<Stamp*> m_lookup;
85 static Grid<float> m_distance;
86 QString m_desc;
87 QString m_fileName;
88};
89
90#endif // STAMPCONTAINER_H
Collection of Stamp for one tree species.
Definition: stampcontainer.h:33
~StampContainer()
Definition: stampcontainer.cpp:47
const Stamp * readerStamp(const float crown_radius_m) const
retrieve reader-stamp.
Definition: stampcontainer.cpp:182
const Stamp * stamp(const float bhd_cm, const float height_m) const
fast access for an individual stamp using a lookup table.
Definition: stampcontainer.cpp:198
void useLookup(const bool use)
Definition: stampcontainer.h:37
void addReaderStamp(Stamp *stamp, const float crown_radius_m)
Definition: stampcontainer.cpp:165
const QString & description()
Definition: stampcontainer.h:59
StampContainer()
Definition: stampcontainer.cpp:35
void load(QDataStream &in)
load the content of the StampContainer to the output stream (binary encoding)
Definition: stampcontainer.cpp:297
void attachReaderStamps(const StampContainer &source)
this functions attaches the appropriate reader (dep.
Definition: stampcontainer.cpp:251
static const Grid< float > & distanceGrid()
static function to retrieve distance grid. See Stamp::distanceToCenter
Definition: stampcontainer.h:56
void save(QDataStream &out)
save the content of the StampContainer to the output stream (binary encoding)
Definition: stampcontainer.cpp:352
QString dump()
Definition: stampcontainer.cpp:373
void invert()
invert stamps (value = 1. - value) (for multiplicative overlay)
Definition: stampcontainer.cpp:271
int count() const
Definition: stampcontainer.h:44
void addStamp(Stamp *stamp, const float dbh, const float hd_value, const float crown_radius)
addStamp() add a pre-allocated stamp
Definition: stampcontainer.cpp:158
void setDescription(const QString s)
Definition: stampcontainer.h:60
Stamp is the basic class for the LIP field of a individual tree.
Definition: stamp.h:32