ITK
4.2.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
private
:
159
160
bool
m_LetArrayManageMemory
;
161
};
162
163
template
<
typename
TValueType >
164
std::ostream & operator<<(std::ostream & os, const Array< TValueType > & arr)
165
{
166
const
unsigned
int
length = arr.size();
167
const
signed
int
last = (
unsigned
int)length - 1;
168
169
os <<
"["
;
170
for
(
signed
int
i = 0; i < last; ++i )
171
{
172
os << arr[i] <<
", "
;
173
}
174
if
( length >= 1 )
175
{
176
os << arr[last];
177
}
178
os <<
"]"
;
179
return
os;
180
}
181
}
// namespace itk
182
183
// Define instantiation macro for this template.
184
#define ITK_TEMPLATE_Array(_, EXPORT, TypeX, TypeY) \
185
namespace itk \
186
{ \
187
_( 1 ( class EXPORT Array< ITK_TEMPLATE_1 TypeX > ) ) \
188
_( 1 ( EXPORT std::ostream & operator<<(std::ostream &, \
189
const Array< ITK_TEMPLATE_1 TypeX > &) ) ) \
190
namespace Templates \
191
{ \
192
typedef Array< ITK_TEMPLATE_1 TypeX > Array##TypeY; \
193
} \
194
}
195
196
#if ITK_TEMPLATE_EXPLICIT
197
#include "Templates/itkArray+-.h"
198
#endif
199
200
#if ITK_TEMPLATE_TXX
201
#include "itkArray.hxx"
202
#endif
203
204
#endif
205
Generated on Tue Jul 10 2012 23:17:59 for ITK by
1.8.1