Skip to content
Snippets Groups Projects
Commit 839fec7c authored by Van Herck, Walter's avatar Van Herck, Walter
Browse files

Remove translating Transform3D back and forth in FormFactorDecoratorRotation::clone()

parent db42d8f0
No related branches found
No related tags found
No related merge requests found
...@@ -27,12 +27,9 @@ FormFactorDecoratorRotation::FormFactorDecoratorRotation( ...@@ -27,12 +27,9 @@ FormFactorDecoratorRotation::FormFactorDecoratorRotation(
m_transform = rotation.getTransform3D(); m_transform = rotation.getTransform3D();
} }
// TODO: can we avoid the conversion from IRotation to Transform3D and back?
FormFactorDecoratorRotation* FormFactorDecoratorRotation::clone() const FormFactorDecoratorRotation* FormFactorDecoratorRotation::clone() const
{ {
std::unique_ptr<IRotation> P_rotation(IRotation::createRotation(m_transform)); return new FormFactorDecoratorRotation(*mp_form_factor, m_transform);
return new FormFactorDecoratorRotation(*mp_form_factor, *P_rotation);
} }
complex_t FormFactorDecoratorRotation::evaluate(const WavevectorInfo& wavevectors) const complex_t FormFactorDecoratorRotation::evaluate(const WavevectorInfo& wavevectors) const
...@@ -47,6 +44,14 @@ Eigen::Matrix2cd FormFactorDecoratorRotation::evaluatePol(const WavevectorInfo & ...@@ -47,6 +44,14 @@ Eigen::Matrix2cd FormFactorDecoratorRotation::evaluatePol(const WavevectorInfo &
return mp_form_factor->evaluatePol(rotated_wavevectors); return mp_form_factor->evaluatePol(rotated_wavevectors);
} }
FormFactorDecoratorRotation::FormFactorDecoratorRotation(const IFormFactor &form_factor,
const Transform3D &transform)
: IFormFactorDecorator(form_factor)
{
setName(BornAgain::FormFactorDecoratorRotationType);
m_transform = transform;
}
WavevectorInfo FormFactorDecoratorRotation::rotate_wavevectors( WavevectorInfo FormFactorDecoratorRotation::rotate_wavevectors(
const WavevectorInfo& wavevectors) const const WavevectorInfo& wavevectors) const
{ {
......
...@@ -40,6 +40,8 @@ public: ...@@ -40,6 +40,8 @@ public:
private: private:
Transform3D m_transform; Transform3D m_transform;
//! Private constructor for cloning.
FormFactorDecoratorRotation(const IFormFactor &form_factor, const Transform3D &transform);
WavevectorInfo rotate_wavevectors(const WavevectorInfo& wavevectors) const; WavevectorInfo rotate_wavevectors(const WavevectorInfo& wavevectors) const;
}; };
......
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