-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathBandsMofN.cpp
63 lines (50 loc) · 1.66 KB
/
BandsMofN.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* BandsMofN.cpp
*
* Copyright (c) 2015-2021 United States Government as represented by
* the National Aeronautics and Space Administration. No copyright
* is claimed in the United States under Title 17, U.S.Code. All Other
*/
#include "BandsMofN.h"
#include "format.h"
#include "DaidalusParameters.h"
namespace larcfm {
BandsMofN::BandsMofN(const ColorValue& cv, int m, int n) : val(cv.val) {
colors_left.setMofN(m,n,BandsRegion::orderOfRegion(cv.color_left));
colors_right.setMofN(m,n,BandsRegion::orderOfRegion(cv.color_right));
}
BandsMofN::BandsMofN(double value, const MofN& mofn) :
val(value),
colors_left(mofn),
colors_right(mofn)
{}
BandsRegion::Region BandsMofN::left_m_of_n(BandsRegion::Region region) {
int code = colors_left.m_of_n(BandsRegion::orderOfRegion(region));
return BandsRegion::regionFromOrder(code);
}
BandsRegion::Region BandsMofN::right_m_of_n(BandsRegion::Region region) {
int code = colors_right.m_of_n(BandsRegion::orderOfRegion(region));
return BandsRegion::regionFromOrder(code);
}
bool BandsMofN::same_colors() const {
return colors_left.sameAs(colors_right);
}
std::string BandsMofN::toString() const {
std::string s = "<"+colors_left.toString()+", "+FmPrecision(val)+", "+colors_right.toString()+">";
return s;
}
std::string BandsMofN::listToString(const std::vector<BandsMofN>& l) {
std::string s = "[";
bool comma = false;
for (std::vector<BandsMofN>::const_iterator i_ptr = l.begin(); i_ptr != l.end(); ++i_ptr) {
if (comma) {
s+= ", ";
} else {
comma = true;
}
s += i_ptr->toString();
}
s += "]";
return s;
}
} /* namespace larcfm */