//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      Resample/Sample/ReSample.h
//! @brief     Defines class ReSample.
//!
//! @homepage  http://www.bornagainproject.org
//! @license   GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
//  ************************************************************************************************

#ifdef SWIG
#error no need to expose this header to Swig
#endif // SWIG
#ifndef BORNAGAIN_RESAMPLE_SAMPLE_RESAMPLE_H
#define BORNAGAIN_RESAMPLE_SAMPLE_RESAMPLE_H

#include "Sample/Aggregate/Struct.h"
#include "Sample/Multilayer/Slice.h"
#include "Sample/Sample/Sample.h"
#include <heinz/Vectors3D.h>
#include <memory>
#include <vector>

class Fluxes;
class Layer;
class SimulationOptions;

//! Reprocessed sample model. Input to the reflectivity and scattering calculations.
//!
//! If the usage of average materials is requested, layers and particles are sliced into multiple
//! slices and the average material is calculated for each slice.

class ReSample : public Sample {
public:
    //! Factory method that wraps the private constructor.
    static ReSample processedSample(const Sample& sample, const SimulationOptions& options);

    ReSample(const ReSample&) = delete;
    ~ReSample();

    const std::vector<std::unique_ptr<const Slice>>& slices() const { return m_slices; }
    const std::vector<std::unique_ptr<const Struct>>& structs() const { return m_structs; }

    size_t numberOfSlices() const { return m_slices.size(); }
    const Slice& avgeSlice(size_t i) const;

    bool hasRoughness() const;

    Fluxes fluxesIn(const R3& k, bool polarized) const;
    Fluxes fluxesOut(const R3& k, bool polarized) const;

private:
    ReSample(std::vector<std::unique_ptr<const Struct>>&& structs,
             std::vector<std::unique_ptr<const Slice>>&& refined_slices);

    std::vector<std::unique_ptr<const Struct>> m_structs;
    std::vector<std::unique_ptr<const Slice>> m_slices;
};

#endif // BORNAGAIN_RESAMPLE_SAMPLE_RESAMPLE_H
