using LensSimulatorCore.Shapes; namespace LensSimulatorCore.Optical; /// /// An Element contains two surfaces and material coefficients. /// public class Element { //This section is for display and rendering public List Polygon { get; set; } //This section is for calculation private Material _material; private readonly Surface[] _surfaces = new Surface[2]; public Surface[] Surfaces => _surfaces; public Point Position { get; set; } public bool IsValid => !(Polygon[(Polygon.Count / 2) - 1].X > Polygon[(Polygon.Count / 2)].X); public double Depth { get; } public double Diameter { get; } public Element(Material material) { } /// /// /// /// Element Position /// Total Element depth at the centre. /// Diameter of the lens /// /// /// public Element(Point position, double depth, double diameter, Surface frontSurface, Surface rearSurface, Material material) { Polygon = new List(); Surfaces[0] = frontSurface; Surfaces[0].Parent = this; Surfaces[0].IsFront = true; Surfaces[1] = rearSurface; Surfaces[1].Parent = this; Surfaces[1].IsFront = false; Depth = depth; Diameter = diameter; _material = material; Position = position; foreach (var surface in Surfaces) { surface.UpdateSurfacePositions(); surface.GeneratePolyLine(); Polygon.AddRange(surface.PolyLine); } } }