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
itkNumericTraitsArrayPixel.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 __itkNumericTraitsArrayPixel_h
19
#define __itkNumericTraitsArrayPixel_h
20
21
#include "
itkNumericTraits.h
"
22
#include "
itkArray.h
"
23
24
namespace
itk
25
{
29
template
<
typename
T >
30
class
NumericTraits
<
Array
< T > >
31
{
32
private
:
33
34
typedef
typename
NumericTraits< T >::AbsType
ElementAbsType
;
35
typedef
typename
NumericTraits< T >::AccumulateType
ElementAccumulateType
;
36
typedef
typename
NumericTraits< T >::FloatType
ElementFloatType
;
37
typedef
typename
NumericTraits< T >::PrintType
ElementPrintType
;
38
typedef
typename
NumericTraits< T >::RealType
ElementRealType
;
39
public
:
40
42
typedef
T
ValueType
;
43
typedef
Array< T >
Self
;
44
46
typedef
Array< ElementAbsType >
AbsType
;
47
49
typedef
Array< ElementAccumulateType >
AccumulateType
;
50
53
typedef
Array< ElementFloatType >
FloatType
;
54
56
typedef
Array< ElementPrintType >
PrintType
;
57
59
typedef
Array< ElementRealType >
RealType
;
60
62
typedef
ElementRealType
ScalarRealType
;
63
65
typedef
Self
MeasurementVectorType
;
66
72
static
const
Self
max
(
const
Self
& a)
73
{
74
Self
b( a.
Size
() );
75
76
b.
Fill
(
NumericTraits< T >::max
() );
77
return
b;
78
}
79
80
static
const
Self
min
(
const
Self
& a)
81
{
82
Self
b( a.
Size
() );
83
84
b.
Fill
(
NumericTraits< T >::min
() );
85
return
b;
86
}
87
88
static
const
Self
ZeroValue
(
const
Self
& a)
89
{
90
Self
b( a.
Size
() );
91
92
b.
Fill
(
NumericTraits< T >::Zero
);
93
return
b;
94
}
95
96
static
const
Self
OneValue
(
const
Self
& a)
97
{
98
Self
b( a.
Size
() );
99
100
b.
Fill
(
NumericTraits< T >::One
);
101
return
b;
102
}
103
104
static
const
Self
NonpositiveMin
(
const
Self
& a)
105
{
106
Self
b( a.
Size
() );
107
b.
Fill
(
NumericTraits< T >::NonpositiveMin
() );
108
return
b;
109
}
110
112
static
void
SetLength
(
Array< T >
& m,
const
unsigned
int
s)
113
{
114
m.
SetSize
(s);
115
m.
Fill
(
NumericTraits< T >::Zero
);
116
}
118
120
static
unsigned
int
GetLength
(
const
Array< T >
& m)
121
{
122
return
m.
GetSize
();
123
}
124
125
static
void
AssignToArray
(
const
Self
& v,
MeasurementVectorType
& mv )
126
{
127
mv = v;
128
}
129
130
template
<
class
TArray>
131
static
void
AssignToArray
(
const
Self
& v, TArray & mv )
132
{
133
for
(
unsigned
int
i=0; i<
GetLength
(v); i++ )
134
{
135
mv[i] = v[i];
136
}
137
}
138
139
#if !defined(ITK_LEGACY_REMOVE)
140
//The extra #ifdef is need because the itkLegacyMacro
141
//can not format a static const member function properly
142
//in the case of removing the code.
143
145
itkLegacyMacro(
static
const
Self
Zero
(
const
Self & a))
146
{
147
Self b( a.Size() );
148
b.
Fill
(
NumericTraits< T >::Zero
);
149
return
b;
150
}
152
154
itkLegacyMacro(
static
const
Self
One
(
const
Self & a))
155
{
156
Self b( a.Size() );
157
b.Fill(NumericTraits< T >::One);
158
return
b;
159
}
160
#endif
161
162
163
};
164
}
// end namespace itk
165
166
#endif // __itkNumericTraitsArrayPixel_h
167
Generated on Tue Jul 10 2012 23:38:41 for ITK by
1.8.1