Skip to content
Snippets Groups Projects
Commit e19ccfb3 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

rename rot -> rotation; simplify ParticleCoreShell::createSlicedParticle

parent 88782efd
No related branches found
No related tags found
1 merge request!527pointerize rotation
......@@ -60,13 +60,14 @@ complex_t FormFactorFullSphere::formfactor(C3 q) const
return ret;
}
IFormFactor* FormFactorFullSphere::sliceFormFactor(ZLimits limits, const IRotation* rot,
IFormFactor* FormFactorFullSphere::sliceFormFactor(ZLimits limits, const IRotation* rotation,
R3 translation) const
{
R3 center(0.0, 0.0, m_radius);
R3 rotation_offset =
m_position_at_center ? R3(0.0, 0.0, 0.0) : rot->transformed(center) - center;
R3 new_translation = translation + rotation_offset;
R3 new_translation = translation;
if (rotation) {
R3 center(0.0, 0.0, m_radius);
new_translation += rotation->transformed(center) - center;
}
double height = 2.0 * m_radius;
auto effects = computeSlicingEffects(limits, new_translation, height);
FormFactorTruncatedSphere slicedff(m_radius, height - effects.dz_bottom, effects.dz_top);
......
......@@ -46,7 +46,7 @@ public:
protected:
bool canSliceAnalytically(const IRotation*) const override { return true; }
IFormFactor* sliceFormFactor(ZLimits limits, const IRotation* rot,
IFormFactor* sliceFormFactor(ZLimits limits, const IRotation* rotation,
R3 translation) const override;
private:
......
......@@ -45,13 +45,10 @@ MesoCrystal* MesoCrystal::clone() const
SlicedParticle MesoCrystal::createSlicedParticle(const ZLimits& limits) const
{
ASSERT(m_particle_structure && m_meso_form_factor);
std::unique_ptr<IRotation> rotation(new IdentityRotation);
if (m_rotation)
rotation.reset(m_rotation->clone());
std::unique_ptr<IFormFactor> tem_ff(
m_meso_form_factor->createSlicedFormFactor(limits, rotation.get(), m_position));
m_meso_form_factor->createSlicedFormFactor(limits, m_rotation.get(), m_position));
std::unique_ptr<IFormFactor> total_ff(
m_particle_structure->createTotalFormFactor(*tem_ff, rotation.get(), m_position));
m_particle_structure->createTotalFormFactor(*tem_ff, m_rotation.get(), m_position));
double meso_volume = m_meso_form_factor->volume();
auto regions = m_particle_structure->admixtures();
for (auto& region : regions)
......
......@@ -49,17 +49,14 @@ Particle* Particle::clone() const
SlicedParticle Particle::createSlicedParticle(const ZLimits& limits) const
{
ASSERT(m_form_factor);
std::unique_ptr<IRotation> rotation(new IdentityRotation);
if (m_rotation)
rotation.reset(m_rotation->clone());
std::unique_ptr<IFormFactor> sliced_raw_ff(
m_form_factor->createSlicedFormFactor(limits, rotation.get(), m_position));
m_form_factor->createSlicedFormFactor(limits, m_rotation.get(), m_position));
if (!sliced_raw_ff)
return {};
auto sliced_ff = std::make_unique<FormFactorDecoratorMaterial>(*sliced_raw_ff);
double volume = sliced_raw_ff->volume();
Material transformed_material(
rotation ? m_material.rotatedMaterial(rotation->getTransform3D()) : m_material);
m_rotation ? m_material.rotatedMaterial(m_rotation->getTransform3D()) : m_material);
sliced_ff->setMaterial(transformed_material);
return {std::move(sliced_ff), {{{volume, transformed_material}}}};
}
......
......@@ -44,19 +44,18 @@ ParticleCoreShell* ParticleCoreShell::clone() const
SlicedParticle ParticleCoreShell::createSlicedParticle(const ZLimits& limits) const
{
ASSERT(m_core && m_shell);
std::unique_ptr<IRotation> rotation(new IdentityRotation);
if (m_rotation)
rotation.reset(m_rotation->clone());
// core
std::unique_ptr<Particle> P_core(m_core->clone());
P_core->rotate(*rotation);
if (m_rotation)
P_core->rotate(*m_rotation);
P_core->translate(m_position);
auto sliced_core = P_core->createSlicedParticle(limits);
// shell
std::unique_ptr<Particle> P_shell(m_shell->clone());
P_shell->rotate(*rotation);
if (m_rotation)
P_shell->rotate(*m_rotation);
P_shell->translate(m_position);
auto sliced_shell = P_shell->createSlicedParticle(limits);
if (!sliced_shell.sliced_ff)
......
......@@ -52,9 +52,9 @@ double IBornFF::topZ(const IRotation* rotation) const
return TopZ(m_shape3D->vertices(), rotation);
}
bool IBornFF::canSliceAnalytically(const IRotation* rot) const
bool IBornFF::canSliceAnalytically(const IRotation* rotation) const
{
return rot->zInvariant();
return !rotation || rotation->zInvariant();
}
Eigen::Matrix2cd IBornFF::formfactor_pol(C3 q) const
......
......@@ -59,7 +59,7 @@ public:
protected:
//! Default implementation only allows rotations along z-axis
bool canSliceAnalytically(const IRotation* rot) const override;
bool canSliceAnalytically(const IRotation* rotation) const override;
#ifndef SWIG
//! Returns scattering amplitude for complex scattering wavevector q=k_i-k_f in case
......
......@@ -24,20 +24,20 @@
namespace {
bool shapeIsContainedInLimits(const IFormFactor& formfactor, ZLimits limits, const IRotation* rot,
R3 translation)
bool shapeIsContainedInLimits(const IFormFactor& formfactor, ZLimits limits,
const IRotation* rotation, R3 translation)
{
double zbottom = formfactor.bottomZ(rot) + translation.z();
double ztop = formfactor.topZ(rot) + translation.z();
double zbottom = formfactor.bottomZ(rotation) + translation.z();
double ztop = formfactor.topZ(rotation) + translation.z();
return limits.zBottom() <= zbottom && ztop <= limits.zTop();
}
bool shapeOutsideLimits(const IFormFactor& formfactor, ZLimits limits, const IRotation* rot,
R3 translation)
bool shapeOutsideLimits(const IFormFactor& formfactor, ZLimits limits,
const IRotation* rotation, R3 translation)
{
double zbottom = formfactor.bottomZ(rot) + translation.z();
double ztop = formfactor.topZ(rot) + translation.z();
double zbottom = formfactor.bottomZ(rotation) + translation.z();
double ztop = formfactor.topZ(rotation) + translation.z();
return ztop <= limits.zBottom() || zbottom >= limits.zTop();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment