VTK
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
dox
Common
vtkDenseArray.h
Go to the documentation of this file.
1
/*=========================================================================
2
3
Program: Visualization Toolkit
4
Module: vtkDenseArray.h
5
6
-------------------------------------------------------------------------
7
Copyright 2008 Sandia Corporation.
8
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9
the U.S. Government retains certain rights in this software.
10
-------------------------------------------------------------------------
11
12
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
13
All rights reserved.
14
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
15
16
This software is distributed WITHOUT ANY WARRANTY; without even
17
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18
PURPOSE. See the above copyright notice for more information.
19
20
=========================================================================*/
21
51
#ifndef __vtkDenseArray_h
52
#define __vtkDenseArray_h
53
54
#include "
vtkArrayCoordinates.h
"
55
#include "
vtkObjectFactory.h
"
56
#include "
vtkTypedArray.h
"
57
#include "
vtkTypeTemplate.h
"
58
59
template
<
typename
T>
60
class
vtkDenseArray
:
61
public
vtkTypeTemplate
<vtkDenseArray<T>, vtkTypedArray<T> >
62
{
63
public
:
64
static
vtkDenseArray<T>
*
New
();
65
void
PrintSelf
(ostream &os,
vtkIndent
indent);
66
67
typedef
typename
vtkArray::CoordinateT
CoordinateT
;
68
typedef
typename
vtkArray::DimensionT
DimensionT
;
69
typedef
typename
vtkArray::SizeT
SizeT
;
70
71
// vtkArray API
72
bool
IsDense
();
73
const
vtkArrayExtents
&
GetExtents
();
74
SizeT
GetNonNullSize
();
75
void
GetCoordinatesN
(
const
SizeT
n,
vtkArrayCoordinates
& coordinates);
76
vtkArray
*
DeepCopy
();
77
78
// vtkTypedArray API
79
const
T&
GetValue
(
CoordinateT
i);
80
const
T&
GetValue
(
CoordinateT
i,
CoordinateT
j);
81
const
T&
GetValue
(
CoordinateT
i,
CoordinateT
j,
CoordinateT
k);
82
const
T&
GetValue
(
const
vtkArrayCoordinates
& coordinates);
83
const
T&
GetValueN
(
const
SizeT
n);
84
void
SetValue
(
CoordinateT
i,
const
T&
value
);
85
void
SetValue
(
CoordinateT
i,
CoordinateT
j,
const
T&
value
);
86
void
SetValue
(
CoordinateT
i,
CoordinateT
j,
CoordinateT
k,
const
T&
value
);
87
void
SetValue
(
const
vtkArrayCoordinates
& coordinates,
const
T&
value
);
88
void
SetValueN
(
const
SizeT
n,
const
T&
value
);
89
90
// vtkDenseArray API
91
93
96
class
MemoryBlock
97
{
98
public
:
99
virtual
~MemoryBlock
();
100
// Description:
101
// Returns a pointer to the block of memory to be used for storage.
102
virtual
T*
GetAddress
() = 0;
103
};
105
107
110
class
HeapMemoryBlock
:
111
public
MemoryBlock
112
{
113
public
:
114
HeapMemoryBlock
(
const
vtkArrayExtents
& extents);
115
virtual
~HeapMemoryBlock
();
116
virtual
T*
GetAddress
();
118
119
private
:
120
T* Storage;
121
};
122
124
126
class
StaticMemoryBlock
:
127
public
MemoryBlock
128
{
129
public
:
130
StaticMemoryBlock
(T*
const
storage);
131
virtual
T*
GetAddress
();
133
134
private
:
135
T* Storage;
136
};
137
151
void
ExternalStorage
(
const
vtkArrayExtents
& extents,
MemoryBlock
* storage);
152
154
void
Fill
(
const
T&
value
);
155
158
T&
operator[]
(
const
vtkArrayCoordinates
& coordinates);
159
162
const
T*
GetStorage
()
const
;
163
166
T*
GetStorage
();
167
168
protected
:
169
vtkDenseArray
();
170
~vtkDenseArray
();
171
172
private
:
173
vtkDenseArray
(
const
vtkDenseArray
&);
// Not implemented
174
void
operator=(
const
vtkDenseArray
&);
// Not implemented
175
176
void
InternalResize(
const
vtkArrayExtents
& extents);
177
void
InternalSetDimensionLabel(
DimensionT
i,
const
vtkStdString
& label);
178
vtkStdString
InternalGetDimensionLabel(
DimensionT
i);
179
inline
vtkIdType
MapCoordinates(
CoordinateT
i);
180
inline
vtkIdType
MapCoordinates(
CoordinateT
i,
CoordinateT
j);
181
inline
vtkIdType
MapCoordinates(
CoordinateT
i,
CoordinateT
j,
CoordinateT
k);
182
inline
vtkIdType
MapCoordinates(
const
vtkArrayCoordinates
& coordinates);
183
184
void
Reconfigure(
const
vtkArrayExtents
& extents,
MemoryBlock
* storage);
185
186
typedef
vtkDenseArray<T>
ThisT
;
187
189
vtkArrayExtents
Extents;
190
192
std::vector<vtkStdString> DimensionLabels;
193
195
MemoryBlock
* Storage;
196
198
200
T* Begin;
201
T* End;
203
205
206
std::vector<vtkIdType> Offsets;
207
// Description:
208
// Stores the stride along each array dimension (used for fast lookups).
209
std::vector<vtkIdType> Strides;
210
};
212
213
#include "vtkDenseArray.txx"
214
215
#endif
216
Generated on Sun Sep 9 2012 13:03:26 for VTK by
1.8.1.2