Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
17 | Werner | 1 | #ifndef LIGHTROOM_H |
2 | #define LIGHTROOM_H |
||
3 | |||
85 | Werner | 4 | #include "grid.h" |
5 | #include "solarradiation.h" |
||
6 | #include "hemigrid.h" |
||
7 | #include "expression.h" |
||
23 | Werner | 8 | |
9 | class LightRoomObject |
||
10 | { |
||
11 | public: |
||
12 | LightRoomObject(): m_radiusFormula(0) {} |
||
13 | ~LightRoomObject(); |
||
14 | /** Test if the ray starting at "p" hits the object. |
||
15 | the ray has direction azimuth/elevation and starts from the position denoted by p_x, p_y and p_z |
||
31 | Werner | 16 | @return 1: object is hit, 0: object is missed, -1: p is inside the object.*/ |
17 | int hittest(const double p_x, const double p_y, const double p_z, |
||
23 | Werner | 18 | const double azimuth_rad, const double elevation_rad); |
19 | /** sets up a tree as the obstacle. |
||
20 | @param height treehight in meter |
||
21 | @param crownheight height of the start of crown (above ground) in meter |
||
22 | @param formula (as string representation) that yields the radius as f(relativeheight). |
||
23 | the variable of the formula is 0 for ground 1 for tree top. */ |
||
24 | void setuptree(const double height, const double crownheight, const QString &formula); |
||
25 | Werner | 25 | /// returns true if there is no way that a ray hits the object starting from p. |
26 | bool noHitGuaranteed(const double p_x, const double p_y, const double p_z); |
||
772 | werner | 27 | double maxHeight() const { return m_height; } |
28 | double maxRadius() const { return m_baseradius; } |
||
23 | Werner | 29 | private: |
24 | Werner | 30 | Expression *m_radiusFormula; ///< formula for calculation of crown widht as f(relative_height) |
23 | Werner | 31 | double m_baseradius; ///< maximum radius of the crown (at the bottom of the crown) [m] |
32 | double m_height; ///< treehight [m] |
||
33 | double m_crownheight; ///< height of the beginning of the living crown [m] |
||
27 | Werner | 34 | QVector<double> m_treeHeights; |
23 | Werner | 35 | }; |
36 | |||
17 | Werner | 37 | /** virtual room to do some light-experiments. |
38 | The basic use of this class is to derive the size/pattern of the light-influence FON for a single tree. |
||
39 | It uses SolarRadiation for the calculation of global radiation and HemiGrid to calculate and store the results. |
||
21 | Werner | 40 | This calculation is done for each node of a 3D space and afterwards accumulated into a 2D pattern. */ |
17 | Werner | 41 | class LightRoom |
42 | { |
||
43 | public: |
||
44 | LightRoom(); |
||
25 | Werner | 45 | ~LightRoom() { if (m_roomObject) delete m_roomObject; } |
17 | Werner | 46 | /// setup the spatial grid. |
32 | Werner | 47 | void setup(const double dimx, const double dimy, const double dimz, |
18 | Werner | 48 | const double cellsize, const double hemigridsize, |
49 | const double latitude=48., const double diffus_frac=0.5); |
||
25 | Werner | 50 | void setLightRoomObject(LightRoomObject *lro) { if (m_roomObject) delete m_roomObject; m_roomObject = lro; } |
404 | werner | 51 | void setAggregationMode(const int mode ) { m_aggregationMode = mode; } |
24 | Werner | 52 | /// calculate a full hemiview image from given point |
27 | Werner | 53 | double calculateGridAtPoint(const double p_x, const double p_y, const double p_z, bool fillShadowGrid=true); |
25 | Werner | 54 | /// calculate a hemigrid for each node of the grid (store results in m_3dvalues). |
31 | Werner | 55 | /// @return fraction of "blocked" radiation [0..1]. -1: point inside the object |
25 | Werner | 56 | void calculateFullGrid(); |
57 | /// access to the hemigrid |
||
43 | Werner | 58 | const HemiGrid &shadowGrid() const { return m_shadowGrid; } |
59 | const HemiGrid &solarGrid() const { return m_solarGrid; } |
||
60 | const FloatGrid &result() const { return m_2dvalues; } |
||
772 | werner | 61 | double centerValue() const { return m_centervalue; } |
43 | Werner | 62 | |
17 | Werner | 63 | private: |
27 | Werner | 64 | //Grid< QVector<float> > m_3dvalues; ///< storage for resulting 3d light values |
17 | Werner | 65 | FloatGrid m_2dvalues; ///< resulting 2d pattern (derived from 3dvalues) |
66 | int m_countX; ///< size of the grid in x-direction |
||
67 | int m_countY; |
||
68 | int m_countZ; |
||
69 | double m_cellsize; ///< length of the side of one cell (equal for all 3 directions) |
||
29 | Werner | 70 | double m_solarrad_factor; ///< multiplier accounting for the difference of total radiation and the used part of the sky (45°) |
18 | Werner | 71 | HemiGrid m_solarGrid; ///< grid used for solar radiation (direct + diffus) |
72 | HemiGrid m_shadowGrid; ///< grid used for shadow calculations |
||
43 | Werner | 73 | double m_centervalue; ///< value (shadow*height) of the tree center (relative) [-] |
404 | werner | 74 | int m_aggregationMode; ///< aggregation mod |
43 | Werner | 75 | |
24 | Werner | 76 | LightRoomObject *m_roomObject; |
17 | Werner | 77 | }; |
78 | |||
79 | #endif // LIGHTROOM_H |