-
Notifications
You must be signed in to change notification settings - Fork 4
/
ArrayRange.tar
103 lines (89 loc) · 10 KB
/
ArrayRange.tar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
ArrayRange/ 0000755 0000765 0000024 00000000000 13424703035 014062 5 ustar lorensen staff 0000000 0000000 ArrayRange/ArrayRange.cxx 0000644 0000765 0000024 00000003716 13424703035 016650 0 ustar lorensen staff 0000000 0000000 #include <vtkSmartPointer.h>
#include <vtkFloatArray.h>
#include <vtkIntArray.h>
int main(int, char *[])
{
/////////// Floats ///////////
{
vtkSmartPointer<vtkFloatArray> distances =
vtkSmartPointer<vtkFloatArray>::New();
distances->SetNumberOfComponents(1);
distances->SetName("Distances");
distances->InsertNextValue(5);
distances->InsertNextValue(15);
distances->InsertNextValue(25);
// Get min and max
double range[2];
distances->GetRange(range);
std::cout << "range = " << range[0] << " " << range[1] << std::endl;
}
/////////////// Ints //////////////
{
vtkSmartPointer<vtkIntArray> ints =
vtkSmartPointer<vtkIntArray>::New();
ints->SetNumberOfComponents(1);
ints->SetName("Ints");
ints->InsertNextValue(5);
ints->InsertNextValue(15);
ints->InsertNextValue(25);
// Get min and max
int valuesRange[2];
ints->GetValueRange(valuesRange); // Note this is not GetRange()!
std::cout << "valuesRange = " << valuesRange[0] << " " << valuesRange[1] << std::endl;
}
/////////// Range with negative values ///////////
{
vtkSmartPointer<vtkIntArray> ints =
vtkSmartPointer<vtkIntArray>::New();
ints->SetNumberOfComponents(1);
ints->SetName("Ints");
ints->InsertNextValue(-50);
ints->InsertNextValue(15);
ints->InsertNextValue(25);
// Get min and max
int valuesRange[2];
ints->GetValueRange(valuesRange); // Note this is not GetRange()!
std::cout << "valuesRange = " << valuesRange[0] << " " << valuesRange[1] << std::endl;
}
/////////// Magnitude range ///////////
{
vtkSmartPointer<vtkIntArray> ints =
vtkSmartPointer<vtkIntArray>::New();
ints->SetNumberOfComponents(1);
ints->SetName("Ints");
ints->InsertNextValue(-50);
ints->InsertNextValue(15);
ints->InsertNextValue(25);
// Get min and max
int valuesRange[2];
ints->GetValueRange(valuesRange, -1);
std::cout << "valuesRange = " << valuesRange[0] << " " << valuesRange[1] << std::endl;
}
return EXIT_SUCCESS;
}