ITK
4.3.0
Insight Segmentation and Registration Toolkit
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
ITK
Modules
Core
Common
include
itkArray.h
Go to the documentation of this file.
1
/*=========================================================================
2
*
3
* Copyright Insight Software Consortium
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0.txt
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
*=========================================================================*/
18
#ifndef __itkArray_h
19
#define __itkArray_h
20
21
#include "
itkMacro.h
"
22
23
#include "vxl_version.h"
24
#if VXL_VERSION_DATE_FULL < 20110428
25
#error "System installed VXL version is too old. Please make sure the version date is later than 2011-04-28."
26
#endif
27
28
#include "vnl/vnl_vector.h"
29
30
namespace
itk
31
{
49
template
<
typename
TValueType >
50
class
Array
:
public
vnl_vector
< TValueType >
51
{
52
public
:
53
55
typedef
TValueType
ValueType
;
56
typedef
Array
Self
;
57
typedef
vnl_vector< TValueType >
VnlVectorType
;
58
typedef
typename
vnl_vector< TValueType>::size_type
SizeValueType
;
59
60
public
:
61
64
Array
();
65
68
Array
(
const
Array
&);
69
71
explicit
Array
(
SizeValueType
dimension);
72
79
Array
(
ValueType
*data,
SizeValueType
sz,
bool
LetArrayManageMemory =
false
);
80
87
Array
(
const
ValueType
*data,
SizeValueType
sz,
88
bool
LetArrayManageMemory =
false
);
89
91
template
<
class
TArrayValue >
92
Array
(
const
Array< TArrayValue >
& r)
93
{
94
this->
m_LetArrayManageMemory
=
true
;
95
this->
SetSize
( r.
GetSize
() );
96
for
(
SizeValueType
i=0; i<r.
GetSize
(); i++ )
97
{
98
this->operator[](i) =
static_cast<
TValueType
>
( r[i] );
99
}
100
}
102
104
void
Fill
(TValueType
const
& v) { this->fill(v); }
105
107
const
Self
&
operator=
(
const
Self
& rhs);
108
109
const
Self
&
operator=
(
const
VnlVectorType
& rhs);
110
112
SizeValueType
Size
(
void
)
const
113
{
return
static_cast<
SizeValueType
>
( this->size() ); }
114
unsigned
int
GetNumberOfElements
(
void
)
const
115
{
return
static_cast<
SizeValueType
>
( this->size() ); }
117
119
const
TValueType &
GetElement
(
SizeValueType
i)
const
120
{
return
this->operator[](i); }
121
123
void
SetElement
(
SizeValueType
i,
const
TValueType & value)
124
{ this->operator[](i) = value; }
125
127
void
SetSize
(
SizeValueType
sz);
128
129
SizeValueType
GetSize
(
void
)
const
130
{
return
static_cast<
SizeValueType
>
( this->size() ); }
131
137
void
SetData
(TValueType *data,
bool
LetArrayManageMemory =
false
);
138
148
void
SetData
(TValueType *data,
SizeValueType
sz,
149
bool
LetArrayManageMemory =
false
);
150
151
152
#ifdef __INTEL_COMPILER
153
#pragma warning disable 444 //destructor for base class "itk::Array<>" is not virtual
154
#endif
155
157
~Array
();
158
159
private
:
160
161
bool
m_LetArrayManageMemory
;
162
};
163
164
template
<
typename
TValueType >
165
std::ostream & operator<<(std::ostream & os, const Array< TValueType > & arr)
166
{
167
const
unsigned
int
length = arr.size();
168
const
signed
int
last = (
unsigned
int)length - 1;
169
170
os <<
"["
;
171
for
(
signed
int
i = 0; i < last; ++i )
172
{
173
os << arr[i] <<
", "
;
174
}
175
if
( length >= 1 )
176
{
177
os << arr[last];
178
}
179
os <<
"]"
;
180
return
os;
181
}
182
}
// namespace itk
183
184
#ifndef ITK_MANUAL_INSTANTIATION
185
#include "itkArray.hxx"
186
#endif
187
188
#endif
189
Generated on Sun Dec 9 2012 00:45:46 for ITK by
1.8.2