OpenLB 1.7
Loading...
Searching...
No Matches
colormaps.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2007 Jonas Latt
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef COLORMAPS_H
25#define COLORMAPS_H
26
27#include <string>
28#include <vector>
29
30namespace olb {
31
32namespace graphics {
33
34template <typename T>
36 virtual ~ScalarFunction() { }
37 virtual T operator() (T x) const =0;
38 virtual ScalarFunction<T>* clone() const=0;
39};
40
41template <typename T>
42class LinearFunction : public ScalarFunction<T> {
43public:
44 LinearFunction(T x1_, T x2_, T y1_, T y2_);
45 T operator() (T x) const override;
46 LinearFunction<T>* clone() const override;
47private:
48 T x1, x2, y1, y2;
49};
50
51template <typename T>
53public:
54 PowerLawFunction(T x1_, T x2_, T y1_, T y2_, T b_);
55 T operator() (T x) const override;
56 PowerLawFunction<T>* clone() const override;
57private:
58 T x1, x2, y1, y2;
59 T b;
60};
61
62template <typename T>
63struct Piece {
64 Piece(T closedBegin_, T openEnd_) : closedBegin(closedBegin_), openEnd(openEnd_)
65 {
66 }
68};
69
70template <typename T>
72public:
74 ~PiecewiseFunction() override;
77 void swap(PiecewiseFunction<T>& rhs);
78 void addPiece(Piece<T> piece, ScalarFunction<T>* f);
79 T operator() (T x) const override;
80 PiecewiseFunction<T>* clone() const override;
81private:
82 std::vector<Piece<T> > pieces;
83 std::vector<ScalarFunction<T>*> functions;
84};
85
86template <typename T>
87struct rgb {
88 rgb(T r_, T g_, T b_) : r(r_), g(g_), b(b_)
89 {
90 }
91 T r,g,b;
92};
93
94template <typename T>
95class ColorMap {
96public:
98 PiecewiseFunction<T> const& green_,
99 PiecewiseFunction<T> const& blue_);
100 rgb<T> get(T x) const;
101private:
102 PiecewiseFunction<T> red, green, blue;
103};
104
105namespace mapGenerators {
106
107template <typename T> PiecewiseFunction<T> generateEarthRed();
108template <typename T> PiecewiseFunction<T> generateEarthGreen();
109template <typename T> PiecewiseFunction<T> generateEarthBlue();
110
111template <typename T> PiecewiseFunction<T> generateWaterRed();
112template <typename T> PiecewiseFunction<T> generateWaterGreen();
113template <typename T> PiecewiseFunction<T> generateWaterBlue();
114
115template <typename T> PiecewiseFunction<T> generateAirRed();
116template <typename T> PiecewiseFunction<T> generateAirGreen();
117template <typename T> PiecewiseFunction<T> generateAirBlue();
118
119template <typename T> PiecewiseFunction<T> generateFireRed();
120template <typename T> PiecewiseFunction<T> generateFireGreen();
121template <typename T> PiecewiseFunction<T> generateFireBlue();
122
123template <typename T> PiecewiseFunction<T> generateLeeLooRed();
124template <typename T> PiecewiseFunction<T> generateLeeLooGreen();
125template <typename T> PiecewiseFunction<T> generateLeeLooBlue();
126
127template <typename T> ColorMap<T> generateMap(std::string mapName);
128
129} // namespace mapGenerators
130
131} // namespace graphics
132
133} // namespace olb
134
135#endif
ColorMap(PiecewiseFunction< T > const &red_, PiecewiseFunction< T > const &green_, PiecewiseFunction< T > const &blue_)
Definition colormaps.hh:137
rgb< T > get(T x) const
Definition colormaps.hh:144
T operator()(T x) const override
Definition colormaps.hh:40
LinearFunction(T x1_, T x2_, T y1_, T y2_)
Definition colormaps.hh:35
LinearFunction< T > * clone() const override
Definition colormaps.hh:46
T operator()(T x) const override
Definition colormaps.hh:115
PiecewiseFunction< T > * clone() const override
Definition colormaps.hh:131
void swap(PiecewiseFunction< T > &rhs)
Definition colormaps.hh:95
PiecewiseFunction< T > & operator=(PiecewiseFunction< T > const &rhs)
Definition colormaps.hh:80
void addPiece(Piece< T > piece, ScalarFunction< T > *f)
Definition colormaps.hh:102
T operator()(T x) const override
Definition colormaps.hh:57
PowerLawFunction< T > * clone() const override
Definition colormaps.hh:63
PowerLawFunction(T x1_, T x2_, T y1_, T y2_, T b_)
Definition colormaps.hh:52
PiecewiseFunction< T > generateWaterBlue()
Definition colormaps.hh:232
PiecewiseFunction< T > generateAirGreen()
Definition colormaps.hh:260
PiecewiseFunction< T > generateFireGreen()
Definition colormaps.hh:299
PiecewiseFunction< T > generateWaterRed()
Definition colormaps.hh:200
PiecewiseFunction< T > generateFireRed()
Definition colormaps.hh:285
PiecewiseFunction< T > generateEarthRed()
Definition colormaps.hh:152
PiecewiseFunction< T > generateEarthBlue()
Definition colormaps.hh:184
PiecewiseFunction< T > generateWaterGreen()
Definition colormaps.hh:216
PiecewiseFunction< T > generateLeeLooBlue()
Definition colormaps.hh:372
ColorMap< T > generateMap(std::string mapName)
Definition colormaps.hh:392
PiecewiseFunction< T > generateLeeLooRed()
Definition colormaps.hh:330
PiecewiseFunction< T > generateAirBlue()
Definition colormaps.hh:272
PiecewiseFunction< T > generateAirRed()
Definition colormaps.hh:248
PiecewiseFunction< T > generateEarthGreen()
Definition colormaps.hh:168
PiecewiseFunction< T > generateLeeLooGreen()
Definition colormaps.hh:350
PiecewiseFunction< T > generateFireBlue()
Definition colormaps.hh:315
Top level namespace for all of OpenLB.
Piece(T closedBegin_, T openEnd_)
Definition colormaps.h:64
virtual ScalarFunction< T > * clone() const =0
virtual T operator()(T x) const =0
rgb(T r_, T g_, T b_)
Definition colormaps.h:88