RayZaler 0.1
The free opto-mechanical simulation framework
Array.h
1//
2// Copyright (c) 2024 Gonzalo José Carracedo Carballal
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU Lesser General Public License as
6// published by the Free Software Foundation, either version 3 of the
7// License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU Lesser General Public License for more details.
13//
14// You should have received a copy of the GNU Lesser General Public
15// License along with this program. If not, see
16// <http://www.gnu.org/licenses/>
17//
18
19#ifndef _SURFACES_ARRAY_H
20#define _SURFACES_ARRAY_H
21
22#include <SurfaceShape.h>
23
24namespace RZ {
25 class SurfaceArray : public SurfaceShape {
26 SurfaceShape *m_subAperture = nullptr;
27 Real m_width = 100e-3;
28 Real m_height = 100e-3;
29 unsigned int m_rows = 10;
30 unsigned int m_cols = 10;
31 Real m_subApertureWidth = 10e-3;
32 Real m_subApertureHeight = 10e-3;
33 std::vector<std::vector<Real>> m_edges;
34
35 void recalculateDimensions();
36
37 public:
38 inline SurfaceShape *subAperture() const
39 {
40 return m_subAperture;
41 }
42
43 template <class T>
44 inline T *subAperture()
45 {
46 return static_cast<T *>(subAperture());
47 }
48
49 template <class T>
50 inline T const *subAperture() const
51 {
52 return static_cast<const T *>(subAperture());
53 }
54
55 inline Real
56 subApertureWidth() const
57 {
58 return m_subApertureWidth;
59 }
60
61 inline Real
62 subApertureHeight() const
63 {
64 return m_subApertureHeight;
65 }
66
67 inline Real
68 width() const
69 {
70 return m_width;
71 }
72
73 inline Real
74 height() const
75 {
76 return m_height;
77 }
78
79 virtual std::vector<std::vector<Real>> const &edges() const override;
80
82 virtual ~SurfaceArray();
83
84 void setWidth(Real);
85 void setHeight(Real);
86 void setCols(unsigned);
87 void setRows(unsigned);
88
89 virtual bool intercept(
90 Vec3 &coord,
91 Vec3 &n,
92 Real &tIgnore,
93 Vec3 const &origin,
94 Vec3 const &direction) const override;
95
96 virtual Real area() const override;
97 virtual std::string name() const override;
98
99 virtual void generatePoints(
100 const ReferenceFrame *,
101 Real *pointArr,
102 Real *normals,
103 unsigned int N) override;
104
105 virtual void renderOpenGL() override;
106 };
107}
108
109#endif // _SURFACES_ARRAY_H
Definition: ReferenceFrame.h:59
Definition: Array.h:25
Definition: SurfaceShape.h:31
Definition: Vector.h:66