colourTable.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2019 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::colourTable
28
29Description
30 Base class for generating a colour table from node points.
31
32 Dictionary definition
33 \table
34 Property | Description | Required | Default
35 interpolate | rgb/hsv/diverging | no | rgb
36 table | Node points for the colour table | yes |
37 \endtable
38
39Predefined colour tables (in "etc/colourTables") include
40"coolToWarm", "coldAndHot", "fire", "rainbow", "greyscale", "xray".
41
42SourceFiles
43 colourTable.C
44
45\*---------------------------------------------------------------------------*/
46
47#ifndef colourTable_H
48#define colourTable_H
49
50#include "Enum.H"
51#include "List.H"
52#include "Tuple2.H"
53#include "vector.H"
54#include "HashPtrTable.H"
55
56// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57
58namespace Foam
59{
60
61/*---------------------------------------------------------------------------*\
62 Class colourTable Declaration
63\*---------------------------------------------------------------------------*/
64
65class colourTable
66{
67public:
68
69 //- Internal interpolation type
71 {
72 RGB,
73 HSV,
75 };
76
77 //- Enumeration of commonly used colour tables.
78 // The indices must match those in "etc/colourTables"
80 {
81 COOL_WARM,
82 COLD_HOT,
83 FIRE,
85 GREYSCALE,
87 };
88
90 //- Enumeration names for interpolationType
92
93 //- Enumeration names for predefinedType
96 //- The data lookup type
100 // Lookup Colour Tables
102 //- Look up pointer to colourTable by name, or nullptr on failure.
103 static const colourTable* ptr(const word& tableName);
104
105 //- Look up pointer to colourTable by type, or nullptr on failure.
106 static const colourTable* ptr(const predefinedType tbl);
107
108 //- Look up pointer to colourTable by name. Fatal on failure
109 static const colourTable& ref(const word& tableName);
110
111 //- Look up pointer to colourTable by type. Fatal on failure
112 static const colourTable& ref(const predefinedType tbl);
113
114
115private:
116
117 // Private Static Data
118
119 //- Predefined tables
120 static HashPtrTable<colourTable> tables_;
121
122
123 // Private Data
124
125 //- The table control points
126 List<pair_type> table_;
127
128 //- Interpolator type
129 interpolationType interp_;
130
131
132 // Private Member Functions
133
134 //- Construct from central "etc/colourTables" file.
135 static void constructTables();
136
137
138public:
139
140 // Constructors
141
142 //- Copy construct from table values
143 explicit colourTable
144 (
145 const List<Tuple2<scalar, vector>>& values,
147 );
148
149 //- Copy construct from table values
150 explicit colourTable
151 (
154 );
155
156 //- Read construct from dictionary
157 explicit colourTable
158 (
159 const dictionary& dict,
161 );
162
163
164 // Selectors
165
166 //- Read as dictionary content
167 static autoPtr<colourTable> New(Istream& is);
168
169
170 //- Destructor
171 virtual ~colourTable() = default;
172
173
174 // Member Functions
175
176 // Access
177
178 //- Predefined tables
179 static const HashPtrTable<colourTable>& tables();
180
181 //- Return the colour at x. The input is clipped to 0-1 range.
182 vector value(const scalar x) const;
183
184 //- Return a discrete lookup table of colours
185 List<Tuple2<scalar, vector>> table(const label nColours) const;
186
187
188 // IO
189
190 //- Write as dictionary format
191 Ostream& writeDict(Ostream& os) const;
192};
193
194
195//- Write as dictionary format
197
198
199// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200
201} // End namespace Foam
202
203// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204
205// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206
207#endif
208
209// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
A HashTable of pointers to objects of type <T>, with deallocation management of the pointers.
Definition: HashPtrTable.H:68
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: Tuple2.H:58
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Base class for generating a colour table from node points.
Definition: colourTable.H:80
vector value(const scalar x) const
Return the colour at x. The input is clipped to 0-1 range.
Definition: colourTable.C:94
Ostream & writeDict(Ostream &os) const
Write as dictionary format.
Definition: colourTable.C:165
static autoPtr< colourTable > New(Istream &is)
Read as dictionary content.
Definition: colourTable.C:86
static const colourTable * ptr(const word &tableName)
Look up pointer to colourTable by name, or nullptr on failure.
Definition: colourTables.C:88
Tuple2< scalar, vector > pair_type
The data lookup type.
Definition: colourTable.H:111
static const Enum< interpolationType > interpolationTypeNames
Enumeration names for interpolationType.
Definition: colourTable.H:105
List< Tuple2< scalar, vector > > table(const label nColours) const
Return a discrete lookup table of colours.
Definition: colourTable.C:150
interpolationType
Internal interpolation type.
Definition: colourTable.H:85
static const Enum< predefinedType > predefinedNames
Enumeration names for predefinedType.
Definition: colourTable.H:108
predefinedType
Enumeration of commonly used colour tables.
Definition: colourTable.H:94
@ COOL_WARM
"coolToWarm"
Definition: colourTable.H:95
@ GREYSCALE
greyscale - ParaView "Grayscale"
Definition: colourTable.H:99
@ FIRE
"fire" - ParaView "Black-Body Radiation"
Definition: colourTable.H:97
@ COLD_HOT
"coldAndHot"
Definition: colourTable.H:96
@ XRAY
"xray" - ParaView "X Ray"
Definition: colourTable.H:100
@ RAINBOW
"rainbow"
Definition: colourTable.H:98
static const HashPtrTable< colourTable > & tables()
Predefined tables.
Definition: colourTables.C:77
virtual ~colourTable()=default
Destructor.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling words, derived from Foam::string.
Definition: word.H:68
rDeltaT ref()
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
dictionary dict