Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Antoine Belvire
otb
Commits
098a5f13
Commit
098a5f13
authored
16 years ago
by
Emmanuel Christophe
Browse files
Options
Downloads
Patches
Plain Diff
ITK: adding Clamp method to itkNumericTraits
parent
03167448
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Utilities/ITK/Code/Common/itkNumericTraits.h
+47
-0
47 additions, 0 deletions
Utilities/ITK/Code/Common/itkNumericTraits.h
with
47 additions
and
0 deletions
Utilities/ITK/Code/Common/itkNumericTraits.h
+
47
−
0
View file @
098a5f13
...
@@ -183,6 +183,9 @@ public:
...
@@ -183,6 +183,9 @@ public:
static
bool
IsNonnegative
(
char
val
)
{
return
val
>=
Zero
;
}
static
bool
IsNonnegative
(
char
val
)
{
return
val
>=
Zero
;
}
static
char
ZeroValue
()
{
return
Zero
;
}
static
char
ZeroValue
()
{
return
Zero
;
}
static
char
OneValue
()
{
return
One
;
}
static
char
OneValue
()
{
return
One
;
}
static
ValueType
Clamp
(
ValueType
val
,
ValueType
minVal
,
ValueType
maxVal
)
{
return
val
<
minVal
?
minVal
:
(
val
>
maxVal
?
maxVal
:
val
);}
};
};
/** \class NumericTraits<char>
/** \class NumericTraits<char>
...
@@ -214,6 +217,9 @@ public:
...
@@ -214,6 +217,9 @@ public:
static
bool
IsNonnegative
(
signed
char
val
)
{
return
val
>=
Zero
;
}
static
bool
IsNonnegative
(
signed
char
val
)
{
return
val
>=
Zero
;
}
static
signed
char
ZeroValue
()
{
return
Zero
;
}
static
signed
char
ZeroValue
()
{
return
Zero
;
}
static
signed
char
OneValue
()
{
return
One
;
}
static
signed
char
OneValue
()
{
return
One
;
}
static
ValueType
Clamp
(
ValueType
val
,
ValueType
minVal
,
ValueType
maxVal
)
{
return
val
<
minVal
?
minVal
:
(
val
>
maxVal
?
maxVal
:
val
);}
};
};
/** \class NumericTraits<unsigned char>
/** \class NumericTraits<unsigned char>
...
@@ -243,6 +249,9 @@ public:
...
@@ -243,6 +249,9 @@ public:
static
bool
IsNonnegative
(
unsigned
char
/*val */
)
{
return
true
;
}
static
bool
IsNonnegative
(
unsigned
char
/*val */
)
{
return
true
;
}
static
unsigned
char
ZeroValue
()
{
return
Zero
;
}
static
unsigned
char
ZeroValue
()
{
return
Zero
;
}
static
unsigned
char
OneValue
()
{
return
One
;
}
static
unsigned
char
OneValue
()
{
return
One
;
}
static
ValueType
Clamp
(
ValueType
val
,
ValueType
minVal
,
ValueType
maxVal
)
{
return
val
<
minVal
?
minVal
:
(
val
>
maxVal
?
maxVal
:
val
);}
};
};
/** \class NumericTraits<short>
/** \class NumericTraits<short>
...
@@ -270,6 +279,9 @@ public:
...
@@ -270,6 +279,9 @@ public:
static
bool
IsNonnegative
(
short
val
)
{
return
val
>=
Zero
;
}
static
bool
IsNonnegative
(
short
val
)
{
return
val
>=
Zero
;
}
static
short
ZeroValue
()
{
return
Zero
;
}
static
short
ZeroValue
()
{
return
Zero
;
}
static
short
OneValue
()
{
return
One
;
}
static
short
OneValue
()
{
return
One
;
}
static
ValueType
Clamp
(
ValueType
val
,
ValueType
minVal
,
ValueType
maxVal
)
{
return
val
<
minVal
?
minVal
:
(
val
>
maxVal
?
maxVal
:
val
);}
};
};
/** \class NumericTraits<unsigned short>
/** \class NumericTraits<unsigned short>
...
@@ -298,6 +310,9 @@ public:
...
@@ -298,6 +310,9 @@ public:
static
bool
IsNonnegative
(
unsigned
short
/*val*/
)
{
return
true
;
}
static
bool
IsNonnegative
(
unsigned
short
/*val*/
)
{
return
true
;
}
static
unsigned
short
ZeroValue
()
{
return
Zero
;
}
static
unsigned
short
ZeroValue
()
{
return
Zero
;
}
static
unsigned
short
OneValue
()
{
return
One
;
}
static
unsigned
short
OneValue
()
{
return
One
;
}
static
ValueType
Clamp
(
ValueType
val
,
ValueType
minVal
,
ValueType
maxVal
)
{
return
val
<
minVal
?
minVal
:
(
val
>
maxVal
?
maxVal
:
val
);}
};
};
/** \class NumericTraits<int>
/** \class NumericTraits<int>
...
@@ -325,6 +340,9 @@ public:
...
@@ -325,6 +340,9 @@ public:
static
bool
IsNonnegative
(
int
val
)
{
return
val
>=
Zero
;
}
static
bool
IsNonnegative
(
int
val
)
{
return
val
>=
Zero
;
}
static
int
ZeroValue
()
{
return
Zero
;
}
static
int
ZeroValue
()
{
return
Zero
;
}
static
int
OneValue
()
{
return
One
;
}
static
int
OneValue
()
{
return
One
;
}
static
ValueType
Clamp
(
ValueType
val
,
ValueType
minVal
,
ValueType
maxVal
)
{
return
val
<
minVal
?
minVal
:
(
val
>
maxVal
?
maxVal
:
val
);}
};
};
/** \class NumericTraits<unsigned int>
/** \class NumericTraits<unsigned int>
...
@@ -356,6 +374,9 @@ public:
...
@@ -356,6 +374,9 @@ public:
static
bool
IsNonnegative
(
unsigned
int
/*val*/
)
{
return
true
;
}
static
bool
IsNonnegative
(
unsigned
int
/*val*/
)
{
return
true
;
}
static
unsigned
int
ZeroValue
()
{
return
Zero
;
}
static
unsigned
int
ZeroValue
()
{
return
Zero
;
}
static
unsigned
int
OneValue
()
{
return
One
;
}
static
unsigned
int
OneValue
()
{
return
One
;
}
static
ValueType
Clamp
(
ValueType
val
,
ValueType
minVal
,
ValueType
maxVal
)
{
return
val
<
minVal
?
minVal
:
(
val
>
maxVal
?
maxVal
:
val
);}
};
};
/** \class NumericTraits<long>
/** \class NumericTraits<long>
...
@@ -384,6 +405,9 @@ public:
...
@@ -384,6 +405,9 @@ public:
static
bool
IsNonnegative
(
long
val
)
{
return
val
>=
Zero
;
}
static
bool
IsNonnegative
(
long
val
)
{
return
val
>=
Zero
;
}
static
long
ZeroValue
()
{
return
Zero
;
}
static
long
ZeroValue
()
{
return
Zero
;
}
static
long
OneValue
()
{
return
One
;
}
static
long
OneValue
()
{
return
One
;
}
static
ValueType
Clamp
(
ValueType
val
,
ValueType
minVal
,
ValueType
maxVal
)
{
return
val
<
minVal
?
minVal
:
(
val
>
maxVal
?
maxVal
:
val
);}
};
};
/** \class NumericTraits<unsigned long>
/** \class NumericTraits<unsigned long>
...
@@ -412,6 +436,9 @@ public:
...
@@ -412,6 +436,9 @@ public:
static
bool
IsNonnegative
(
unsigned
long
)
{
return
true
;
}
static
bool
IsNonnegative
(
unsigned
long
)
{
return
true
;
}
static
unsigned
long
ZeroValue
()
{
return
Zero
;
}
static
unsigned
long
ZeroValue
()
{
return
Zero
;
}
static
unsigned
long
OneValue
()
{
return
One
;
}
static
unsigned
long
OneValue
()
{
return
One
;
}
static
ValueType
Clamp
(
ValueType
val
,
ValueType
minVal
,
ValueType
maxVal
)
{
return
val
<
minVal
?
minVal
:
(
val
>
maxVal
?
maxVal
:
val
);}
};
};
/** \class NumericTraits<float>
/** \class NumericTraits<float>
...
@@ -440,6 +467,9 @@ public:
...
@@ -440,6 +467,9 @@ public:
static
bool
IsNonnegative
(
float
val
)
{
return
val
>=
Zero
;
}
static
bool
IsNonnegative
(
float
val
)
{
return
val
>=
Zero
;
}
static
float
ZeroValue
()
{
return
Zero
;
}
static
float
ZeroValue
()
{
return
Zero
;
}
static
float
OneValue
()
{
return
One
;
}
static
float
OneValue
()
{
return
One
;
}
static
ValueType
Clamp
(
ValueType
val
,
ValueType
minVal
,
ValueType
maxVal
)
{
return
val
<
minVal
?
minVal
:
(
val
>
maxVal
?
maxVal
:
val
);}
};
};
/** \class NumericTraits<double>
/** \class NumericTraits<double>
...
@@ -468,6 +498,9 @@ public:
...
@@ -468,6 +498,9 @@ public:
static
bool
IsNonnegative
(
double
val
)
{
return
val
>=
Zero
;
}
static
bool
IsNonnegative
(
double
val
)
{
return
val
>=
Zero
;
}
static
double
ZeroValue
()
{
return
Zero
;
}
static
double
ZeroValue
()
{
return
Zero
;
}
static
double
OneValue
()
{
return
One
;
}
static
double
OneValue
()
{
return
One
;
}
static
ValueType
Clamp
(
ValueType
val
,
ValueType
minVal
,
ValueType
maxVal
)
{
return
val
<
minVal
?
minVal
:
(
val
>
maxVal
?
maxVal
:
val
);}
};
};
/** \class NumericTraits<long double>
/** \class NumericTraits<long double>
...
@@ -496,6 +529,9 @@ public:
...
@@ -496,6 +529,9 @@ public:
static
bool
IsNonnegative
(
long
double
val
)
{
return
val
>=
Zero
;
}
static
bool
IsNonnegative
(
long
double
val
)
{
return
val
>=
Zero
;
}
static
long
double
ZeroValue
()
{
return
Zero
;
}
static
long
double
ZeroValue
()
{
return
Zero
;
}
static
long
double
OneValue
()
{
return
One
;
}
static
long
double
OneValue
()
{
return
One
;
}
static
ValueType
Clamp
(
ValueType
val
,
ValueType
minVal
,
ValueType
maxVal
)
{
return
val
<
minVal
?
minVal
:
(
val
>
maxVal
?
maxVal
:
val
);}
};
};
/** \class NumericTraits< std::complex<float> >
/** \class NumericTraits< std::complex<float> >
...
@@ -527,6 +563,12 @@ public:
...
@@ -527,6 +563,12 @@ public:
static
bool
IsNonnegative
(
TheType
val
)
{
return
val
.
real
()
>=
0.0
;
}
static
bool
IsNonnegative
(
TheType
val
)
{
return
val
.
real
()
>=
0.0
;
}
static
TheType
ZeroValue
()
{
return
Zero
;
}
static
TheType
ZeroValue
()
{
return
Zero
;
}
static
TheType
OneValue
()
{
return
One
;
}
static
TheType
OneValue
()
{
return
One
;
}
static
TheType
Clamp
(
TheType
val
,
TheType
minVal
,
TheType
maxVal
)
{
return
TheType
(
NumericTraits
<
ValueType
>::
Clamp
(
val
.
real
(),
minVal
.
real
(),
maxVal
.
real
()),
NumericTraits
<
ValueType
>::
Clamp
(
val
.
imag
(),
minVal
.
imag
(),
maxVal
.
imag
()));
}
};
};
...
@@ -559,6 +601,11 @@ public:
...
@@ -559,6 +601,11 @@ public:
static
bool
IsNonnegative
(
TheType
val
)
{
return
val
.
real
()
>=
0.0
;
}
static
bool
IsNonnegative
(
TheType
val
)
{
return
val
.
real
()
>=
0.0
;
}
static
TheType
ZeroValue
()
{
return
Zero
;
}
static
TheType
ZeroValue
()
{
return
Zero
;
}
static
TheType
OneValue
()
{
return
One
;
}
static
TheType
OneValue
()
{
return
One
;
}
static
TheType
Clamp
(
TheType
val
,
TheType
minVal
,
TheType
maxVal
)
{
return
TheType
(
NumericTraits
<
ValueType
>::
Clamp
(
val
.
real
(),
minVal
.
real
(),
maxVal
.
real
()),
NumericTraits
<
ValueType
>::
Clamp
(
val
.
imag
(),
minVal
.
imag
(),
maxVal
.
imag
()));
}
};
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment