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

no unique_ptr for read-only ptr

parent 0abb716f
No related branches found
No related tags found
1 merge request!1748new dir rawEx/offspec; uniform directory name MiniExamples; minor cleanup
......@@ -21,7 +21,7 @@
using std::numbers::pi;
DiffuseElement::DiffuseElement(double wavelength, double alpha_i, double phi_i,
std::unique_ptr<const IPixel> pixel, const SpinMatrix& polarizer,
const IPixel* const pixel, const SpinMatrix& polarizer,
const SpinMatrix& analyzer, bool isSpecular_,
const Fluxes* const fluxes_in, const Fluxes* const fluxes_out)
: IElement({polarizer, analyzer})
......@@ -30,7 +30,7 @@ DiffuseElement::DiffuseElement(double wavelength, double alpha_i, double phi_i,
, m_phi_i(phi_i)
, m_k_i(vecOfLambdaAlphaPhi(m_wavelength, -m_alpha_i, -m_phi_i))
, m_mean_kf(pixel->getK(0.5, 0.5, m_wavelength))
, m_pixel(std::move(pixel))
, m_pixel(pixel)
, m_is_specular(isSpecular_)
, m_fluxes_in(fluxes_in)
, m_fluxes_out(fluxes_out)
......@@ -57,12 +57,11 @@ const IFlux* DiffuseElement::fluxOut(size_t i_layer) const
DiffuseElement DiffuseElement::pointElement(double x, double y) const
{
return {
m_wavelength, m_alpha_i,
m_phi_i, std::unique_ptr<IPixel>(m_pixel->createZeroSizePixel(x, y)), // TODO simplify
polarizer(), analyzer(),
m_is_specular, m_fluxes_in,
m_fluxes_out};
return {m_wavelength, m_alpha_i,
m_phi_i, m_pixel->createZeroSizePixel(x, y), // TODO simplify
polarizer(), analyzer(),
m_is_specular, m_fluxes_in,
m_fluxes_out};
}
R3 DiffuseElement::getKi() const
......
......@@ -32,10 +32,9 @@ class WavevectorInfo;
class DiffuseElement : public IElement {
public:
DiffuseElement(double wavelength, double alpha_i, double phi_i,
std::unique_ptr<const IPixel> pixel, const SpinMatrix& polarizer,
const SpinMatrix& analyzer, bool isSpecular_, const Fluxes* fluxes_in = nullptr,
const Fluxes* fluxes_out = nullptr);
DiffuseElement(double wavelength, double alpha_i, double phi_i, const IPixel* const pixel,
const SpinMatrix& polarizer, const SpinMatrix& analyzer, bool isSpecular_,
const Fluxes* fluxes_in = nullptr, const Fluxes* fluxes_out = nullptr);
DiffuseElement(const DiffuseElement&) = delete;
DiffuseElement(DiffuseElement&&) noexcept = default;
~DiffuseElement();
......@@ -72,7 +71,7 @@ private:
const double m_phi_i; //!< incident angle in xy plane
const R3 m_k_i; //!< cached value of k_i
const R3 m_mean_kf; //!< cached value of mean_kf
std::unique_ptr<const IPixel> m_pixel;
const IPixel* m_pixel;
const bool m_is_specular;
const Fluxes* m_fluxes_in;
const Fluxes* m_fluxes_out;
......
......@@ -92,8 +92,7 @@ void OffspecSimulation::runComputation(const ReSample& re_sample, size_t i, doub
const double phi = 0;
const bool isSpecular = k == m_detector->indexOfSpecular(alpha, phi);
DiffuseElement ele(m_scan->wavelength(), alpha, phi,
std::unique_ptr<IPixel>(m_pixels[k]->clone()), m_scan->polarizerMatrix(),
DiffuseElement ele(m_scan->wavelength(), alpha, phi, m_pixels[k], m_scan->polarizerMatrix(),
m_scan->analyzerMatrix(), isSpecular);
double intensity = Compute::scattered_and_reflected(re_sample, options(), ele);
......
......@@ -86,9 +86,8 @@ void ScatteringSimulation::runComputation(const ReSample& re_sample, size_t i, d
const bool isSpecular = m_active_indices[i] == m_detector->indexOfSpecular(beam());
DiffuseElement ele(beam().wavelength(), beam().alpha_i(), beam().phi_i(),
std::unique_ptr<IPixel>(m_pixels[i]->clone()), beam().polMatrix(),
m_detector->analyzer().matrix(), isSpecular);
DiffuseElement ele(beam().wavelength(), beam().alpha_i(), beam().phi_i(), m_pixels[i],
beam().polMatrix(), m_detector->analyzer().matrix(), isSpecular);
double intensity = Compute::scattered_and_reflected(re_sample, options(), ele);
......
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