//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      Sample/Particle/Particle.h
//! @brief     Defines class Particle.
//!
//! @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)
//
//  ************************************************************************************************

#ifndef BORNAGAIN_SAMPLE_PARTICLE_PARTICLE_H
#define BORNAGAIN_SAMPLE_PARTICLE_PARTICLE_H

#include "Sample/Particle/IParticle.h"

class Formfactor;
class Material;

//! A particle with a form factor and refractive index.

class Particle : public IParticle {
public:
    Particle(const Material& material, const Formfactor& formfactor);
    ~Particle() override;

#ifndef SWIG
    Particle* clone() const override;
    void validate() const override;

    double volumeToAdmix() const override;
    void setVolumeToAdmix(double volume);
    std::unique_ptr<const Material> materialToAdmix() const override;

    const Material* material() const { return m_material.get(); }
    void setMaterial(const Material& material);

    const Formfactor* pFormfactor() const { return m_formfactor.get(); }
    void setFormfactor(const Formfactor* ff); // takes ownership

    void setAmbientMaterial(const Material& material);
    const Material* ambientMaterial() const { return m_ambient_material.get(); }

    double bottomZ() const override;
    double topZ() const override;
    double radius() const override;
    double radialExtension() const override;
    bool containsSoftParticle() const override;

    complex_t theFF(const WavevectorInfo& wavevectors) const override;
    SpinMatrix thePolFF(const WavevectorInfo& wavevectors) const override;

    ScatteringMoments scatteringMoments(const DiffuseElement& ele) const override;
    PolScatteringMoments polScatteringMoments(const DiffuseElement& ele) const override;
    ChannelMoments channelMoments(const DwbaChannels& channels) const override;
    PolChannelMoments polChannelMoments(const PolDwbaChannels& channels) const override;

private:
    std::unique_ptr<const Material> m_material;
    std::unique_ptr<const Formfactor> m_formfactor;
    std::unique_ptr<Material> m_ambient_material;
    std::optional<double> m_admix_volume;
#endif // SWIG
};

#endif // BORNAGAIN_SAMPLE_PARTICLE_PARTICLE_H
