$treeview $search $mathjax
|
Palabos
Version 1.1
$projectbrief
|
$projectbrief
|
$searchbox |
00001 /* This file is part of the Palabos library. 00002 * 00003 * Copyright (C) 2011 FlowKit Sarl 00004 * Avenue de Chailly 23 00005 * 1012 Lausanne, Switzerland 00006 * E-mail contact: contact@flowkit.com 00007 * 00008 * The most recent release of Palabos can be downloaded at 00009 * <http://www.palabos.org/> 00010 * 00011 * The library Palabos is free software: you can redistribute it and/or 00012 * modify it under the terms of the GNU Affero General Public License as 00013 * published by the Free Software Foundation, either version 3 of the 00014 * License, or (at your option) any later version. 00015 * 00016 * The library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Affero General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Affero General Public License 00022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00023 */ 00024 00025 #ifndef COLORMAPS_H 00026 #define COLORMAPS_H 00027 00028 #include "core/globalDefs.h" 00029 #include <string> 00030 #include <vector> 00031 00032 namespace plb { 00033 00034 struct ScalarFunction { 00035 virtual ~ScalarFunction() { } 00036 virtual double operator() (double x) const =0; 00037 virtual ScalarFunction* clone() const=0; 00038 }; 00039 00040 class LinearFunction : public ScalarFunction { 00041 public: 00042 LinearFunction(double x1_, double x2_, double y1_, double y2_); 00043 virtual double operator() (double x) const; 00044 virtual LinearFunction* clone() const; 00045 private: 00046 double x1, x2, y1, y2; 00047 }; 00048 00049 class PowerLawFunction : public ScalarFunction { 00050 public: 00051 PowerLawFunction(double x1_, double x2_, double y1_, double y2_, double b_); 00052 virtual double operator() (double x) const; 00053 virtual PowerLawFunction* clone() const; 00054 private: 00055 double x1, x2, y1, y2; 00056 double b; 00057 }; 00058 00059 struct Piece { 00060 Piece(double closedBegin_, double openEnd_) : closedBegin(closedBegin_), openEnd(openEnd_) 00061 { } 00062 double closedBegin, openEnd; 00063 }; 00064 00065 class PiecewiseFunction : public ScalarFunction { 00066 public: 00067 PiecewiseFunction() { } 00068 ~PiecewiseFunction(); 00069 PiecewiseFunction(PiecewiseFunction const& rhs); 00070 PiecewiseFunction& operator=(PiecewiseFunction const& rhs); 00071 void swap(PiecewiseFunction& rhs); 00072 void addPiece(Piece piece, ScalarFunction* f); 00073 virtual double operator() (double x) const; 00074 virtual PiecewiseFunction* clone() const; 00075 private: 00076 std::vector<Piece > pieces; 00077 std::vector<ScalarFunction*> functions; 00078 }; 00079 00080 struct rgb { 00081 rgb(double r_, double g_, double b_) : r(r_), g(g_), b(b_) 00082 { } 00083 double r,g,b; 00084 }; 00085 00086 class ColorMap { 00087 public: 00088 ColorMap(PiecewiseFunction const& red_, 00089 PiecewiseFunction const& green_, 00090 PiecewiseFunction const& blue_); 00091 rgb get(double x) const; 00092 private: 00093 PiecewiseFunction red, green, blue; 00094 }; 00095 00096 namespace mapGenerators { 00097 00098 PiecewiseFunction generateEarthRed(); 00099 PiecewiseFunction generateEarthGreen(); 00100 PiecewiseFunction generateEarthBlue(); 00101 00102 PiecewiseFunction generateWaterRed(); 00103 PiecewiseFunction generateWaterGreen(); 00104 PiecewiseFunction generateWaterBlue(); 00105 00106 PiecewiseFunction generateAirRed(); 00107 PiecewiseFunction generateAirGreen(); 00108 PiecewiseFunction generateAirBlue(); 00109 00110 PiecewiseFunction generateFireRed(); 00111 PiecewiseFunction generateFireGreen(); 00112 PiecewiseFunction generateFireBlue(); 00113 00114 PiecewiseFunction generateLeeLooRed(); 00115 PiecewiseFunction generateLeeLooGreen(); 00116 PiecewiseFunction generateLeeLooBlue(); 00117 00118 PiecewiseFunction generateRedBlueRed(); 00119 PiecewiseFunction generateRedBlueGreen(); 00120 PiecewiseFunction generateRedBlueBlue(); 00121 00122 ColorMap generateMap(std::string mapName); 00123 00124 } // namespace mapGenerators 00125 00126 } // namespace plb 00127 00128 #endif // COLORMAPS_H
1.6.3
1.6.3