FFSM++  1.1.0
French Forest Sector Model ++
ModelRegion.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2015 by Laboratoire d'Economie Forestière *
3  * http://ffsm-project.org *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version, given the compliance with the *
9  * exceptions listed in the file COPYING that is distribued together *
10  * with this file. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 #ifndef MODELREGION_H
23 #define MODELREGION_H
24 
25 // Core C++ headers
26 #include <string>
27 #include <vector>
28 #include <map>
29 #include <stdexcept>
30 #include <iostream>
31 #include <sstream>
32 
33 // Qt headers...
34 #include <QString>
35 
36 // regmas headers..
37 #include "BaseClass.h"
38 
39 using namespace std;
40 
41 struct forData;
42 struct prodData;
43 class Pixel;
44 
45 class ModelRegion : public BaseClass{
46 
47 public:
48  ModelRegion(ThreadManager* MTHREAD_h, int regId_h, string regSName_h, string regLName_h, int regLevel_h, int parRegId_h, bool isResidual_h); ///< Constructor
49  ~ModelRegion();
50 
51  // "set" methods..
52  void setRegId(int regId_h){regId = regId_h;};
53  void setRegSName(string regSName_h){regSName = regSName_h;};
54  void setRegLName(string regLName_h){regLName = regLName_h;};
55  void setRegLevel(int regLevel_h){regLevel = regLevel_h;};
56  void setParRegId(int parRegId_h){parRegId = parRegId_h;};
57  void setIsResidual(bool isResidual_h){isResidual = isResidual_h;};
58  void setParent(ModelRegion* parRegion_h){parRegion = parRegion_h;};
59  void setChildren(vector<ModelRegion*> children_h) {chRegions = children_h;}; ///< Childrens are all the lvel-1 region that are parts of this region.
60  void addForData(forData* data_h){forDataVector.push_back(data_h);};
61  void addProdData(prodData* data_h){prodDataVector.push_back(data_h);};
62  void setMyPixels(); ///< It sets a double link pixels <--> region
63  void swap(const int& swap_what);
64 
65  // "get" methods..
66  int getRegId() const {return regId;};
67  string getRegSName() const {return regSName;};
68  string getRegLName() const {return regLName;};
69  int getRegLevel() const {return regLevel;};
70  int getParRegId() const {return parRegId;};
71  bool getIsResidual() const {return isResidual;};
72  ModelRegion* getParent(){return parRegion;}; ///< Returns a pointer to the parent regions
73  vector<ModelRegion*>getChildren(bool excludeResidual = true); ///< Return a vector of pointers to the direct child regions
74  vector<ModelRegion*>getSiblings(bool excludeResidual = true); ///< Return a vector of pointers to the siblings regions
75  double getVolumes();
76  vector<double> getVolumes(int fType_h);
77  double getValue(string layerName, int op=OP_SUM); ///< return the values of its own pixels for the specified layer. Possible operations: OP_SUM or OP_AVG
78  vector < vector <double> > getVolumes(int fType_h, string dClass_h);
79  double getArea(const string &fType_h, const string &dClass_h); ///< Get area by ft and dc (from pixel->area matrix)
80  double getArea(const string &fType_h); ///< Get area by ft (from pixel->area matrix)
81  double getArea(const int& ft_pos, const int& dc_pos); ///< Get area by ft and dc positions (from pixel->area matrix)
82  double getArea(const int& ft_pos); ///< Get area by ft position (from pixel->area matrix)
83  double getArea(); ///< Get whole forest area (from pixel->area matrix)
84 
85  int getNChildren(bool excludeResidual = true);
86  vector<Pixel*> getMyPixels(){return myPixels;};
87 
88  vector<double> inResByAnyCombination; ///< Vector of inventory resource for each possible combination of primary products. This store both alive timber and death one.
89  //vector<double> inResByAnyCombination_deathTimber; ///< Vector of inventory resource for each possible combination of primary products. This store only death timber.
90 
91 private:
92  int regId; ///< Regional unique ID
93  string regSName; ///< A short name of the region
94  string regLName; ///< Region long name;
95  int regLevel; ///< The level of the region. 1: country, 2: regions
96  int parRegId; ///< Id of the parent region;
97  bool isResidual; ///< A flag if this region should be explicitelly modelled or it is just a residual
98  ModelRegion* parRegion; ///< Pointer to the parent region
99  vector<ModelRegion*> chRegions; ///< Vector of level-1 children regions
100  vector<forData*> forDataVector; ///< Vector of pointers of forestry data (owned by ModelData)
101  vector<prodData*> prodDataVector; ///< Vector of pointers of product data (owned by ModelData)
102  vector<Pixel*> myPixels; ///< Vector of pixels for this region
103 
104 
105 
106 };
107 
108 #endif // REGION_H
void setRegLevel(int regLevel_h)
Definition: ModelRegion.h:55
void setRegLName(string regLName_h)
Definition: ModelRegion.h:54
int getParRegId() const
Definition: ModelRegion.h:70
int parRegId
Id of the parent region;.
Definition: ModelRegion.h:96
int regLevel
The level of the region. 1: country, 2: regions.
Definition: ModelRegion.h:95
int getRegId() const
Definition: ModelRegion.h:66
void setParent(ModelRegion *parRegion_h)
Definition: ModelRegion.h:58
STL namespace.
vector< forData * > forDataVector
Vector of pointers of forestry data (owned by ModelData)
Definition: ModelRegion.h:100
Thread manager. Responsable to manage the main thread and "speak" with the GUI.
Definition: ThreadManager.h:65
Perform a SUM operation.
Definition: BaseClass.h:77
void setChildren(vector< ModelRegion * > children_h)
Definition: ModelRegion.h:59
vector< ModelRegion * > chRegions
Vector of level-1 children regions.
Definition: ModelRegion.h:99
vector< double > inResByAnyCombination
Vector of inventory resource for each possible combination of primary products. This store both alive...
Definition: ModelRegion.h:86
void addProdData(prodData *data_h)
Definition: ModelRegion.h:61
void addForData(forData *data_h)
Childrens are all the lvel-1 region that are parts of this region.
Definition: ModelRegion.h:60
bool isResidual
A flag if this region should be explicitelly modelled or it is just a residual.
Definition: ModelRegion.h:97
int regId
Regional unique ID.
Definition: ModelRegion.h:92
Pixel-level class.
Definition: Pixel.h:47
void setRegSName(string regSName_h)
Definition: ModelRegion.h:53
int getRegLevel() const
Definition: ModelRegion.h:69
vector< prodData * > prodDataVector
Vector of pointers of product data (owned by ModelData)
Definition: ModelRegion.h:101
Base class for the regmas application.
Definition: BaseClass.h:239
vector< Pixel * > myPixels
Vector of pixels for this region.
Definition: ModelRegion.h:102
bool getIsResidual() const
Definition: ModelRegion.h:71
void setParRegId(int parRegId_h)
Definition: ModelRegion.h:56
string getRegSName() const
Definition: ModelRegion.h:67
ModelRegion * getParent()
Definition: ModelRegion.h:72
ModelRegion * parRegion
Pointer to the parent region.
Definition: ModelRegion.h:98
string regLName
Region long name;.
Definition: ModelRegion.h:94
This file is the header of BaseClass and it is included by ALL compiled code.
void setRegId(int regId_h)
Definition: ModelRegion.h:52
string regSName
A short name of the region.
Definition: ModelRegion.h:93
void setIsResidual(bool isResidual_h)
Definition: ModelRegion.h:57
string getRegLName() const
Definition: ModelRegion.h:68