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
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
135
static
bool
IsPositive
(
const
Self
& a)
136
{
137
bool
flag =
false
;
138
for
(
unsigned
int
i=0; i <
GetLength
( a ); i++)
139
{
140
if
( a[i] >
NumericTraits< ValueType >::ZeroValue
() )
141
{
142
flag =
true
;
143
}
144
}
145
return
flag;
146
}
147
148
static
bool
IsNonpositive
(
const
Self
& a)
149
{
150
bool
flag =
false
;
151
for
(
unsigned
int
i=0; i <
GetLength
( a ); i++)
152
{
153
if
( ! (a[i] > 0.0 ) )
154
{
155
flag =
true
;
156
}
157
}
158
return
flag;
159
}
160
161
static
bool
IsNegative
(
const
Self
& a)
162
{
163
bool
flag =
false
;
164
for
(
unsigned
int
i=0; i <
GetLength
( a ); i++)
165
{
166
if
( a[i] <
NumericTraits< ValueType >::ZeroValue
() )
167
{
168
flag =
true
;
169
}
170
}
171
return
flag;
172
}
173
174
static
bool
IsNonnegative
(
const
Self
& a)
175
{
176
bool
flag =
false
;
177
for
(
unsigned
int
i=0; i <
GetLength
( a ); i++)
178
{
179
if
( ! (a[i] < 0.0 ))
180
{
181
flag =
true
;
182
}
183
}
184
return
flag;
185
}
186
187
189
static
void
SetLength
(
VariableLengthVector< T >
& m,
const
unsigned
int
s)
190
{
191
m.
SetSize
(s);
192
m.
Fill
(
NumericTraits< T >::Zero
);
193
}
195
197
static
unsigned
int
GetLength
(
const
VariableLengthVector< T >
& m)
198
{
199
return
m.
GetSize
();
200
}
201
202
static
void
AssignToArray
(
const
Self
& v,
MeasurementVectorType
& mv )
203
{
204
mv = v;
205
}
206
207
template
<
class
TArray>
208
static
void
AssignToArray
(
const
Self
& v, TArray & mv )
209
{
210
for
(
unsigned
int
i=0; i<
GetLength
(v); i++ )
211
{
212
mv[i] = v[i];
213
}
214
}
215
216
#if !defined(ITK_LEGACY_REMOVE)
217
//The extra #ifdef is need because the itkLegacyMacro
218
//can not format a static const member function properly
219
//in the case of removing the code.
220
222
itkLegacyMacro(
static
const
Self
Zero
(
const
Self & a))
223
{
224
Self b( a.Size() );
225
226
b.
Fill
(
NumericTraits< T >::Zero
);
227
return
b;
228
}
230
itkLegacyMacro(
static
const
Self
One
(
const
Self & a))
231
{
232
Self b( a.Size() );
233
234
b.Fill(NumericTraits< T >::One);
235
return
b;
236
}
237
#endif
238
239
};
240
}
// end namespace itk
241
242
#endif // __itkNumericTraitsVariableLengthVector_h
243
Generated on Mon May 13 2013 01:03:06 for ITK by
1.8.3.1