Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review 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
mantidproject
mantid
Commits
72504494
Commit
72504494
authored
9 years ago
by
Martyn Gigg
Browse files
Options
Downloads
Patches
Plain Diff
Refactor reinterpret_cast lines & remove cppcast suppressions
They pointed to real problem before but no longer. Refs #14106
parent
894c5d26
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Framework/DataHandling/src/LoadFITS.cpp
+23
-19
23 additions, 19 deletions
Framework/DataHandling/src/LoadFITS.cpp
with
23 additions
and
19 deletions
Framework/DataHandling/src/LoadFITS.cpp
+
23
−
19
View file @
72504494
...
@@ -19,17 +19,28 @@ using namespace Mantid::DataObjects;
...
@@ -19,17 +19,28 @@ using namespace Mantid::DataObjects;
using
namespace
Mantid
::
API
;
using
namespace
Mantid
::
API
;
using
namespace
Mantid
::
Kernel
;
using
namespace
Mantid
::
Kernel
;
namespace
{
/**
* Reinterpret a byte sequence as InterpretType and cast to double
* @param Pointer to byte src
*/
template
<
typename
InterpretType
>
double
toDouble
(
uint8_t
*
src
)
{
return
static_cast
<
double
>
(
*
reinterpret_cast
<
InterpretType
*>
(
src
));
}
}
namespace
Mantid
{
namespace
Mantid
{
namespace
DataHandling
{
namespace
DataHandling
{
// Register the algorithm into the AlgorithmFactory
// Register the algorithm into the AlgorithmFactory
DECLARE_FILELOADER_ALGORITHM
(
LoadFITS
)
DECLARE_FILELOADER_ALGORITHM
(
LoadFITS
)
// Static class constants
const
std
::
string
LoadFITS
::
g_BIT_DEPTH_NAME
=
"BitDepthName"
;
const
std
::
string
LoadFITS
::
g_BIT_DEPTH_NAME
=
"BitDepthName"
;
const
std
::
string
LoadFITS
::
g_ROTATION_NAME
=
"RotationName"
;
const
std
::
string
LoadFITS
::
g_ROTATION_NAME
=
"RotationName"
;
const
std
::
string
LoadFITS
::
g_AXIS_NAMES_NAME
=
"AxisNames"
;
const
std
::
string
LoadFITS
::
g_AXIS_NAMES_NAME
=
"AxisNames"
;
const
std
::
string
LoadFITS
::
g_IMAGE_KEY_NAME
=
"ImageKeyName"
;
const
std
::
string
LoadFITS
::
g_IMAGE_KEY_NAME
=
"ImageKeyName"
;
const
std
::
string
LoadFITS
::
g_HEADER_MAP_NAME
=
"HeaderMapFile"
;
const
std
::
string
LoadFITS
::
g_HEADER_MAP_NAME
=
"HeaderMapFile"
;
const
std
::
string
LoadFITS
::
g_defaultImgType
=
"SAMPLE"
;
const
std
::
string
LoadFITS
::
g_defaultImgType
=
"SAMPLE"
;
/**
/**
...
@@ -809,25 +820,18 @@ void LoadFITS::readDataToWorkspace(const FITSInfo &fileInfo, double cmpp,
...
@@ -809,25 +820,18 @@ void LoadFITS::readDataToWorkspace(const FITSInfo &fileInfo, double cmpp,
std
::
reverse_copy
(
buffer8Start
,
buffer8Start
+
bytespp
,
byteValue
.
get
());
std
::
reverse_copy
(
buffer8Start
,
buffer8Start
+
bytespp
,
byteValue
.
get
());
double
val
=
0
;
double
val
=
0
;
if
(
fileInfo
.
bitsPerPixel
==
8
)
if
(
fileInfo
.
bitsPerPixel
==
8
)
{
val
=
static_cast
<
double
>
(
*
byteValue
);
val
=
toDouble
<
uint8_t
>
(
byteValue
.
get
());
else
if
(
fileInfo
.
bitsPerPixel
==
16
)
}
else
if
(
fileInfo
.
bitsPerPixel
==
16
)
{
val
=
val
=
toDouble
<
uint16_t
>
(
byteValue
.
get
());
static_cast
<
double
>
(
*
reinterpret_cast
<
uint16_t
*>
(
byteValue
.
get
()));
}
else
if
(
fileInfo
.
bitsPerPixel
==
32
&&
!
fileInfo
.
isFloat
)
{
else
if
(
fileInfo
.
bitsPerPixel
==
32
&&
!
fileInfo
.
isFloat
)
val
=
toDouble
<
uint32_t
>
(
byteValue
.
get
());
val
=
}
else
if
(
fileInfo
.
bitsPerPixel
==
64
&&
!
fileInfo
.
isFloat
)
{
static_cast
<
double
>
(
*
reinterpret_cast
<
uint32_t
*>
(
byteValue
.
get
()));
val
=
toDouble
<
uint32_t
>
(
byteValue
.
get
());
else
if
(
fileInfo
.
bitsPerPixel
==
64
&&
!
fileInfo
.
isFloat
)
}
else
if
(
fileInfo
.
bitsPerPixel
==
32
&&
fileInfo
.
isFloat
)
{
val
=
val
=
toDouble
<
float
>
(
byteValue
.
get
());
static_cast
<
double
>
(
*
reinterpret_cast
<
uint64_t
*>
(
byteValue
.
get
()));
// cppcheck doesn't realise that these are safe casts
else
if
(
fileInfo
.
bitsPerPixel
==
32
&&
fileInfo
.
isFloat
)
{
// cppcheck-suppress invalidPointerCast
val
=
static_cast
<
double
>
(
*
reinterpret_cast
<
float
*>
(
byteValue
.
get
()));
}
else
if
(
fileInfo
.
bitsPerPixel
==
64
&&
fileInfo
.
isFloat
)
{
}
else
if
(
fileInfo
.
bitsPerPixel
==
64
&&
fileInfo
.
isFloat
)
{
// cppcheck-suppress invalidPointerCast
val
=
toDouble
<
double
>
(
byteValue
.
get
());
val
=
*
reinterpret_cast
<
double
*>
(
byteValue
.
get
());
}
}
val
=
fileInfo
.
scale
*
val
-
fileInfo
.
offset
;
val
=
fileInfo
.
scale
*
val
-
fileInfo
.
offset
;
...
...
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