FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTmaskfilter.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 FMTMASKFILTER_H_INCLUDED
9#define FMTMASKFILTER_H_INCLUDED
10
11
12#include <boost/dynamic_bitset.hpp>
13#include <boost/serialization/serialization.hpp>
14#include <boost/serialization/nvp.hpp>
15#include <vector>
16#include <boost/functional/hash.hpp>
17#include "FMTutility.hpp"
18
19
20namespace Core
21{
22 class FMTmask;
23 class FMTtheme;
24
25
27 {
28 friend class boost::serialization::access;
29 friend class FMTtheme;
30 friend class FMTmask;
31 template<class Archive>
32 void serialize(Archive& ar, const unsigned int version)
33 {
34 /*ar & BOOST_SERIALIZATION_NVP(fullset);*/
35 ar & BOOST_SERIALIZATION_NVP(selection);
36 ar & BOOST_SERIALIZATION_NVP(flippedselection);
37 //ar & BOOST_SERIALIZATION_NVP(index);
38 }
39 protected:
40 /*boost::dynamic_bitset<> fullset;*/
41 boost::dynamic_bitset<> selection;
42 boost::dynamic_bitset<> flippedselection;
43 //std::vector<size_t>index;
44 public:
46 virtual ~FMTmaskfilter()=default;
48 FMTmaskfilter& operator = (const FMTmaskfilter& rhs);
49 FMTmaskfilter(const FMTmask& presolveselection, const FMTmask& buffermask);
50 FMTmaskfilter(const FMTmask& presolveselection);
51 FMTmaskfilter(std::vector<FMTmask>& masks);
52 FMTmaskfilter(std::vector<FMTmask>& masks,const std::vector<FMTtheme>& themes);
53 FMTmask filter(const FMTmask& devmask) const;
54 void swap(FMTmaskfilter& rhs);
55 FMTmaskfilter presolve(const std::vector<FMTtheme>& themes) const;
56 bool canpresolve(const FMTmask& mask, const std::vector<Core::FMTtheme>& themes) const;
57 std::vector<Core::FMTtheme> getselectedthemes(const std::vector<Core::FMTtheme>& themes) const;
58 inline bool emptyflipped() const
59 {
60 return flippedselection.empty();
61 }
62 inline bool empty() const
63 {
64 return selection.empty();
65 }
66 inline size_t hash() const
67 {
68 return (boost::hash<boost::dynamic_bitset<>>()(selection) ^ boost::hash<boost::dynamic_bitset<>>()(flippedselection));
69 }
70 };
71
72
73
74}
75
76namespace boost {
77
78 template <>
79 struct hash<Core::FMTmaskfilter>
80 {
81 std::size_t operator()(const Core::FMTmaskfilter& filter) const
82 {
83
84 return (filter.hash());
85 }
86 };
87
88
89}
90
91#endif // FMTMASKFILTER_H_INCLUDED
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTmask.hpp:96
Definition: FMTmaskfilter.hpp:27
boost::dynamic_bitset flippedselection
Definition: FMTmaskfilter.hpp:42
FMTmaskfilter(std::vector< FMTmask > &masks, const std::vector< FMTtheme > &themes)
FMTmaskfilter(const FMTmask &presolveselection, const FMTmask &buffermask)
FMTmaskfilter(const FMTmaskfilter &rhs)
FMTmaskfilter presolve(const std::vector< FMTtheme > &themes) const
size_t hash() const
Definition: FMTmaskfilter.hpp:66
bool canpresolve(const FMTmask &mask, const std::vector< Core::FMTtheme > &themes) const
FMTmaskfilter(const FMTmask &presolveselection)
bool emptyflipped() const
Definition: FMTmaskfilter.hpp:58
FMTmaskfilter(std::vector< FMTmask > &masks)
FMTmask filter(const FMTmask &devmask) const
boost::dynamic_bitset selection
Definition: FMTmaskfilter.hpp:41
bool empty() const
Definition: FMTmaskfilter.hpp:62
virtual ~FMTmaskfilter()=default
std::vector< Core::FMTtheme > getselectedthemes(const std::vector< Core::FMTtheme > &themes) const
void swap(FMTmaskfilter &rhs)
Definition: FMTtheme.hpp:47
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31
Definition: FMTaction.hpp:364
std::size_t operator()(const Core::FMTmaskfilter &filter) const
Definition: FMTmaskfilter.hpp:81