Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
545e6b9c
Commit
545e6b9c
authored
4 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
prefer dynamic_cast over dataType test
parent
75ea5bf5
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
Core/Simulation/SpecularSimulation.cpp
+7
-13
7 additions, 13 deletions
Core/Simulation/SpecularSimulation.cpp
with
7 additions
and
13 deletions
Core/Simulation/SpecularSimulation.cpp
+
7
−
13
View file @
545e6b9c
...
...
@@ -30,12 +30,8 @@ namespace
{
// TODO: remove when pointwise resolution is implemented
std
::
unique_ptr
<
AngularSpecScan
>
mangledScan
(
const
ISpecular
Scan
&
scan
_
,
const
Beam
&
beam
)
std
::
unique_ptr
<
AngularSpecScan
>
mangledScan
(
const
AngularSpec
Scan
&
scan
,
const
Beam
&
beam
)
{
if
(
scan_
.
dataType
()
!=
ISpecularScan
::
angle
)
throw
std
::
runtime_error
(
"Error in mangledScan: invalid usage"
);
const
auto
&
scan
=
static_cast
<
const
AngularSpecScan
&>
(
scan_
);
const
double
wl
=
beam
.
getWavelength
();
const
double
angle_shift
=
beam
.
getAlpha
();
std
::
vector
<
double
>
angles
=
scan
.
coordinateAxis
()
->
getBinCenters
();
...
...
@@ -54,8 +50,8 @@ std::vector<SpecularSimulationElement> generateSimulationElements(const Instrume
std
::
vector
<
SpecularSimulationElement
>
result
;
// TODO: remove if-else statement when pointwise resolution is implemented
if
(
scan
.
dataType
()
==
ISpecularScan
::
angle
)
result
=
mangledScan
(
s
can
,
instrument
.
getBeam
())
->
generateSimulationElements
();
if
(
const
auto
*
aScan
=
dynamic_cast
<
const
AngularSpecScan
*>
(
&
scan
)
)
result
=
mangledScan
(
*
aS
can
,
instrument
.
getBeam
())
->
generateSimulationElements
();
else
result
=
scan
.
generateSimulationElements
();
...
...
@@ -135,10 +131,8 @@ void SpecularSimulation::setScan(const ISpecularScan& scan)
instrument
().
setDetector
(
detector
);
// TODO: remove when pointwise resolution is implemented
if
(
scan
.
dataType
()
==
ISpecularScan
::
angle
)
{
const
auto
&
angular_scan
=
static_cast
<
const
AngularSpecScan
&>
(
scan
);
instrument
().
setBeamParameters
(
angular_scan
.
wavelength
(),
0.0
,
0.0
);
}
if
(
const
auto
*
aScan
=
dynamic_cast
<
const
AngularSpecScan
*>
(
&
scan
))
instrument
().
setBeamParameters
(
aScan
->
wavelength
(),
0.0
,
0.0
);
}
const
IAxis
*
SpecularSimulation
::
coordinateAxis
()
const
...
...
@@ -221,8 +215,8 @@ void SpecularSimulation::normalize(size_t start_ind, size_t n_elements)
std
::
vector
<
double
>
footprints
;
// TODO: use just m_scan when pointwise resolution is implemented
if
(
m_scan
->
dataType
()
==
ISpecularScan
::
angle
)
footprints
=
mangledScan
(
*
m_s
can
,
instrument
().
getBeam
())
->
footprint
(
start_ind
,
n_elements
);
if
(
const
auto
*
aScan
=
dynamic_cast
<
const
AngularSpecScan
*>
(
m_scan
.
get
())
)
footprints
=
mangledScan
(
*
aS
can
,
instrument
().
getBeam
())
->
footprint
(
start_ind
,
n_elements
);
else
footprints
=
m_scan
->
footprint
(
start_ind
,
n_elements
);
...
...
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