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
itkNumericTraitsVariableLengthVectorPixel.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 __itkNumericTraitsVariableLengthVectorPixel_h
19
#define __itkNumericTraitsVariableLengthVectorPixel_h
20
21
#include "
itkVariableLengthVector.h
"
22
23
// This work is part of the National Alliance for Medical Image Computing
24
// (NAMIC), funded by the National Institutes of Health through the NIH Roadmap
25
// for Medical Research, Grant U54 EB005149.
26
27
namespace
itk
28
{
53
template
<
typename
T >
54
class
NumericTraits
<
VariableLengthVector
< T > >
55
{
56
public
:
57
58
typedef
typename
NumericTraits< T >::AbsType
ElementAbsType
;
59
typedef
typename
NumericTraits< T >::AccumulateType
ElementAccumulateType
;
60
typedef
typename
NumericTraits< T >::FloatType
ElementFloatType
;
61
typedef
typename
NumericTraits< T >::PrintType
ElementPrintType
;
62
typedef
typename
NumericTraits< T >::RealType
ElementRealType
;
63
65
typedef
T
ValueType
;
66
67
typedef
VariableLengthVector< T >
Self
;
68
70
typedef
VariableLengthVector< ElementAbsType >
AbsType
;
71
73
typedef
VariableLengthVector< ElementAccumulateType >
AccumulateType
;
74
77
typedef
VariableLengthVector< ElementFloatType >
FloatType
;
78
80
typedef
VariableLengthVector< ElementPrintType >
PrintType
;
81
83
typedef
VariableLengthVector< ElementRealType >
RealType
;
84
86
typedef
ElementRealType
ScalarRealType
;
87
89
typedef
Self
MeasurementVectorType
;
90
96
static
const
Self
max
(
const
Self
& a)
97
{
98
Self
b( a.
Size
() );
99
100
b.
Fill
(
NumericTraits< T >::max
() );
101
return
b;
102
}
103
104
static
const
Self
min
(
const
Self
& a)
105
{
106
Self
b( a.
Size
() );
107
108
b.
Fill
(
NumericTraits< T >::min
() );
109
return
b;
110
}
111
112
static
const
Self
ZeroValue
(
const
Self
& a)
113
{
114
Self
b( a.
Size
() );
115
116
b.
Fill
(
NumericTraits< T >::Zero
);
117
return
b;
118
}
119
120
static
const
Self
OneValue
(
const
Self
& a)
121
{
122
Self
b( a.
Size
() );
123
124
b.
Fill
(
NumericTraits< T >::One
);
125
return
b;
126
}
127
128
static
const
Self
NonpositiveMin
(
const
Self
& a)
129
{
130
Self
b( a.
Size
() );
131
b.
Fill
(
NumericTraits< T >::NonpositiveMin
() );
132
return
b;
133
}
134
136
static
void
SetLength
(
VariableLengthVector< T >
& m,
const
unsigned
int
s)
137
{
138
m.
SetSize
(s);
139
m.
Fill
(
NumericTraits< T >::Zero
);
140
}
142
144
static
unsigned
int
GetLength
(
const
VariableLengthVector< T >
& m)
145
{
146
return
m.
GetSize
();
147
}
148
149
static
void
AssignToArray
(
const
Self
& v,
MeasurementVectorType
& mv )
150
{
151
mv = v;
152
}
153
154
template
<
class
TArray>
155
static
void
AssignToArray
(
const
Self
& v, TArray & mv )
156
{
157
for
(
unsigned
int
i=0; i<
GetLength
(v); i++ )
158
{
159
mv[i] = v[i];
160
}
161
}
162
163
#if !defined(ITK_LEGACY_REMOVE)
164
//The extra #ifdef is need because the itkLegacyMacro
165
//can not format a static const member function properly
166
//in the case of removing the code.
167
169
itkLegacyMacro(
static
const
Self
Zero
(
const
Self & a))
170
{
171
Self b( a.Size() );
172
173
b.
Fill
(
NumericTraits< T >::Zero
);
174
return
b;
175
}
177
itkLegacyMacro(
static
const
Self
One
(
const
Self & a))
178
{
179
Self b( a.Size() );
180
181
b.Fill(NumericTraits< T >::One);
182
return
b;
183
}
184
#endif
185
186
};
187
}
// end namespace itk
188
189
#endif // __itkNumericTraitsVariableLengthVector_h
190
Generated on Tue Jul 10 2012 23:38:42 for ITK by
1.8.1