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
itkNumericTraitsVectorPixel.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 __itkNumericTraitsVectorPixel_h
19
#define __itkNumericTraitsVectorPixel_h
20
21
#include "
itkNumericTraits.h
"
22
#include "
itkVector.h
"
23
24
namespace
itk
25
{
30
template
<
typename
T,
unsigned
int
D >
31
class
NumericTraits
<
Vector
< T, D > >
32
{
33
private
:
34
35
typedef
typename
NumericTraits< T >::AbsType
ElementAbsType
;
36
typedef
typename
NumericTraits< T >::AccumulateType
ElementAccumulateType
;
37
typedef
typename
NumericTraits< T >::FloatType
ElementFloatType
;
38
typedef
typename
NumericTraits< T >::PrintType
ElementPrintType
;
39
typedef
typename
NumericTraits< T >::RealType
ElementRealType
;
40
41
public
:
42
44
typedef
T
ValueType
;
45
typedef
Vector< T, D >
Self
;
46
48
typedef
Vector< ElementAbsType, D >
AbsType
;
49
51
typedef
Vector< ElementAccumulateType, D >
AccumulateType
;
52
55
typedef
Vector< ElementFloatType, D >
FloatType
;
56
58
typedef
Vector< ElementPrintType, D >
PrintType
;
59
61
typedef
Vector< ElementRealType, D >
RealType
;
62
64
typedef
ElementRealType
ScalarRealType
;
65
67
typedef
Self
MeasurementVectorType
;
68
74
static
const
Self
max
(
const
Self
&)
75
{
76
return
Self
(
NumericTraits< T >::max
() );
77
}
78
79
static
const
Self
min
(
const
Self
&)
80
{
81
return
Self
(
NumericTraits< T >::min
() );
82
}
83
84
static
const
Self
max
()
85
{
86
return
Self
(
NumericTraits< T >::max
() );
87
}
88
89
static
const
Self
min
()
90
{
91
return
Self
(
NumericTraits< T >::min
() );
92
}
93
94
static
const
Self
NonpositiveMin
()
95
{
96
return
Self
(
NumericTraits< T >::NonpositiveMin
() );
97
}
98
99
static
const
Self
ZeroValue
()
100
{
101
return
Self
(
NumericTraits< T >::ZeroValue
() );
102
}
103
104
static
const
Self
OneValue
()
105
{
106
return
Self
(
NumericTraits< T >::OneValue
() );
107
}
108
109
static
const
Self
NonpositiveMin
(
const
Self
&)
110
{
111
return
NonpositiveMin
();
112
}
113
114
static
const
Self
ZeroValue
(
const
Self
&)
115
{
116
return
ZeroValue
();
117
}
118
119
static
const
Self
OneValue
(
const
Self
&)
120
{
121
return
OneValue
();
122
}
123
124
static
bool
IsPositive
(
const
Self
& a)
125
{
126
bool
flag =
false
;
127
for
(
unsigned
int
i=0; i <
GetLength
( a ); i++)
128
{
129
if
( a[i] >
NumericTraits< ValueType >::ZeroValue
() )
130
{
131
flag =
true
;
132
}
133
}
134
return
flag;
135
}
136
137
static
bool
IsNonpositive
(
const
Self
& a)
138
{
139
bool
flag =
false
;
140
for
(
unsigned
int
i=0; i <
GetLength
( a ); i++)
141
{
142
if
( ! (a[i] > 0.0 ) )
143
{
144
flag =
true
;
145
}
146
}
147
return
flag;
148
}
149
150
static
bool
IsNegative
(
const
Self
& a)
151
{
152
bool
flag =
false
;
153
for
(
unsigned
int
i=0; i <
GetLength
( a ); i++)
154
{
155
if
( a[i] < 0.0 )
156
{
157
flag =
true
;
158
}
159
}
160
return
flag;
161
}
162
163
static
bool
IsNonnegative
(
const
Self
& a)
164
{
165
bool
flag =
false
;
166
for
(
unsigned
int
i=0; i <
GetLength
( a ); i++)
167
{
168
if
( ! (a[i] < 0.0 ))
169
{
170
flag =
true
;
171
}
172
}
173
return
flag;
174
}
175
179
static
void
SetLength
(
Vector< T, D >
& m,
const
unsigned
int
s)
180
{
181
if
( s != D )
182
{
183
itkGenericExceptionMacro(<<
"Cannot set the size of a Vector of length "
184
<< D <<
" to "
<< s);
185
}
186
m.
Fill
(
NumericTraits< T >::Zero
);
187
}
189
191
static
unsigned
int
GetLength
(
const
Vector< T, D >
&)
192
{
193
return
D;
194
}
195
197
static
unsigned
int
GetLength
()
198
{
199
return
D;
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<D; i++ )
211
{
212
mv[i] = v[i];
213
}
214
}
215
219
static
const
Self
ITKCommon_EXPORT
Zero
;
220
static
const
Self
ITKCommon_EXPORT
One
;
221
};
222
}
// end namespace itk
223
224
#endif // __itkNumericTraitsVectorPixel_h
225
Generated on Mon May 13 2013 01:03:06 for ITK by
1.8.3.1