FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTevent.hpp
Go to the documentation of this file.
1/*
2Copyright (c) 2019 Gouvernement du Québec
3
4SPDX-License-Identifier: LiLiQ-R-1.1
5License-Filename: LICENSES/EN/LiLiQ-R11unicode.txt
6*/
7
8#ifndef FMTEVENT_H_INCLUDED
9#define FMTEVENT_H_INCLUDED
10
11#include "FMTcoordinate.hpp"
12#include <random>
13#include <limits>
14#include <iterator>
15#include <boost/serialization/serialization.hpp>
16#include <boost/serialization/nvp.hpp>
17#include <boost/serialization/set.hpp>
18
19namespace Spatial
20{
21class FMTeventrelation;
22// DocString: FMTevent
28 {
29 friend class boost::serialization::access;
30 template<class Archive>
31 void serialize(Archive& ar, const unsigned int version)
32 {
33 //ar & BOOST_SERIALIZATION_NVP(ignition);
34 //ar & BOOST_SERIALIZATION_NVP(active);
35 ar & BOOST_SERIALIZATION_NVP(action_id);
36 ar & BOOST_SERIALIZATION_NVP(period);
37 ar & BOOST_SERIALIZATION_NVP(elements);
38 }
39 protected:
40 // DocString: FMTevent::ignition
44 //FMTcoordinate ignition;
45 // DocString: FMTevent::active
49 //std::vector<FMTcoordinate>active;
50 // DocString: FMTsaevent::action_id
55 // DocString: FMTsaevent::period
59 int period;
60 public:
61 // DocString: FMTevent::midposition()
65 inline std::set<FMTcoordinate>::const_iterator midposition() const
66 {
67 std::set<FMTcoordinate>::const_iterator it = elements.begin();
68 if (elements.size() > 1)
69 {
70 const size_t midlocation = (elements.size() / 2);
71 std::advance(it, midlocation);
72 }
73 return it;
74 }
75 // DocString: FMTevent::elements
79 std::set<FMTcoordinate>elements;
80 // DocString: ~FMTevent()
84 virtual ~FMTevent() = default;
85 // DocString: FMTevent()
90 // DocString: FMTsaevent(const FMTcoordinate&,const int&,const int&)
94 FMTevent(const FMTcoordinate& location,const int& laction_id,const int& lperiod);
95 // DocString: FMTevent(const FMTevent&)
99 FMTevent(const FMTevent& rhs);
100 // DocString: FMTevent::operator=
105 // DocString: FMTevent::empty()
109 bool empty() const {return elements.empty();}
110 // DocString: FMTevent::size()
114 size_t size() const {return elements.size();}
115 // DocString: FMTevent::hash()
119 size_t hash() const;// {return boost::hash<Spatial::FMTcoordinate>()(ignition); }
120 // DocString: FMTevent::getrelation(const FMTevent&)
125 // DocString: FMTevent::operator==(const FMTevent&)
129 virtual bool operator==(const FMTevent& rhs) const;
130 // DocString: FMTevent::operator!=(const FMTevent&)
134 bool operator!=(const FMTevent& rhs) const;
135 // DocString: FMTevent::operator<(const FMTevent&)
139 virtual bool operator<(const FMTevent& rhs) const;
140 // DocString: FMTevent::perimeter()
145 size_t perimeter() const;
146 // DocString: FMTevent::height()
150 size_t height() const;
151 // DocString: FMTevent::width()
155 size_t width() const;
156 // DocString: FMTevent::averagecentroid()
161 // DocString: FMTevent::getstatsheader()
165 static std::string getstatsheader();
166 // DocString: FMTevent::getstats()
170 std::string getstats() const;
171 // DocString: FMTevent::erase(const FMTcoordinate&)
175 virtual void erase(const FMTcoordinate& newlocation);
176 // DocString: FMTevent::merge(const FMTevent& event)
180 virtual void merge(const FMTevent& event);
181 // DocString: FMTevent::insert(const FMTcoordinate&)
185 virtual void insert(const FMTcoordinate& newlocation);
186 // DocString: FMTevent::setactionid(const int&)
190 void setactionid(const int& laction_id){action_id=laction_id;}
191 // DocString: FMTevent::setperiod(const int&)
195 void setperiod(const int& lperiod){period=lperiod;}
196 // DocString: FMTevent::getactionid()
200 inline const int& getactionid() const {return action_id;}
201 // DocString: FMTevent::getperiod()
205 inline const int& getperiod() const {return period;}
206 // DocString: FMTevent::ignit(const FMTspatialaction&, const FMTcoordinate&, const int&, const int&)
210 virtual std::vector<std::set<FMTcoordinate>::const_iterator> ignit(const size_t& eventmaximalsize,const std::set<FMTcoordinate>::const_iterator& ignit, const int& laction_id, const int& lperiod);
211 // DocString: FMTevent::spread(const size_t& eventminimalsize,const size_t& eventmaximalsize,const size_t& neighboringsize,const std::set<FMTcoordinate>& territory, std::vector<std::set<FMTcoordinate>::const_iterator> active)
215 virtual bool spread(const size_t& eventminimalsize,const size_t& eventmaximalsize,
216 const size_t& neighboringsize,const std::set<FMTcoordinate>& territory, std::vector<std::set<FMTcoordinate>::const_iterator> active);
217 // DocString: FMTevent::distance(const FMTevent&)
221 double distance(const FMTevent& rhs) const;
222 // DocString: FMTevent::within(unsigned int, const FMTevent&)
226 template<typename T>
227 bool within(const T& dist, const FMTevent& rhs) const;
228 // DocString: FMTevent::withinc(unsigned int, const FMTcoordinate&)
232 template<typename T>
233 bool within(const T& dist, const FMTcoordinate& location) const;
234 // DocString: FMTevent::contain(const FMTcoordinate&)
238 bool contain(const FMTcoordinate& coord)const;
239 // DocString: FMTevent::potentialysplittedevent(const FMTcoordinate&)
244 bool potentialysplitevent(const FMTcoordinate& coord) const;
245 // DocString: FMTevent::splitevent(const unsigned int&, std::vector<FMTsaevent>&)
250 bool splitevent(const unsigned int& ldistance, std::vector<FMTevent>& splittedevents) const;
251 // DocString: FMTevent::getterritory
255 std::set<FMTcoordinate>getterritory(const size_t& distance) const;
256 // DocString: FMTevent::getborders
260 std::vector<std::set<FMTcoordinate>::const_iterator>getborders() const;
261 // DocString: FMTevent::getenveloppe
269 std::vector<FMTcoordinate>getenveloppe() const;
270 // DocString: FMTevent::getclosescoordinate
275 std::set<FMTcoordinate>::const_iterator& thiscoordinate,
276 std::set<FMTcoordinate>::const_iterator& rhscoordinate) const;
277 };
278
279}
280
281namespace boost {
282
283 template <>
284 struct hash<Spatial::FMTevent>
285 {
286 std::size_t operator()(const Spatial::FMTevent& event) const
287 {
288
289 return (event.hash());
290 }
291 };
292
293}
294#endif // FMTEVENT_H_INCLUDED
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTcoordinate.hpp:25
Definition: FMTevent.hpp:28
FMTeventrelation getrelation(const FMTevent &rhs) const
std::string getstats() const
void setactionid(const int &laction_id)
Definition: FMTevent.hpp:190
virtual bool operator<(const FMTevent &rhs) const
const int & getperiod() const
Definition: FMTevent.hpp:205
size_t size() const
Definition: FMTevent.hpp:114
bool within(const T &dist, const FMTcoordinate &location) const
FMTevent & operator=(const FMTevent &rhs)
void getclosescoordinates(const FMTevent &rhs, std::set< FMTcoordinate >::const_iterator &thiscoordinate, std::set< FMTcoordinate >::const_iterator &rhscoordinate) const
size_t hash() const
size_t height() const
virtual void insert(const FMTcoordinate &newlocation)
bool empty() const
Definition: FMTevent.hpp:109
virtual ~FMTevent()=default
FMTevent(const FMTevent &rhs)
virtual std::vector< std::set< FMTcoordinate >::const_iterator > ignit(const size_t &eventmaximalsize, const std::set< FMTcoordinate >::const_iterator &ignit, const int &laction_id, const int &lperiod)
FMTcoordinate averagecentroid() const
bool operator!=(const FMTevent &rhs) const
size_t perimeter() const
virtual bool spread(const size_t &eventminimalsize, const size_t &eventmaximalsize, const size_t &neighboringsize, const std::set< FMTcoordinate > &territory, std::vector< std::set< FMTcoordinate >::const_iterator > active)
int period
Definition: FMTevent.hpp:59
std::vector< FMTcoordinate > getenveloppe() const
bool potentialysplitevent(const FMTcoordinate &coord) const
virtual void erase(const FMTcoordinate &newlocation)
int action_id
Definition: FMTevent.hpp:54
std::set< FMTcoordinate > elements
Definition: FMTevent.hpp:79
static std::string getstatsheader()
virtual bool operator==(const FMTevent &rhs) const
double distance(const FMTevent &rhs) const
bool contain(const FMTcoordinate &coord) const
void setperiod(const int &lperiod)
Definition: FMTevent.hpp:195
std::vector< std::set< FMTcoordinate >::const_iterator > getborders() const
std::set< FMTcoordinate > getterritory(const size_t &distance) const
const int & getactionid() const
Definition: FMTevent.hpp:200
size_t width() const
FMTevent(const FMTcoordinate &location, const int &laction_id, const int &lperiod)
std::set< FMTcoordinate >::const_iterator midposition() const
Definition: FMTevent.hpp:65
bool within(const T &dist, const FMTevent &rhs) const
bool splitevent(const unsigned int &ldistance, std::vector< FMTevent > &splittedevents) const
virtual void merge(const FMTevent &event)
Definition: FMTeventrelation.hpp:22
The spatial namespace provides classes for spatialy explicit simulation/optimization based on raster ...
Definition: FMTareaparser.hpp:36
Definition: FMTaction.hpp:364
std::size_t operator()(const Spatial::FMTevent &event) const
Definition: FMTevent.hpp:286