GOAT (Geometrical optics application tool) 0.1
Loading...
Searching...
No Matches
raytrace.h
Go to the documentation of this file.
1#pragma once
2#include "lightsrc_mc.h"
3#include "lightsrc.h"
4#include "objectshape.h"
5#include "vector.h"
6#include "detector.h"
7#include "raybase.h"
8#include "superarray.h"
9#include <vector>
10
11namespace GOAT
12{
13 namespace raytracing
14 {
15 #define RAYTRACER_TYPE_NONE 0
16 #define RAYTRACER_TYPE_PATH 1
17 #define RAYTRACER_TYPE_OT 2
18 #define RAYTRACER_TYPE_PURE 3
19
20 #define MAX_RECURSIONS 20
21 #define RAYTRACE_MAX_REFLEXIONS 2
27 class Scene
28 {
29 public:
31 Scene(const Scene& S);
34 void addObjectList(int nobj, std::vector<ObjectShape*> obj);
35 void removeObject(int index);
40 void removeLightSrc(int index);
42 void addLightSourceRRT(LightSrc* ls, maths::Vector<std::complex<double> >Pol1, maths::Vector<std::complex<double> >Pol2);
43 void addLightSourceList(int nls, std::vector<LightSrc*> ls);
45 void addDetectorList(int nDet, std::vector< Detector*> D);
47 void removeDetector(int index);
49 void setr0(double r0);
50 void setnS(std::complex<double> nS);
51 void setnSRRT(std::complex<double> nS);
52 void setRaytype(int raytype);
53 void resetLS();
54 int testLS();
55 std::vector<ObjectShape*> Obj;
56 std::vector<LightSrc*> LS;
58 std::vector< Detector*> Det;
59 int nObj = 0;
60 int nLS = 0;
61 int nDet = 0;
62 std::complex<double> nS;
63 std::complex<double> nSRRT;
64 double r0=1E+100;
66 bool suppress_phase_progress = false;
67 };
68
69
78 class Raytrace
79 {
80 public:
82 Raytrace(const Scene& S);
83 void setScene(const Scene& S);
85 void trace();
86 virtual void traceEnterObject() = 0;
87 virtual void traceLeaveObject() = 0;
88 virtual void traceStopObject() {};
89 void init();
90 int lost;
91 int currentObj;
92 int currentLS;
97
104
106 double PowRef;
107 double PowIn;
108 double PowTrans;
109 Scene S;
110 bool useRRTParms;
112
113
116 virtual void traceOneRay(RayBase* ray, int& Reflexions, int& recur);
117 virtual void reset();
118 void copyRay(RayBase*& dest, RayBase* src);
119 RayBase* ray;
120 RayBase* tray;
121 bool Abbruch;
123 };
124
128 class Raytrace_OT : public Raytrace
129 {
130 public:
133 void setScene(const Scene& S);
134 void trace();
141 };
142
143
150 class Raytrace_Path : public Raytrace
151 {
152 public:
155 void trace(std::string FName);
156 void trace();
157 void setShowOutgoingRays(bool show);
159
160 std::vector<maths::Vector<double>> P1;
161 std::vector<maths::Vector<double>> P2;
162
163 // maths::Vector<double>* P1; ///< Here, the starting points of each step are stored if no filename is given
164 // maths::Vector<double>* P2; ///< Here, the ending points of each step are stored if no filename is given
165 int numRays=0;
166 private:
169 void storeStep();
171 std::ofstream os;
172 bool showOutgoingRays = true;
173 bool storeInFile = false;
174
175 };
181 class Raytrace_pure : public Raytrace
182 {
183 public:
186 private:
189 };
190
191 }
192}
Template class for threedimensional vectors.
Definition vector.h:57
The abstract Detector class provides an interface to a detector to store the information about the el...
Definition detector.h:22
This abstract class is the basic class for all light sources used in this raytracing library....
Definition lightsrc.h:68
Abstract base class for all volume objects This abstract class provides a template for all volume obj...
Definition objectshape.h:60
Abstract base class for all rays used for the raytracing process. This abstract base class for all ra...
Definition raybase.h:16
This class provides functionality to calculate the forces for optical tweezers. It is derived by the ...
Definition raytrace.h:136
maths::Vector< double > ** f
list of the forces acting on the objects, separated for the different light sources
Definition raytrace.h:146
void traceEnterObject()
force calculation, when the ray enters an object
maths::Vector< double > * F
list of the forces acting on the objects
Definition raytrace.h:144
void setScene(const Scene &S)
void traceLeaveObject()
force calculation, when the ray leaves an object
maths::Vector< double > * L
angular momenta acting on the objects
Definition raytrace.h:145
maths::Vector< double > ** l
list of the angular momenta acting on the objects, separated for the different light sources
Definition raytrace.h:147
Class which stores the start and end points of each step into a file.
Definition raytrace.h:158
std::vector< maths::Vector< double > > P2
Here, the ending points of each step are stored if no filename is given.
Definition raytrace.h:167
bool getShowOutgoingRays()
Returns true, if Rays, which going out of an object without hidding a second one will be stored.
void setShowOutgoingRays(bool show)
if true, Rays, which going out of an object without hidding a second one will be stored
Raytrace_Path(Scene)
Constructor with Scene Object.
void traceEnterObject()
this function is called when the ray enters an object
int numRays
Number of rays stored.
Definition raytrace.h:168
void trace(std::string FName)
Starting point of the raytracing with the filename where the data will be stored.
void traceLeaveObject()
this function is called when the ray leaves an object
std::vector< maths::Vector< double > > P1
Here, the starting points of each step are stored if no filename is given.
Definition raytrace.h:166
void trace()
If no Filename is given, the starting and endpoint of each ray step is stored in two arrays named P1 ...
This class makes a raytracing without any output (except detectors) In this ray tracing class no reac...
Definition raytrace.h:185
void traceEnterObject()
this function is called when the ray enters an object
Definition raytrace.h:188
Raytrace_pure(const Scene &)
Constructor with Scene Object.
void traceLeaveObject()
this function is called when the ray leaves an object
Definition raytrace.h:187
This class provides all functionalities for the base raytracing code. It follows all rays from all li...
Definition raytrace.h:86
bool useRRTParms
Flag which tells the raytracing procedure if the RRT parameters of scene or the normal parameters are...
Definition raytrace.h:117
virtual void traceOneRay(RayBase *ray, int &Reflexions, int &recur)
traces one ray
maths::Vector< std::complex< double > > EStop2
Start and end value of the electric field (second ray in IRay)
Definition raytrace.h:103
maths::Vector< std::complex< double > > EStop
Start and end value of the electric field.
Definition raytrace.h:102
int currentObj
Number of the last object hit (no object hit: -1)
Definition raytrace.h:98
maths::Vector< double > PStart
Definition raytrace.h:101
void setNumReflex(int numReflex)
sets number of reflexions
RayBase * tray
transmitted ray
Definition raytrace.h:127
double PowIn
Power of the incident ray.
Definition raytrace.h:114
double PowTrans
Power of the transmitted ray.
Definition raytrace.h:115
int currentLS
Number of the current light source, which is currently in the calculation process.
Definition raytrace.h:99
maths::Vector< double > ktrans
direction of the transmitted ray
Definition raytrace.h:109
Raytrace(const Scene &S)
virtual void traceEnterObject()=0
this function is called when the ray enters an object
Scene S
Description of the scene.
Definition raytrace.h:116
maths::Vector< double > kin
direction of the incident ray
Definition raytrace.h:107
maths::Vector< double > kref
direction of the reflected ray
Definition raytrace.h:108
void init()
this function is called if no object was hidden
virtual void traceStopObject()
Definition raytrace.h:88
virtual void traceLeaveObject()=0
this function is called when the ray leaves an object
void trace()
this is the starting point for the raytracing procedure
RayBase * ray
current ray
Definition raytrace.h:126
double PowRef
Powers stored when ray type is PRay.
Definition raytrace.h:113
void setScene(const Scene &S)
sets Scene
int lost
Rays unintentionally get lost, e.g. due to total internal reflection.
Definition raytrace.h:97
GOAT::maths::Vector< INDEX_TYPE > currentIndex
Definition raytrace.h:100
bool Abbruch
flag to stop calculation
Definition raytrace.h:128
maths::Vector< std::complex< double > > EStart2
Definition raytrace.h:103
maths::Vector< double > PStop
Start and end point of the last step.
Definition raytrace.h:101
int type
Flag which shows which type of raytracer is selected.
Definition raytrace.h:118
void copyRay(RayBase *&dest, RayBase *src)
int numReflex
current number of reflections
Definition raytrace.h:129
maths::Vector< std::complex< double > > EStart
Definition raytrace.h:102
Class defining a scene with lightsources and objects. This is a container used to inform the Raytrace...
Definition raytrace.h:28
bool suppress_phase_progress
If true, phase progress is skipped. This is needed for short pulse calculations.
Definition raytrace.h:70
int nDet
Number of detectors.
Definition raytrace.h:64
void addLightSourceList(int nls, std::vector< LightSrc * > ls)
add list of lightsources, nls: number of lightsources
void setnSRRT(std::complex< double > nS)
set the refractive index of the filling material in the scene
void removeAllLightSources()
removes all light sources from the scene
void addObject(ObjectShape *Obj)
add single object to scene
int nLS
Number of light sources.
Definition raytrace.h:63
int nObj
Number of objects in the scene.
Definition raytrace.h:62
double r0
Radius of the calculation space. All rays are followed within this calculation sphere.
Definition raytrace.h:68
void addObjectList(int nobj, std::vector< ObjectShape * > obj)
add a list of objects to scene, nobj: number of objects
void addLightSource(LightSrc *ls, int raytype)
add single lightsource to scene and determine ray type
std::vector< LightSrc * > LS
List of all light sources.
Definition raytrace.h:59
void removeAllObjects()
removes all objects from the scene
void setPhaseProgress(bool suppress_phase_progress)
LightSrc * LSRRT
Light source for reversed ray tracing (RRT)
Definition raytrace.h:60
int raytype
Type of the rays created by the light source. More detailed information about the available ray types...
Definition raytrace.h:69
void removeLightSrc(int index)
remove one light source from the scene
void removeDetector(int index)
remove detector "index" from detector list
int testLS()
tests, if all lightsources are outside all objects (return value: -1, if every lightsource is outside...
std::vector< ObjectShape * > Obj
List of all objects within the scene.
Definition raytrace.h:58
Scene()
Standard constructor.
void removeObject(int index)
removes object with index "index" from object list
void setRaytype(int raytype)
set the ray type for all light sources
void removeAllDetectors()
remove all detectors from the scene
void addLightSource(LightSrc *ls)
add single lightsource to scene
Definition raytrace.h:38
void cleanAllDetectors()
clean all detectors, i.e. all detectors are set to zero, but the detectors remain in the scene
Scene(const Scene &S)
Copy constructor.
void removeObject(ObjectShape *obj)
removes object, identified by its pointer from object list
void addLightSourceRRT(LightSrc *ls, maths::Vector< std::complex< double > >Pol1, maths::Vector< std::complex< double > >Pol2)
std::complex< double > nSRRT
refractive index of the surrounding medium (RRT), i.e. the medium between the objects
Definition raytrace.h:67
void setnS(std::complex< double > nS)
set the refractive index of the filling material in the scene
void addDetector(Detector *D)
add single detector to scene
std::vector< Detector * > Det
List of detectors, which are storing the electric field inside a defined area.
Definition raytrace.h:61
void addDetectorList(int nDet, std::vector< Detector * > D)
add a list of detectors to the scene, nDet: number of detectors to add
void setr0(double r0)
set the radius of the calculation space
std::complex< double > nS
refractive index of the surrounding medium, i.e. the medium between the objects
Definition raytrace.h:66
void resetLS()
reset all light sources. That means the counters for the rays within of the light sources are set to ...
#define LIGHTSRC_RAYTYPE_IRAY
Ray class : IRay.
Definition lightsrc.h:17
Raytracer used for ultrashort pulse calculation with raytracing only.
Definition asphericLens.h:6
This class is used for the iray class. This class is intended for internal use only....
Definition fresnel.h:7
#define RAYTRACER_TYPE_NONE
Definition raytrace.h:15
#define RAYTRACE_MAX_REFLEXIONS
Definition raytrace.h:21
This file contains the Vector template class and some useful functions around this class.