1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* |
---|
3 | * ---------------------------------------------------------------------- |
---|
4 | * ColorMap.h: color map class contains an array of (RGBA) values |
---|
5 | * |
---|
6 | * ====================================================================== |
---|
7 | * AUTHOR: Wei Qiao <qiaow@purdue.edu> |
---|
8 | * Purdue Rendering and Perceptualization Lab (PURPL) |
---|
9 | * |
---|
10 | * Copyright (c) 2004-2013 HUBzero Foundation, LLC |
---|
11 | * |
---|
12 | * See the file "license.terms" for information on usage and |
---|
13 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
14 | * ====================================================================== |
---|
15 | */ |
---|
16 | #ifndef TRANSFER_FUNCTION_H |
---|
17 | #define TRANSFER_FUNCTION_H |
---|
18 | |
---|
19 | #include <string> |
---|
20 | |
---|
21 | #include <vrmath/Vector3f.h> |
---|
22 | |
---|
23 | #include "Texture1D.h" |
---|
24 | |
---|
25 | class TransferFunction |
---|
26 | { |
---|
27 | public: |
---|
28 | TransferFunction(const char *name, int size, float *data); |
---|
29 | |
---|
30 | void update(float *data); |
---|
31 | |
---|
32 | void update(int size, float *data); |
---|
33 | |
---|
34 | GLuint id() |
---|
35 | { |
---|
36 | return _id; |
---|
37 | } |
---|
38 | |
---|
39 | void id(GLuint id) |
---|
40 | { |
---|
41 | _id = id; |
---|
42 | } |
---|
43 | |
---|
44 | Texture1D *getTexture() |
---|
45 | { |
---|
46 | return _tex; |
---|
47 | } |
---|
48 | |
---|
49 | float *getData() |
---|
50 | { |
---|
51 | return _data; |
---|
52 | } |
---|
53 | |
---|
54 | int getSize() const |
---|
55 | { |
---|
56 | return _size; |
---|
57 | } |
---|
58 | |
---|
59 | const char *name() const |
---|
60 | { |
---|
61 | return _name.c_str(); |
---|
62 | } |
---|
63 | |
---|
64 | static void sample(float fraction, float *keys, vrmath::Vector3f *keyValues, int count, vrmath::Vector3f *ret); |
---|
65 | |
---|
66 | static void sample(float fraction, float *keys, float *keyValues, int count, float *ret); |
---|
67 | |
---|
68 | protected : |
---|
69 | ~TransferFunction(); |
---|
70 | |
---|
71 | private: |
---|
72 | /// the resolution of the color map, how many (RGBA) quadraples |
---|
73 | int _size; |
---|
74 | float *_data; |
---|
75 | Texture1D *_tex; ///< the texture storing the colors |
---|
76 | std::string _name; |
---|
77 | GLuint _id; ///< OpenGL texture identifier |
---|
78 | }; |
---|
79 | |
---|
80 | #endif |
---|