-
Notifications
You must be signed in to change notification settings - Fork 4
/
3DArray.tar
62 lines (52 loc) · 10 KB
/
3DArray.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
3DArray/ 0000755 0000765 0000024 00000000000 13424703035 013274 5 ustar lorensen staff 0000000 0000000 3DArray/3DArray.cxx 0000644 0000765 0000024 00000001645 13424703035 015273 0 ustar lorensen staff 0000000 0000000 #include <vtkSmartPointer.h>
#include <vtkDenseArray.h>
int main(int, char *[])
{
// Create an N-D array
vtkSmartPointer<vtkDenseArray<double> > array =
vtkSmartPointer<vtkDenseArray<double> >::New();
// Resize the array to 4x5x3
array->Resize(4,5,3);
// Set a value
int i = 0; int j = 0; int k = 0;
double value = 3.0;
array->SetValue(i, j, k, value);
// Get a value
std::cout << array->GetValue(i,j,k) << std::endl;
// Get size (bounds) of whole array
cout << array->GetExtents() << endl;
// Get size (bounds) of array dimensions
std::cout << array->GetExtents()[0] << std::endl;
std::cout << array->GetExtents()[1] << std::endl;
std::cout << array->GetExtents()[2] << std::endl;
// Get the bounds of the 0th dimension
std::cout << array->GetExtents()[0].GetBegin() << std::endl;
std::cout << array->GetExtents()[0].GetEnd() << std::endl;
return EXIT_SUCCESS;
}