23#include <WorldFrame.h>
24#include <ReferenceFrame.h>
27#include <OpticalElement.h>
28#include <Elements/Detector.h>
30#include <SkySampler.h>
34#define _STRINGIFY(x) #x
35#define STRINGIFY(x) _STRINGIFY(x)
37#define RZ_DEFAULT_CCD_RESOLUTION 1024
38#define RZ_DEFAULT_CCD_WIDTH 5e-2
39#define RZ_WAVELENGTH 555e-9
43 class GenericCompositeModel;
61 class ExpressionEvaluator;
67 std::string expression;
68 ExpressionEvaluator *evaluator =
nullptr;
69 std::list<std::string> change_list;
110 BeamReference reference = SkyRelative;
111 BeamShape shape = Circular;
112 bool converging =
true;
122 Real wavelength = 535e-9;
123 unsigned int numRays = 1000;
125 Vec3 direction = -Vec3::eZ();
126 Vec3 offset = Vec3::zero();
128 bool vignetting =
true;
131 SkyObjectShape objectShape = PointLike;
132 Real angularDiameter = M_PI / 6;
133 std::string objectPath;
139 setFNum(Real fNum, FNumReference adjust = BeamDiameter)
141 if (adjust == BeamDiameter)
142 diameter = length / fNum;
144 length = diameter * fNum;
156 setObjectFNum(Real fNum)
158 fNum = std::fabs(fNum);
160 if (std::isinf(fNum)) {
161 objectShape = PointLike;
163 objectShape = CircleLike;
164 angularDiameter = 2 * std::atan(0.5 / fNum);
171 focusZ = -std::numeric_limits<Real>::infinity();
175 setElementRelative(
const Element *element)
177 reference = ElementRelative;
178 this->element = element;
184 reference = PlaneRelative;
189 setObjectShape(std::string
const &shape)
191 if (shape ==
"point")
192 this->objectShape = PointLike;
193 else if (shape ==
"circular")
194 this->objectShape = CircleLike;
195 else if (shape ==
"extended")
196 this->objectShape = Extended;
198 std::runtime_error(
"Unrecognized angular shape `" + shape +
"'");
205 std::list<ReferenceFrame *> m_frames;
206 std::map<std::string, ReferenceFrame *> m_nameToFrame;
208 std::list<Element *> m_elements;
209 std::map<std::string, Element *> m_nameToElement;
210 std::map<std::string, OpticalElement *> m_nameToOpticalElement;
212 std::list<OpticalPath> m_paths;
213 std::map<std::string, OpticalPath *> m_nameToPath;
214 std::map<std::string, Detector *> m_nameToDetector;
223 bool registerElement(
Element *);
231 std::string genElementName(std::string
const &type);
232 std::string genReferenceFrameName(std::string
const &type);
234 bool registerDetectorAlias(std::string
const &name,
Detector *);
261 std::string
const &existing,
262 std::string
const &port,
263 std::string
const &type,
264 std::string
const &name =
"")
266 std::string rwName = name;
267 Element *element = lookupElementOrEx(existing);
270 if (rwName.size() == 0)
271 rwName = genElementName(type);
273 if (lookupElement(rwName) !=
nullptr)
276 return static_cast<T *
>(
277 autoRegisterElement(element->plug<T>(port, type, rwName)));
283 std::string
const &existingFrame,
284 std::string
const &type,
285 std::string
const &name =
"")
287 std::string rwName = name;
292 auto factory = sing->lookupElementFactory(type);
294 if (factory ==
nullptr)
295 throw std::runtime_error(
"Element class `" + type +
"` does not exist");
298 if (rwName.size() == 0)
299 rwName = genElementName(type);
301 if (lookupElement(rwName) !=
nullptr)
304 return static_cast<T *
>(
305 autoRegisterElement(factory->make(rwName, frame)));
320 bool addOpticalPath(std::string
const &, std::list<std::string>
const &);
322 std::string
const &name,
324 unsigned int cols = RZ_DEFAULT_CCD_RESOLUTION,
325 unsigned int rows = RZ_DEFAULT_CCD_RESOLUTION,
326 Real width = RZ_DEFAULT_CCD_WIDTH,
327 Real height = RZ_DEFAULT_CCD_WIDTH);
330 std::string
const &name,
331 std::string
const &parentFrame,
332 unsigned int cols = RZ_DEFAULT_CCD_RESOLUTION,
333 unsigned int rows = RZ_DEFAULT_CCD_RESOLUTION,
334 Real width = RZ_DEFAULT_CCD_WIDTH,
335 Real height = RZ_DEFAULT_CCD_WIDTH);
338 std::list<std::string> frames()
const;
339 std::list<std::string> elements()
const;
340 std::list<std::string> opticalElements()
const;
341 std::list<std::string> detectors()
const;
342 std::list<std::string> opticalPaths()
const;
343 std::list<std::string> elementHierarchy(std::string
const &pfx =
"")
const;
344 std::list<std::string> opticalElementHierarchy(std::string
const &pfx =
"")
const;
345 void boundingBox(
Vec3 &,
Vec3 &)
const;
348 std::list<Element *>
const &elementList()
const;
349 std::list<Element *> allElements()
const;
350 std::list<OpticalElement *> allOpticalElements()
const;
354 Element *resolveElement(std::string
const &)
const;
355 Element *lookupElement(std::string
const &)
const;
358 Detector *lookupDetector(std::string
const &)
const;
359 const OpticalPath *lookupOpticalPath(std::string
const & =
"")
const;
362 ReferenceFrame *lookupReferenceFrameOrEx(std::string
const &)
const;
363 Element *lookupElementOrEx(std::string
const &)
const;
364 OpticalElement *lookupOpticalElementOrEx(std::string
const &)
const;
365 Detector *lookupDetectorOrEx(std::string
const &)
const;
366 const OpticalPath *lookupOpticalPathOrEx(std::string
const & =
"")
const;
370 std::string
const &path,
371 std::list<RZ::Ray>
const &rays,
372 bool updateBeamElement =
false,
375 const struct timeval *startTime =
nullptr,
376 bool clearIntermediate =
true);
378 bool traceDiffraction(
379 std::string
const &path,
380 std::list<RZ::Ray>
const &rays,
383 const struct timeval *startTime =
nullptr);
386 std::list<RZ::Ray>
const &rays,
387 bool updateBeamElement =
false,
390 const struct timeval *startTime =
nullptr);
392 bool traceNonSequential(
393 std::list<RZ::Ray>
const &rays,
394 bool updateBeamElement =
false,
397 const struct timeval *startTime =
nullptr,
398 bool clearIntermediate =
true,
399 uint32_t maxProps = 3000);
401 struct timeval lastTracerTick() const;
405 std::string
const &detector,
406 std::string
const &file);
408 static void addSkyBeam(
409 std::list<Ray> &dest,
410 unsigned int number = 1000,
418 static void addElementRelativeBeam(
419 std::list<Ray> &dest,
421 unsigned int number = 1000,
431 static void addElementRelativeFocusBeam(
432 std::list<Ray> &dest,
434 unsigned int number = 1000,
437 Real refAperture = 200e-3,
446 static void addFocalPlaneFocusedBeam(
447 std::list<Ray> &dest,
449 unsigned int number = 1000,
460 static void addBeam(std::list<Ray> &dest,
BeamProperties const &);
465#ifndef RZ_NO_HELPER_MACROS
466# define plugElement(parent, type) plug<type>(parent, STRINGIFY(type))
467# define plugElementName(parent, type, name) plug<type>(parent, STRINGIFY(type), name)
Definition: Detector.h:116
Definition: Element.h:173
Definition: OMModel.h:204
Definition: OpticalElement.h:87
Definition: RayBeamElement.h:67
Definition: RayBeamElement.h:30
Definition: RayTracingEngine.h:38
Definition: ReferenceFrame.h:59
Definition: Simulation.h:50
Definition: Singleton.h:34
Definition: OMModel.h:108
Definition: OpticalElement.h:54