ITK
4.4.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
40
public
:
41
43
typedef
T
ValueType
;
44
typedef
Array< T >
Self
;
45
47
typedef
Array< ElementAbsType >
AbsType
;
48
50
typedef
Array< ElementAccumulateType >
AccumulateType
;
51
54
typedef
Array< ElementFloatType >
FloatType
;
55
57
typedef
Array< ElementPrintType >
PrintType
;
58
60
typedef
Array< ElementRealType >
RealType
;
61
63
typedef
ElementRealType
ScalarRealType
;
64
66
typedef
Self
MeasurementVectorType
;
67
73
static
const
Self
max
(
const
Self
& a)
74
{
75
Self
b( a.
Size
() );
76
77
b.
Fill
(
NumericTraits< T >::max
() );
78
return
b;
79
}
80
81
static
const
Self
min
(
const
Self
& a)
82
{
83
Self
b( a.
Size
() );
84
85
b.
Fill
(
NumericTraits< T >::min
() );
86
return
b;
87
}
88
89
static
const
Self
ZeroValue
(
const
Self
& a)
90
{
91
Self
b( a.
Size
() );
92
93
b.
Fill
(
NumericTraits< T >::Zero
);
94
return
b;
95
}
96
97
static
const
Self
OneValue
(
const
Self
& a)
98
{
99
Self
b( a.
Size
() );
100
101
b.
Fill
(
NumericTraits< T >::One
);
102
return
b;
103
}
104
105
static
const
Self
NonpositiveMin
(
const
Self
& a)
106
{
107
Self
b( a.
Size
() );
108
b.
Fill
(
NumericTraits< T >::NonpositiveMin
() );
109
return
b;
110
}
111
113
static
void
SetLength
(
Array< T >
& m,
const
unsigned
int
s)
114
{
115
m.
SetSize
(s);
116
m.
Fill
(
NumericTraits< T >::Zero
);
117
}
119
121
static
unsigned
int
GetLength
(
const
Array< T >
& m)
122
{
123
return
m.
GetSize
();
124
}
125
126
static
void
AssignToArray
(
const
Self
& v,
MeasurementVectorType
& mv )
127
{
128
mv = v;
129
}
130
131
template
<
class
TArray>
132
static
void
AssignToArray
(
const
Self
& v, TArray & mv )
133
{
134
for
(
unsigned
int
i=0; i<
GetLength
(v); i++ )
135
{
136
mv[i] = v[i];
137
}
138
}
139
140
#if !defined(ITK_LEGACY_REMOVE)
141
//The extra #ifdef is need because the itkLegacyMacro
142
//can not format a static const member function properly
143
//in the case of removing the code.
144
146
itkLegacyMacro(
static
const
Self
Zero
(
const
Self & a))
147
{
148
Self b( a.Size() );
149
b.
Fill
(
NumericTraits< T >::Zero
);
150
return
b;
151
}
153
155
itkLegacyMacro(
static
const
Self
One
(
const
Self & a))
156
{
157
Self b( a.Size() );
158
b.Fill(NumericTraits< T >::One);
159
return
b;
160
}
161
#endif
162
163
164
};
165
}
// end namespace itk
166
167
#endif // __itkNumericTraitsArrayPixel_h
168
Generated on Mon May 13 2013 01:03:05 for ITK by
1.8.3.1