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-2012 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 <vrmath/Vector3f.h> |
---|
20 | |
---|
21 | #include "Texture1D.h" |
---|
22 | |
---|
23 | class TransferFunction |
---|
24 | { |
---|
25 | public: |
---|
26 | TransferFunction(int size, float *data); |
---|
27 | |
---|
28 | void update(float *data); |
---|
29 | |
---|
30 | void update(int size, float *data); |
---|
31 | |
---|
32 | GLuint id() |
---|
33 | { |
---|
34 | return _id; |
---|
35 | } |
---|
36 | |
---|
37 | void id(GLuint id) |
---|
38 | { |
---|
39 | _id = id; |
---|
40 | } |
---|
41 | |
---|
42 | Texture1D *getTexture() |
---|
43 | { |
---|
44 | return _tex; |
---|
45 | } |
---|
46 | |
---|
47 | float *getData() |
---|
48 | { |
---|
49 | return _data; |
---|
50 | } |
---|
51 | |
---|
52 | int getSize() const |
---|
53 | { |
---|
54 | return _size; |
---|
55 | } |
---|
56 | |
---|
57 | const char *name() const |
---|
58 | { |
---|
59 | return _name; |
---|
60 | } |
---|
61 | |
---|
62 | void name(const char *name) |
---|
63 | { |
---|
64 | _name = name; |
---|
65 | } |
---|
66 | |
---|
67 | static void sample(float fraction, float *key, int count, vrmath::Vector3f *keyValue, vrmath::Vector3f *ret); |
---|
68 | |
---|
69 | static void sample(float fraction, float *key, int count, float *keyValue, float *ret); |
---|
70 | |
---|
71 | protected : |
---|
72 | ~TransferFunction(); |
---|
73 | |
---|
74 | private: |
---|
75 | /// the resolution of the color map, how many (RGBA) quadraples |
---|
76 | int _size; |
---|
77 | float *_data; |
---|
78 | Texture1D *_tex; ///< the texture storing the colors |
---|
79 | const char *_name; |
---|
80 | GLuint _id; ///< OpenGL texture identifier |
---|
81 | }; |
---|
82 | |
---|
83 | #endif |
---|