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
2c19f2b2
Commit
2c19f2b2
authored
11 years ago
by
Van Herck, Walter
Browse files
Options
Downloads
Patches
Plain Diff
Refactored ParticleDecoration and removed TODO
parent
adec994e
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/Samples/inc/ParticleDecoration.h
+8
-28
8 additions, 28 deletions
Core/Samples/inc/ParticleDecoration.h
Core/Samples/src/ParticleDecoration.cpp
+30
-15
30 additions, 15 deletions
Core/Samples/src/ParticleDecoration.cpp
with
38 additions
and
43 deletions
Core/Samples/inc/ParticleDecoration.h
+
8
−
28
View file @
2c19f2b2
...
...
@@ -26,33 +26,13 @@
class
BA_CORE_API_
ParticleDecoration
:
public
IDecoration
{
public:
ParticleDecoration
()
:
m_total_abundance
(
0.0
)
{
setName
(
"ParticleDecoration"
);
}
ParticleDecoration
();
ParticleDecoration
(
Particle
*
p_particle
,
double
depth
=
0.
,
double
abundance
=
1.
)
:
m_total_abundance
(
0.0
)
{
setName
(
"ParticleDecoration"
);
addParticle
(
p_particle
,
depth
,
abundance
);
}
Particle
*
p_particle
,
double
depth
=
0.
,
double
abundance
=
1.
);
ParticleDecoration
(
const
Particle
&
p_particle
,
double
depth
=
0.
,
double
abundance
=
1.
)
:
m_total_abundance
(
0.0
)
{
setName
(
"ParticleDecoration"
);
addParticle
(
p_particle
.
clone
(),
depth
,
abundance
);
}
~
ParticleDecoration
()
{
for
(
size_t
i
=
0
;
i
<
m_particles
.
size
();
++
i
)
delete
m_particles
[
i
];
}
const
Particle
&
p_particle
,
double
depth
=
0.
,
double
abundance
=
1.
);
virtual
~
ParticleDecoration
();
virtual
ParticleDecoration
*
clone
()
const
;
...
...
@@ -114,10 +94,10 @@ private:
void
print
(
std
::
ostream
&
ostr
)
const
;
//TODO: replace with SafePointerVector
std
::
vector
<
ParticleInfo
*>
m_particles
;
//! Vector of the types of particles
SafePointerVector
<
ParticleInfo
>
m_particles
;
//! Vector of interference functions
SafePointerVector
<
IInterferenceFunction
>
m_interference_functions
;
//! Currently only a scalar interference function (instead of matrix)
...
...
This diff is collapsed.
Click to expand it.
Core/Samples/src/ParticleDecoration.cpp
+
30
−
15
View file @
2c19f2b2
...
...
@@ -23,9 +23,34 @@
#include
<iomanip>
ParticleDecoration
::
ParticleDecoration
()
:
m_total_abundance
(
0.0
)
{
setName
(
"ParticleDecoration"
);
}
ParticleDecoration
::
ParticleDecoration
(
Particle
*
p_particle
,
double
depth
,
double
abundance
)
:
m_total_abundance
(
0.0
)
{
setName
(
"ParticleDecoration"
);
addParticle
(
p_particle
,
depth
,
abundance
);
}
ParticleDecoration
::
ParticleDecoration
(
const
Particle
&
p_particle
,
double
depth
,
double
abundance
)
:
m_total_abundance
(
0.0
)
{
setName
(
"ParticleDecoration"
);
addParticle
(
p_particle
.
clone
(),
depth
,
abundance
);
}
ParticleDecoration
::~
ParticleDecoration
()
{
}
ParticleDecoration
*
ParticleDecoration
::
clone
()
const
{
// msglog(MSG::DEBUG) << "ParticleDecoration::clone()";
ParticleDecoration
*
p_new
=
new
ParticleDecoration
();
p_new
->
setName
(
getName
());
...
...
@@ -44,7 +69,6 @@ ParticleDecoration* ParticleDecoration::clone() const
ParticleDecoration
*
ParticleDecoration
::
cloneInvertB
()
const
{
// msglog(MSG::DEBUG) << "ParticleDecoration::clone()";
ParticleDecoration
*
p_new
=
new
ParticleDecoration
();
p_new
->
setName
(
getName
()
+
"_inv"
);
...
...
@@ -62,13 +86,13 @@ ParticleDecoration* ParticleDecoration::cloneInvertB() const
}
//! Adds generic particle, *-version.
void
ParticleDecoration
::
addParticle
(
Particle
*
p_particle
,
const
Geometry
::
ITransform3D
&
transform
,
double
depth
,
double
abundance
)
{
if
(
!
abundance
)
{
throw
LogicErrorException
(
"ParticleDecoration::addParticle() -> Error! Abundance can't be equal to 0.0"
);
throw
LogicErrorException
(
"ParticleDecoration::addParticle() ->"
" Error! Abundance can't be equal to 0.0"
);
}
p_particle
->
setTransform
(
transform
);
addAndRegisterParticleInfo
(
...
...
@@ -76,13 +100,13 @@ void ParticleDecoration::addParticle(
}
//! Adds generic particle, &-version.
void
ParticleDecoration
::
addParticle
(
const
Particle
&
p_particle
,
const
Geometry
::
ITransform3D
&
transform
,
double
depth
,
double
abundance
)
{
if
(
!
abundance
)
{
throw
LogicErrorException
(
"ParticleDecoration::addParticle() -> Error! Abundance can't be equal to 0.0"
);
throw
LogicErrorException
(
"ParticleDecoration::addParticle() ->"
" Error! Abundance can't be equal to 0.0"
);
}
Particle
*
p_particle_clone
=
p_particle
.
clone
();
p_particle_clone
->
setTransform
(
transform
);
...
...
@@ -91,18 +115,15 @@ void ParticleDecoration::addParticle(
}
//! Adds particle without rotation, *-version.
void
ParticleDecoration
::
addParticle
(
Particle
*
p_particle
,
double
depth
,
double
abundance
)
{
addAndRegisterParticleInfo
(
new
ParticleInfo
(
p_particle
,
depth
,
abundance
));
// addParticle(p_particle, Geometry::ITransform3D(), depth, abundance);
}
//! Adds particle without rotation, &-version.
void
ParticleDecoration
::
addParticle
(
const
Particle
&
p_particle
,
double
depth
,
double
abundance
)
...
...
@@ -110,18 +131,15 @@ void ParticleDecoration::addParticle(
Particle
*
p_particle_clone
=
p_particle
.
clone
();
addAndRegisterParticleInfo
(
new
ParticleInfo
(
p_particle_clone
,
depth
,
abundance
));
// addParticle(p_particle.clone(), Geometry::PTransform3D(), depth, abundance);
}
//! Adds particle info.
void
ParticleDecoration
::
addParticleInfo
(
const
ParticleInfo
&
info
)
{
addAndRegisterParticleInfo
(
info
.
clone
()
);
}
//! Returns particle info
const
ParticleInfo
*
ParticleDecoration
::
getParticleInfo
(
size_t
index
)
const
{
if
(
index
<
m_particles
.
size
())
...
...
@@ -137,7 +155,6 @@ double ParticleDecoration::getAbundanceFractionOfParticle(size_t index) const
}
//! Adds interference functions
void
ParticleDecoration
::
addInterferenceFunction
(
IInterferenceFunction
*
p_interference_function
)
{
...
...
@@ -164,14 +181,12 @@ const IInterferenceFunction* ParticleDecoration::getInterferenceFunction(
void
ParticleDecoration
::
addAndRegisterParticleInfo
(
ParticleInfo
*
child
)
{
// msglog(MSG::DEBUG) << "ParticleDecoration::addAndRegisterParticleInfo {" << *child << "}";
m_total_abundance
+=
child
->
getAbundance
();
m_particles
.
push_back
(
child
);
registerChild
(
child
);
}
//! Adds interference function with simultaneous registration in parent class.
void
ParticleDecoration
::
addAndRegisterInterferenceFunction
(
IInterferenceFunction
*
child
)
{
...
...
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