Skip to content

File Element.h

File List > Element > Element.h

Go to the documentation of this file

#pragma once

#include <glm.hpp>
#include <map>
#include <optional>
#include <string>

#include "Behaviour.h"
#include "Coating.h"
#include "Core.h"
#include "Cutout.h"
#include "Rml/xml.h"
#include "Shader/SlopeError.h"
#include "Surface.h"

namespace rayx {

class DesignElement;

enum class ElementType {
    Undefined,
    ImagePlane,
    ConeMirror,
    Crystal,
    CylinderMirror,
    EllipsoidMirror,
    ExpertsMirror,
    Foil,
    ParaboloidMirror,
    PlaneGrating,
    PlaneMirror,
    ReflectionZoneplate,
    Slit,
    SphereGrating,
    Sphere,
    SphereMirror,
    ToroidMirror,
    ToroidGrating,
    PointSource,
    MatrixSource,
    DipoleSource,
    PixelSource,
    CircleSource,
    SimpleUndulatorSource,
    RayListSource,
};

struct OpticalElement {
    Behaviour m_behaviour;    
    Surface m_surface;        
    Cutout m_cutout;          
    Coating m_coating;        
    SlopeError m_slopeError;  
    double m_azimuthalAngle;  
    int m_material;           
};

// Ensure OpticalElement does not introduce cost on copy or default construction.
// static_assert(std::is_trivially_copyable_v<OpticalElement>);

struct ObjectTransform {
    glm::dmat4 m_inTrans;   
    glm::dmat4 m_outTrans;  
};

RAYX_API glm::dmat4 calcTransformationMatrices(glm::dvec4 position, glm::dmat4 orientation, bool calcInMatrix, DesignPlane plane);

struct OpticalElementAndTransform {
    OpticalElement element;
    ObjectTransform transform;
};

// constructs an OpticalElement given all of its components. Some information that is not explicitly given, will be parsed from the ` dele`.
OpticalElementAndTransform makeElement(const DesignElement& dele, Behaviour behaviour, Surface surface, DesignPlane plane = DesignPlane::XZ,
                                       std::optional<Cutout> cutout = {});

}  // namespace rayx