Developer documentation
Version 3.0.3-105-gd3941f44
colourmap.h
Go to the documentation of this file.
1/* Copyright (c) 2008-2022 the MRtrix3 contributors.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 *
7 * Covered Software is provided under this License on an "as is"
8 * basis, without warranty of any kind, either expressed, implied, or
9 * statutory, including, without limitation, warranties that the
10 * Covered Software is free of defects, merchantable, fit for a
11 * particular purpose or non-infringing.
12 * See the Mozilla Public License v. 2.0 for more details.
13 *
14 * For more details, see http://www.mrtrix.org/.
15 */
16
17#ifndef __colourmap_h__
18#define __colourmap_h__
19
20#include <functional>
21#include "types.h"
22
23
24namespace MR
25{
26 namespace ColourMap
27 {
28
30 public:
31
32 using basic_map_fn = std::function< Eigen::Array3f (float) >;
33
34 Entry (const char* name, const char* glsl_mapping, basic_map_fn basic_mapping,
35 const char* amplitude = NULL, bool special = false, bool is_colour = false, bool is_rgb = false) :
36 name (name),
37 glsl_mapping (glsl_mapping),
38 basic_mapping (basic_mapping),
39 amplitude (amplitude ? amplitude : default_amplitude),
40 special (special),
41 is_colour (is_colour),
42 is_rgb (is_rgb) { }
43
44 const char* name;
45 const char* glsl_mapping;
46 basic_map_fn basic_mapping;
47 const char* amplitude;
48 bool special, is_colour, is_rgb;
49
50 static const char* default_amplitude;
51
52 };
53
54 extern const Entry maps[];
55
56
57
58
59
60 inline size_t num () {
61 size_t n = 0;
62 while (maps[n].name) ++n;
63 return n;
64 }
65
66
67 inline size_t num_scalar () {
68 size_t n = 0, i = 0;
69 while (maps[i].name) {
70 if (!maps[i].special)
71 ++n;
72 ++i;
73 }
74 return n;
75 }
76
77 inline size_t index (const std::string& name) {
78 size_t n = 0;
79 while (maps[n].name != name) ++n;
80 return n;
81 }
82
83
84 inline size_t num_special () {
85 size_t n = 0, i = 0;
86 while (maps[i].name) {
87 if (maps[i].special)
88 ++n;
89 ++i;
90 }
91 return n;
92 }
93
94
95 }
96}
97
98#endif
99
100
101
102
Definition: colourmap.h:29
size_t num_special()
Definition: colourmap.h:84
size_t num_scalar()
Definition: colourmap.h:67
const Entry maps[]
size_t num()
Definition: colourmap.h:60
size_t index(const std::string &name)
Definition: colourmap.h:77
Definition: base.h:24
#define MEMALIGN(...)
Definition: types.h:185
const std::string name
Definition: thread.h:108