//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      Sample/Aggregate/ICrystal2D.h
//! @brief     Defines and implements the interface class ICrystal2D.
//!
//! @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_AGGREGATE_ICRYSTAL2D_H
#define BORNAGAIN_SAMPLE_AGGREGATE_ICRYSTAL2D_H

#include "Sample/Aggregate/Ordered2D.h"

class Lattice2D;

//! Abstract base for infinite and finite 2D lattice structures.
class ICrystal2D : public virtual Ordered2D {
protected:
    ICrystal2D(const IParticle& particle, const Lattice2D& lattice);

public:
    ~ICrystal2D() override;

    void setIntegrationOverXi(bool integrate_xi);

    std::string className() const override { return "ICrystal2D"; }

#ifndef SWIG
    bool integrationOverXi() const { return m_integrate_xi; }

    const Lattice2D& lattice() const;

    //! Returns the particle density associated with this 2d lattice
    double areaNumberDensity() const override;

private:
    virtual double interferenceForXi(double xi, double qx, double qy) const = 0;

protected:
    double iff_without_dw(const R3& q) const override;
    void instructCrystalClone(ICrystal2D* dest) const;

    bool m_integrate_xi; //!< Integrate over the orientation xi
    std::unique_ptr<Lattice2D> m_lattice;

#endif // SWIG
};


#endif // BORNAGAIN_SAMPLE_AGGREGATE_ICRYSTAL2D_H
