5 #include "ThresholdShader.h" 25 auto Iend = params.end();
27 m_threshold = I->second;
31 HighShader::~HighShader() =
default;
35 if (s.
getMax() > m_threshold) {
46 unsigned int colors = channels - 1;
49 if (height_data == 0) {
50 std::cerr <<
"WARNING: Mercator: Attempting to shade empty segment." 51 << std::endl << std::flush;
56 unsigned int count = size * size;
58 for (
unsigned int i = 0; i < count; ++i) {
59 for (
unsigned int k = 0; k < colors; ++k) {
62 data[++j] = ((height_data[i] > m_threshold) ? colorMax : colorMin);
77 auto Iend = params.end();
79 m_threshold = I->second;
83 LowShader::~LowShader() =
default;
87 if (s.
getMin() < m_threshold) {
98 unsigned int colors = channels - 1;
101 if (height_data == 0) {
102 std::cerr <<
"WARNING: Mercator: Attempting to shade empty segment." 103 << std::endl << std::flush;
108 unsigned int count = size * size;
110 for (
unsigned int i = 0; i < count; ++i) {
111 for (
unsigned int k = 0; k < colors; ++k) {
112 data[++j] = colorMax;
114 data[++j] = ((height_data[i] < m_threshold) ? colorMax : colorMin);
125 m_lowThreshold(low_threshold), m_highThreshold(high_threshold)
133 auto Iend = params.end();
135 m_lowThreshold = I->second;
139 m_highThreshold = I->second;
143 BandShader::~BandShader() =
default;
147 if ((s.
getMin() < m_highThreshold) &&
148 (s.
getMax() > m_lowThreshold)) {
158 assert(channels > 0);
159 unsigned int colors = channels - 1;
162 if (height_data ==
nullptr) {
163 std::cerr <<
"WARNING: Mercator: Attempting to shade empty segment." 164 << std::endl << std::flush;
169 unsigned int count = size * size;
171 for (
unsigned int i = 0; i < count; ++i) {
172 for (
unsigned int k = 0; k < colors; ++k) {
173 data[++j] = colorMax;
175 data[++j] = (((height_data[i] > m_lowThreshold) &&
176 (height_data[i] < m_highThreshold)) ? colorMax : colorMin);
HighShader(float threshold=default_threshold)
Constructor.
static const std::string key_lowThreshold
Key string used when specifying the low threshold parameter.
DataType * getData()
Accessor for a pointer to buffer containing data values.
LowShader(float threshold=default_threshold)
Constructor.
bool checkIntersect(const Segment &) const override
Check whether this Shader has any effect on the given Segment.
Data store for terrain surface data.
float threshold() const
Accessor for level above which the shader renders.
BandShader(float low_threshold=default_lowThreshold, float high_threshold=default_highThreshold)
Constructor.
void shade(Surface &) const override
Populate a Surface with data.
float getMin() const
Accessor for the minimum height value in this Segment.
std::map< std::string, float > Parameters
STL map of parameter values for a shader constructor.
int getSize() const
Accessor for array size of this segment.
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
static const float default_lowThreshold
Default level above which the shader renders.
static const float default_threshold
Default level below which the shader renders.
unsigned int getChannels() const
Accessor for the number of data values per height point.
float getMax() const
Accessor for the maximum height value in this Segment.
const Segment & getSegment() const
Accessor for the terrain height segment this surface is associated with.
static const float default_threshold
Default level above which the shader renders.
static const std::string key_highThreshold
Key string used when specifying the high threshold parameter.
void shade(Surface &) const override
Populate a Surface with data.
const float * getPoints() const
Accessor for buffer containing height points.
void shade(Surface &) const override
Populate a Surface with data.
static const float default_highThreshold
Default level below which the shader renders.
static const std::string key_threshold
Key string used when specifying the threshold parameter.
bool checkIntersect(const Segment &) const override
Check whether this Shader has any effect on the given Segment.
static const std::string key_threshold
Key string used when specifying the threshold parameter.
bool checkIntersect(const Segment &) const override
Check whether this Shader has any effect on the given Segment.