31#include "MediumBoundary.h"
33#define RZ_BEAM_MINIMUM_WAVELENGTH 1e-12
46 Real cumOptLength = 0;
50 bool intercepted =
false;
52 RZ::Real wavelength = RZ_WAVELENGTH;
59 class RayList :
public std::list<RZ::Ray, std::allocator<RZ::Ray>> { };
62 uint64_t intercepted = 0;
63 uint64_t vignetted = 0;
69 intercepted += existing.intercepted;
70 vignetted += existing.vignetted;
71 pruned += existing.pruned;
77 enum RayExtractionMask {
80 BeamIsSurfaceRelative = 4,
81 RayShouldBeSurfaceRelative = 8,
82 ExtractIntercepted = 16,
83 ExtractVignetted = 32,
85 ExtractAll = ExtractIntercepted | ExtractVignetted
90 uint64_t allocation = 0;
93 Real *origins =
nullptr;
94 Real *directions =
nullptr;
95 Real *destinations =
nullptr;
96 Complex *amplitude =
nullptr;
97 Real *lengths =
nullptr;
98 Real *cumOptLengths =
nullptr;
99 Real *normals =
nullptr;
100 Real *wavelengths =
nullptr;
101 Real *refNdx =
nullptr;
103 uint32_t *ids =
nullptr;
105 uint64_t *mask =
nullptr;
106 uint64_t *intMask =
nullptr;
107 uint64_t *prevMask =
nullptr;
108 uint64_t *chiefMask =
nullptr;
113 isChief(uint64_t index)
const
115 return (chiefMask[index >> 6] & (1ull << (index & 63))) >> (index & 63);
119 isIntercepted(uint64_t index)
const
121 return (intMask[index >> 6] & (1ull << (index & 63))) >> (index & 63);
125 hasRay(uint64_t index)
const
127 return (~mask[index >> 6] & (1ull << (index & 63))) >> (index & 63);
133 if (!isChief(c) && hasRay(c))
134 mask[c >> 6] |= 1ull << (c & 63);
140 size_t maskSize = ((count + 63) >> 6) << 3;
141 memset(mask, 0xff, maskSize);
147 size_t maskSize = ((count + 63) >> 6) << 3;
148 memset(intMask, 0, maskSize);
152 intercept(uint64_t c)
155 intMask[c >> 6] |= 1ull << (c & 63);
159 setChiefRay(uint64_t c)
164 chiefMask[c >> 6] |= 1ull << (c & 63);
169 unsetsetChiefRay(uint64_t c)
174 chiefMask[c >> 6] &= ~(1ull << (c & 63));
179 hadRay(uint64_t index)
const
181 return (~prevMask[index >> 6] & (1ull << (index & 63))) >> (index & 63);
184 #define SETMASK(field) \
185 field[word] = (field[word] & ~bit) | (existing->field[word] & bit)
187 copyRay(
const RayBeam *existing, uint64_t index)
189 uint64_t bit = 1ull << (index & 63);
190 uint64_t word = index >> 6;
192 memcpy(origins + 3 * index, existing->origins + 3 * index, 3 *
sizeof(Real));
193 memcpy(directions + 3 * index, existing->directions + 3 * index, 3 *
sizeof(Real));
194 memcpy(normals + 3 * index, existing->normals + 3 * index, 3 *
sizeof(Real));
195 memcpy(destinations + 3 * index, existing->destinations + 3 * index, 3 *
sizeof(Real));
197 amplitude[index] = existing->amplitude[index];
198 lengths[index] = existing->lengths[index];
199 cumOptLengths[index] = existing->lengths[index];
200 refNdx[index] = existing->refNdx[index];
201 wavelengths[index] = existing->wavelengths[index];
202 ids[index] = existing->ids[index];
211 virtual void allocate(uint64_t);
212 virtual void deallocate();
214 template <
class T>
void extractRays(
220 template <
class T>
static void extractRays(
230 void updateOrigins();
246 void fromSurfaceRelative();
254 RayBeam(uint64_t,
bool mediumBoundaries =
false);
267 assert(start <= end);
268 assert(end <= beam->count);
269 assert(start < beam->count);
Definition: ReferenceFrame.h:59
Definition: OpticalElement.h:33
Definition: RayBeam.h:261