From 94d3e79a8617f88dc0219cfdeedfa3147833719d Mon Sep 17 00:00:00 2001
From: Adrian Kummerlaender
Date: Mon, 24 Jun 2019 14:43:36 +0200
Subject: Initialize at openlb-1-3
---
src/io/colormaps.h | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 135 insertions(+)
create mode 100644 src/io/colormaps.h
(limited to 'src/io/colormaps.h')
diff --git a/src/io/colormaps.h b/src/io/colormaps.h
new file mode 100644
index 0000000..673425d
--- /dev/null
+++ b/src/io/colormaps.h
@@ -0,0 +1,135 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2007 Jonas Latt
+ * E-mail contact: info@openlb.net
+ * The most recent release of OpenLB can be downloaded at
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef COLORMAPS_H
+#define COLORMAPS_H
+
+#include
+#include
+
+namespace olb {
+
+namespace graphics {
+
+template
+struct ScalarFunction {
+ virtual ~ScalarFunction() { }
+ virtual T operator() (T x) const =0;
+ virtual ScalarFunction* clone() const=0;
+};
+
+template
+class LinearFunction : public ScalarFunction {
+public:
+ LinearFunction(T x1_, T x2_, T y1_, T y2_);
+ T operator() (T x) const override;
+ LinearFunction* clone() const override;
+private:
+ T x1, x2, y1, y2;
+};
+
+template
+class PowerLawFunction : public ScalarFunction {
+public:
+ PowerLawFunction(T x1_, T x2_, T y1_, T y2_, T b_);
+ T operator() (T x) const override;
+ PowerLawFunction* clone() const override;
+private:
+ T x1, x2, y1, y2;
+ T b;
+};
+
+template
+struct Piece {
+ Piece(T closedBegin_, T openEnd_) : closedBegin(closedBegin_), openEnd(openEnd_)
+ {
+ }
+ T closedBegin, openEnd;
+};
+
+template
+class PiecewiseFunction : public ScalarFunction {
+public:
+ PiecewiseFunction() { }
+ ~PiecewiseFunction() override;
+ PiecewiseFunction(PiecewiseFunction const& rhs);
+ PiecewiseFunction& operator=(PiecewiseFunction const& rhs);
+ void swap(PiecewiseFunction& rhs);
+ void addPiece(Piece piece, ScalarFunction* f);
+ T operator() (T x) const override;
+ PiecewiseFunction* clone() const override;
+private:
+ std::vector > pieces;
+ std::vector*> functions;
+};
+
+template
+struct rgb {
+ rgb(T r_, T g_, T b_) : r(r_), g(g_), b(b_)
+ {
+ }
+ T r,g,b;
+};
+
+template
+class ColorMap {
+public:
+ ColorMap(PiecewiseFunction const& red_,
+ PiecewiseFunction const& green_,
+ PiecewiseFunction const& blue_);
+ rgb get(T x) const;
+private:
+ PiecewiseFunction red, green, blue;
+};
+
+namespace mapGenerators {
+
+template PiecewiseFunction generateEarthRed();
+template PiecewiseFunction generateEarthGreen();
+template PiecewiseFunction generateEarthBlue();
+
+template PiecewiseFunction generateWaterRed();
+template PiecewiseFunction generateWaterGreen();
+template PiecewiseFunction generateWaterBlue();
+
+template PiecewiseFunction generateAirRed();
+template PiecewiseFunction generateAirGreen();
+template PiecewiseFunction generateAirBlue();
+
+template PiecewiseFunction generateFireRed();
+template PiecewiseFunction generateFireGreen();
+template PiecewiseFunction generateFireBlue();
+
+template PiecewiseFunction generateLeeLooRed();
+template PiecewiseFunction generateLeeLooGreen();
+template PiecewiseFunction generateLeeLooBlue();
+
+template ColorMap generateMap(std::string mapName);
+
+} // namespace mapGenerators
+
+} // namespace graphics
+
+} // namespace olb
+
+#endif
--
cgit v1.2.3