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
65377e43
Commit
65377e43
authored
8 years ago
by
Van Herck, Walter
Browse files
Options
Downloads
Patches
Plain Diff
Remove code duplication
parent
587b6784
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Core/Particle/SlicedFormFactorList.cpp
+4
-1
4 additions, 1 deletion
Core/Particle/SlicedFormFactorList.cpp
Core/Scattering/IFormFactor.cpp
+3
-5
3 additions, 5 deletions
Core/Scattering/IFormFactor.cpp
with
7 additions
and
6 deletions
Core/Particle/SlicedFormFactorList.cpp
+
4
−
1
View file @
65377e43
...
@@ -32,11 +32,14 @@ void SlicedFormFactorList::addParticle(IParticle& particle,
...
@@ -32,11 +32,14 @@ void SlicedFormFactorList::addParticle(IParticle& particle,
const
MultiLayer
&
multilayer
,
size_t
ref_layer_index
)
const
MultiLayer
&
multilayer
,
size_t
ref_layer_index
)
{
{
auto
layer_indices
=
LayerIndicesLimits
(
particle
,
multilayer
,
ref_layer_index
);
auto
layer_indices
=
LayerIndicesLimits
(
particle
,
multilayer
,
ref_layer_index
);
bool
single_layer
=
(
layer_indices
.
first
==
layer_indices
.
second
);
for
(
size_t
i
=
layer_indices
.
first
;
i
<
layer_indices
.
second
+
1
;
++
i
)
for
(
size_t
i
=
layer_indices
.
first
;
i
<
layer_indices
.
second
+
1
;
++
i
)
{
{
kvector_t
translation
(
0.0
,
0.0
,
-
ZDifference
(
multilayer
,
i
,
ref_layer_index
));
kvector_t
translation
(
0.0
,
0.0
,
-
ZDifference
(
multilayer
,
i
,
ref_layer_index
));
particle
.
applyTranslation
(
translation
);
particle
.
applyTranslation
(
translation
);
ZLimits
limits
=
LayerZLimits
(
multilayer
,
i
);
// if particle is contained in this layer, set limits to infinite:
ZLimits
limits
=
single_layer
?
ZLimits
()
:
LayerZLimits
(
multilayer
,
i
);
m_ff_list
.
emplace_back
(
std
::
unique_ptr
<
IFormFactor
>
(
m_ff_list
.
emplace_back
(
std
::
unique_ptr
<
IFormFactor
>
(
particle
.
createSlicedFormFactor
(
limits
)),
i
);
particle
.
createSlicedFormFactor
(
limits
)),
i
);
ref_layer_index
=
i
;
// particle now has coordinates relative to layer i
ref_layer_index
=
i
;
// particle now has coordinates relative to layer i
...
...
This diff is collapsed.
Click to expand it.
Core/Scattering/IFormFactor.cpp
+
3
−
5
View file @
65377e43
...
@@ -63,17 +63,15 @@ bool ShapeIsContainedInLimits(const IFormFactor& formfactor, ZLimits limits,
...
@@ -63,17 +63,15 @@ bool ShapeIsContainedInLimits(const IFormFactor& formfactor, ZLimits limits,
{
{
double
zbottom
=
formfactor
.
bottomZ
(
rot
)
+
translation
.
z
();
double
zbottom
=
formfactor
.
bottomZ
(
rot
)
+
translation
.
z
();
double
ztop
=
formfactor
.
topZ
(
rot
)
+
translation
.
z
();
double
ztop
=
formfactor
.
topZ
(
rot
)
+
translation
.
z
();
double
eps
=
(
ztop
-
zbottom
)
*
1e-6
;
// allow for relatively small crossing due to numerical
// approximations (like rotation over 180 degrees)
switch
(
limits
.
type
())
{
switch
(
limits
.
type
())
{
case
ZLimits
::
FINITE
:
case
ZLimits
::
FINITE
:
return
zbottom
>=
limits
.
zmin
()
-
eps
&&
ztop
<=
limits
.
zmax
()
+
eps
;
return
zbottom
>=
limits
.
zmin
()
&&
ztop
<=
limits
.
zmax
();
case
ZLimits
::
INFINITE
:
case
ZLimits
::
INFINITE
:
return
true
;
return
true
;
case
ZLimits
::
NEG_INFINITE
:
case
ZLimits
::
NEG_INFINITE
:
return
ztop
<=
limits
.
zmax
()
+
eps
;
return
ztop
<=
limits
.
zmax
();
case
ZLimits
::
POS_INFINITE
:
case
ZLimits
::
POS_INFINITE
:
return
zbottom
>=
limits
.
zmin
()
-
eps
;
return
zbottom
>=
limits
.
zmin
();
}
}
return
false
;
return
false
;
}
}
...
...
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