1 /*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: otherLookupTableWithEnabling.cxx
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14 =========================================================================*/
15
16 // .NAME
17 // .SECTION Description
18 // this program tests the LookupTableWithEnabling
19
20 #include "vtkLookupTableWithEnabling.h"
21 #include "vtkDebugLeaks.h"
22
TestOLT(vtkLookupTableWithEnabling * lut1)23 void TestOLT(vtkLookupTableWithEnabling *lut1)
24 {
25 // actual test
26
27 lut1->SetRange(1,1024);
28
29 lut1->Allocate (1024);
30 lut1->SetRampToLinear();
31 lut1->Build();
32
33 double rgb[4];
34 lut1->GetColor(0, rgb);
35
36 lut1->GetOpacity(0);
37
38 lut1->GetTableValue(10,rgb);
39 lut1->GetTableValue(10);
40
41 unsigned char output[4*1024];
42
43 int bitA = 0;
44 lut1->MapScalarsThroughTable2(&bitA, output, VTK_BIT,
45 2, 1, VTK_RGBA);
46 lut1->MapScalarsThroughTable2(&bitA, output, VTK_CHAR,
47 2, 1, VTK_RGB);
48 lut1->MapScalarsThroughTable2(&bitA, output, VTK_CHAR,
49 2, 1, VTK_LUMINANCE_ALPHA);
50 lut1->MapScalarsThroughTable2(&bitA, output, VTK_CHAR,
51 2, 1, VTK_LUMINANCE);
52
53 bitA = 1;
54 lut1->MapScalarsThroughTable2(&bitA, output, VTK_BIT,
55 2, 1, VTK_RGBA);
56 lut1->MapScalarsThroughTable2(&bitA, output, VTK_CHAR,
57 2, 1, VTK_RGB);
58 lut1->MapScalarsThroughTable2(&bitA, output, VTK_CHAR,
59 2, 1, VTK_LUMINANCE_ALPHA);
60 lut1->MapScalarsThroughTable2(&bitA, output, VTK_CHAR,
61 2, 1, VTK_LUMINANCE);
62
63
64 char charA[2] = {0, 10};
65 lut1->MapScalarsThroughTable2(charA, output, VTK_CHAR,
66 2, 1, VTK_RGBA);
67 lut1->MapScalarsThroughTable2(charA, output, VTK_CHAR,
68 2, 1, VTK_RGB);
69 lut1->MapScalarsThroughTable2(charA, output, VTK_CHAR,
70 2, 1, VTK_LUMINANCE_ALPHA);
71 lut1->MapScalarsThroughTable2(charA, output, VTK_CHAR,
72 2, 1, VTK_LUMINANCE);
73
74 unsigned char ucharA[2] = {0, 10};
75 lut1->MapScalarsThroughTable2(ucharA, output, VTK_UNSIGNED_CHAR,
76 2, 1, VTK_RGBA);
77 lut1->MapScalarsThroughTable2(ucharA, output, VTK_UNSIGNED_CHAR,
78 2, 1, VTK_RGB);
79 lut1->MapScalarsThroughTable2(ucharA, output, VTK_UNSIGNED_CHAR,
80 2, 1, VTK_LUMINANCE_ALPHA);
81 lut1->MapScalarsThroughTable2(ucharA, output, VTK_UNSIGNED_CHAR,
82 2, 1, VTK_LUMINANCE);
83
84 int intA[2] = {0, 10};
85 lut1->MapScalarsThroughTable2(intA, output, VTK_INT,
86 2, 1, VTK_RGBA);
87 lut1->MapScalarsThroughTable2(intA, output, VTK_INT,
88 2, 1, VTK_RGB);
89 lut1->MapScalarsThroughTable2(intA, output, VTK_INT,
90 2, 1, VTK_LUMINANCE_ALPHA);
91 lut1->MapScalarsThroughTable2(intA, output, VTK_INT,
92 2, 1, VTK_LUMINANCE);
93
94 unsigned int uintA[2] = {0, 10};
95 lut1->MapScalarsThroughTable2(uintA, output, VTK_UNSIGNED_INT,
96 2, 1, VTK_RGBA);
97 lut1->MapScalarsThroughTable2(uintA, output, VTK_UNSIGNED_INT,
98 2, 1, VTK_RGB);
99 lut1->MapScalarsThroughTable2(uintA, output, VTK_UNSIGNED_INT,
100 2, 1, VTK_LUMINANCE_ALPHA);
101 lut1->MapScalarsThroughTable2(uintA, output, VTK_UNSIGNED_INT,
102 2, 1, VTK_LUMINANCE);
103
104 long longA[2] = {0, 10};
105 lut1->MapScalarsThroughTable2(longA, output, VTK_LONG,
106 2, 1, VTK_RGBA);
107 lut1->MapScalarsThroughTable2(longA, output, VTK_LONG,
108 2, 1, VTK_RGB);
109 lut1->MapScalarsThroughTable2(longA, output, VTK_LONG,
110 2, 1, VTK_LUMINANCE_ALPHA);
111 lut1->MapScalarsThroughTable2(longA, output, VTK_LONG,
112 2, 1, VTK_LUMINANCE);
113
114 unsigned long ulongA[2] = {0, 10};
115 lut1->MapScalarsThroughTable2(ulongA, output, VTK_UNSIGNED_LONG,
116 2, 1, VTK_RGBA);
117 lut1->MapScalarsThroughTable2(ulongA, output, VTK_UNSIGNED_LONG,
118 2, 1, VTK_RGB);
119 lut1->MapScalarsThroughTable2(ulongA, output, VTK_UNSIGNED_LONG,
120 2, 1, VTK_LUMINANCE_ALPHA);
121 lut1->MapScalarsThroughTable2(ulongA, output, VTK_UNSIGNED_LONG, 2, 1, VTK_LUMINANCE);
122
123 short shortA[2] = {0, 10};
124 lut1->MapScalarsThroughTable2(shortA, output, VTK_SHORT,
125 2, 1, VTK_RGBA);
126 lut1->MapScalarsThroughTable2(shortA, output, VTK_SHORT,
127 2, 1, VTK_RGB);
128 lut1->MapScalarsThroughTable2(shortA, output, VTK_SHORT,
129 2, 1, VTK_LUMINANCE_ALPHA);
130 lut1->MapScalarsThroughTable2(shortA, output, VTK_SHORT,
131 2, 1, VTK_LUMINANCE);
132
133 unsigned short ushortA[2] = {0, 10};
134 lut1->MapScalarsThroughTable2(ushortA, output,
135 VTK_UNSIGNED_SHORT, 2, 1, VTK_RGBA);
136 lut1->MapScalarsThroughTable2(ushortA, output,
137 VTK_UNSIGNED_SHORT, 2, 1, VTK_RGB);
138 lut1->MapScalarsThroughTable2(ushortA, output,
139 VTK_UNSIGNED_SHORT, 2, 1, VTK_LUMINANCE_ALPHA);
140 lut1->MapScalarsThroughTable2(ushortA, output,
141 VTK_UNSIGNED_SHORT, 2, 1, VTK_LUMINANCE);
142
143 float floatA[2] = {0, 10};
144 lut1->MapScalarsThroughTable2(floatA, output,
145 VTK_FLOAT, 2, 1, VTK_RGBA);
146 lut1->MapScalarsThroughTable2(floatA, output,
147 VTK_FLOAT, 2, 1, VTK_RGB);
148 lut1->MapScalarsThroughTable2(floatA, output,
149 VTK_FLOAT, 2, 1, VTK_LUMINANCE_ALPHA);
150 lut1->MapScalarsThroughTable2(floatA, output,
151 VTK_FLOAT, 2, 1, VTK_LUMINANCE);
152
153 double doubleA[2] = {0, 10};
154 lut1->MapScalarsThroughTable2(doubleA, output,
155 VTK_DOUBLE, 2, 1, VTK_RGBA);
156 lut1->MapScalarsThroughTable2(doubleA, output,
157 VTK_DOUBLE, 2, 1, VTK_RGB);
158 lut1->MapScalarsThroughTable2(doubleA, output,
159 VTK_DOUBLE, 2, 1, VTK_LUMINANCE_ALPHA);
160 lut1->MapScalarsThroughTable2(doubleA, output,
161 VTK_DOUBLE, 2, 1, VTK_LUMINANCE);
162
163
164 }
165
166
otherLookupTableWithEnabling(int,char * [])167 int otherLookupTableWithEnabling(int,char *[])
168 {
169 vtkLookupTableWithEnabling *lut1 = vtkLookupTableWithEnabling::New();
170 lut1->SetAlpha(1.0);
171 lut1->SetScaleToLinear();
172 TestOLT(lut1);
173 lut1->SetAlpha(.5);
174 TestOLT(lut1);
175 lut1->Delete();
176
177 vtkLookupTableWithEnabling *lut2 = vtkLookupTableWithEnabling::New();
178 lut2->SetAlpha(1.0);
179 lut2->SetScaleToLog10();
180 TestOLT(lut2);
181 lut2->SetAlpha(.5);
182 TestOLT(lut2);
183 lut2->Delete();
184
185 return 0;
186 }
187