Rev 51 | Rev 61 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 51 | Rev 58 | ||
---|---|---|---|
1 | Redirecting to URL 'https://iland.boku.ac.at/svn/iland/tags/release_1.0/src/core/stampcontainer.h': |
1 | Redirecting to URL 'https://iland.boku.ac.at/svn/iland/tags/release_1.0/src/core/stampcontainer.h': |
2 | #ifndef STAMPCONTAINER_H
|
2 | #ifndef STAMPCONTAINER_H
|
3 | #define STAMPCONTAINER_H
|
3 | #define STAMPCONTAINER_H
|
4 | 4 | ||
5 | #include "stamp.h"
|
5 | #include "stamp.h"
|
6 | #include "grid.h"
|
6 | #include "grid.h"
|
7 | 7 | ||
8 | /** Collection of @class Stamp for one tree species.
|
8 | /** Collection of @class Stamp for one tree species.
|
9 | Per species several stamps are stored (different BHD, different HD relations). This class
|
9 | Per species several stamps are stored (different BHD, different HD relations). This class
|
10 | encapsulates storage and access to these stamps. The design goal is to deliver high
|
10 | encapsulates storage and access to these stamps. The design goal is to deliver high
|
11 | access speeds for the "stamp()" method.
|
11 | access speeds for the "stamp()" method.
|
12 | Use getStamp(bhd, hd) or getStamp(bhd, height) to access. */
|
12 | Use getStamp(bhd, hd) or getStamp(bhd, height) to access. */
|
13 | class StampContainer
|
13 | class StampContainer
|
14 | {
|
14 | {
|
15 | public: |
15 | public: |
16 | StampContainer(); |
16 | StampContainer(); |
17 | ~StampContainer(); |
17 | ~StampContainer(); |
18 | void useLookup(const bool use) { m_useLookup = use; } |
18 | void useLookup(const bool use) { m_useLookup = use; } |
19 | /// addStamp() add a pre-allocated stamp @param stamp to internal collection. Caller must allocate stamp on the heap,
|
19 | /// addStamp() add a pre-allocated stamp @param stamp to internal collection. Caller must allocate stamp on the heap,
|
20 | /// freeing is done by this class.
|
20 | /// freeing is done by this class.
|
21 | int addStamp(Stamp* stamp, const float bhd, const float hd_value, const float crown_radius_m); |
21 | int addStamp(Stamp* stamp, const float bhd, const float hd_value, const float crown_radius_m); |
22 | int addReaderStamp(Stamp *stamp, const float crown_radius_m); |
22 | int addReaderStamp(Stamp *stamp, const float crown_radius_m); |
23 | const Stamp* stamp(const float bhd_cm, const float height_m) const; |
23 | const Stamp* stamp(const float bhd_cm, const float height_m) const; |
24 | const Stamp* readerStamp(const float crown_radius_m) const; ///< retrieve reader-stamp. @param radius of crown in m. @return the appropriate stamp or NULL if not found. |
24 | const Stamp* readerStamp(const float crown_radius_m) const; ///< retrieve reader-stamp. @param radius of crown in m. @return the appropriate stamp or NULL if not found. |
25 | const int count() const { return m_stamps.count(); } |
25 | const int count() const { return m_stamps.count(); } |
26 | /// save the content of the StampContainer to the output stream (binary encoding)
|
26 | /// save the content of the StampContainer to the output stream (binary encoding)
|
27 | void save(QDataStream &out); |
27 | void save(QDataStream &out); |
28 | /// load the content of the StampContainer to the output stream (binary encoding)
|
28 | /// load the content of the StampContainer to the output stream (binary encoding)
|
29 | void load(QDataStream &in); |
29 | void load(QDataStream &in); |
30 | 30 | ||
31 | /** factory creation function for stamps of different size.
|
31 | /** factory creation function for stamps of different size.
|
32 | newStamp() creates new Stamp-Objects on the heap with a given type (see @enum Stamp::StampType).*/
|
32 | newStamp() creates new Stamp-Objects on the heap with a given type (see @enum Stamp::StampType).*/
|
33 | static Stamp* newStamp(const Stamp::StampType type); |
33 | static Stamp* newStamp(const Stamp::StampType type); |
34 | /** this functions attaches the appropriate reader (dep. on crown radius) to each stamp of the container.
|
34 | /** this functions attaches the appropriate reader (dep. on crown radius) to each stamp of the container.
|
35 | The reader-stamp is returned by a call to the reader()-function of the Stamp itself.
|
35 | The reader-stamp is returned by a call to the reader()-function of the Stamp itself.
|
36 | @param Container holding the reader stamps.*/
|
36 | @param Container holding the reader stamps.*/
|
37 | void attachReaderStamps(const StampContainer &source); |
37 | void attachReaderStamps(const StampContainer &source); |
38 | void invert(); ///< invert stamps (value = 1. - value) (for multiplicative overlay) |
38 | void invert(); ///< invert stamps (value = 1. - value) (for multiplicative overlay) |
39 | 39 | ||
40 | QString dump(); |
40 | QString dump(); |
41 | 41 | ||
42 | private: |
42 | private: |
- | 43 | void finalizeSetup(); ///< complete lookup-grid by filling up zero values |
|
- | 44 | ||
43 | static const int cBHDclassWidth; |
45 | static const int cBHDclassWidth; |
44 | static const int cHDclassWidth; |
46 | static const int cHDclassWidth; |
45 | static const int cBHDclassLow; ///< bhd classes start with 2: class 0 = 2..6, class1 = 6..10 |
47 | static const int cBHDclassLow; ///< bhd classes start with 2: class 0 = 2..6, class1 = 6..10 |
46 | static const int cHDclassLow; ///< hd classes offset is 40: class 0 = 40-50, class 1 = 50-60 |
48 | static const int cHDclassLow; ///< hd classes offset is 40: class 0 = 40-50, class 1 = 50-60 |
47 | static const int cBHDclassCount; ///< class count, 50: highest class = 50*4 +- 2 = 198 - 202 |
49 | static const int cBHDclassCount; ///< class count, 50: highest class = 50*4 +- 2 = 198 - 202 |
48 | static const int cHDclassCount; ///< class count. highest class: 140-150 |
50 | static const int cHDclassCount; ///< class count. highest class: 140-150 |
49 | struct StampItem { |
51 | struct StampItem { |
50 | Stamp* stamp; |
52 | Stamp* stamp; |
51 | float bhd; |
53 | float bhd; |
52 | float hd; |
54 | float hd; |
53 | float crown_radius; |
55 | float crown_radius; |
54 | }; |
56 | }; |
55 | inline int getKey(const float bhd, const float hd_value); |
57 | inline int getKey(const float bhd, const float hd_value); |
56 | int m_maxBhd; |
58 | int m_maxBhd; |
57 | bool m_useLookup; // use lookup table? |
59 | bool m_useLookup; // use lookup table? |
58 | QList<StampItem> m_stamps; |
60 | QList<StampItem> m_stamps; |
59 | Grid<Stamp*> m_lookup; |
61 | Grid<Stamp*> m_lookup; |
60 | }; |
62 | }; |
61 | 63 | ||
62 | #endif // STAMPCONTAINER_H
|
64 | #endif // STAMPCONTAINER_H
|
63 | 65 |