#include <OpticalSystem.hpp>
Inheritance diagram for LOSR::OpticalSystem::

Public Methods | |
| OpticalSystem (unsigned int inSize=0) | |
| Construct an optical system of the size given. More... | |
| ~OpticalSystem () | |
| Destructor (do nothing). | |
| void | read (std::istream &ioIs=std::cin) |
| Read a LOSR::OpticalSystem from a C++ input stream. More... | |
| void | write (std::ostream &ioOs=std::cout) const |
| Write a LOSR::OpticalSystem into a C++ output stream. More... | |
| bool | validate () |
| Validate and correct the apertures of the optical system. More... | |
LOSR::OpticalSystem is a on-axis lenses system made of optical materials. It is a std::vector of LOSR::Surface, that is a sequence of surface between different optical materials.
|
|
Construct an optical system of the size given.
00041 :
00042 std::vector<Surface>(inSize)
00043 { }
|
|
|
Read a LOSR::OpticalSystem from a C++ input stream.
00052 {
00053 char c1 ='\0', c2='\0';
00054 unsigned int sz = 0;
00055 char buf[2048];
00056
00057 // Extract and ignore the rest of lines starting with a #
00058 for(ioIs >> c1; c1=='#'; ioIs >> c1) ioIs.getline(buf,2048,'\n');
00059 if(!ioIs) throw LOSR_RuntimeErrorM("Premature end of stream!");
00060
00061 // Looking for the number of surface, between parenthesis
00062 ioIs >> sz >> c2;
00063 if((c1!='(') || (c2!=')')) throw LOSR_RuntimeErrorM("Bad file format!");
00064 resize(sz);
00065
00066 // Read each surfaces from the stream
00067 for(unsigned int i=0; i<sz; i++) {
00068 if(!ioIs) throw LOSR_RuntimeErrorM("Premature end of stream!");
00069 (*this)[i].read(ioIs);
00070 }
00071
00072 }
|
|
|
Validate and correct the apertures of the optical system. The system is validate by calculating whether the curvature and the distance between of two adjacent surfaces is physically possible with the given apertures. If the system is not physically possible, the apertures are reduced to the greatest value valid for the actual setup.
00098 {
00099 const double lcMinRadius = 0.0001;
00100 bool lSystemValid = true;
00101
00102 // For all surfaces of the optical system
00103 for(unsigned int i=0; i<(size()-1); i++) {
00104 // Determine the minimal aperture between the two surfaces
00105 double lMinAperture = LOSR_MinM( (*this)[i].getAperture(), (*this)[i+1].getAperture() );
00106
00107 // Calculates values for the first surface
00108 double lAlpha1 = 0;
00109 double lR1 = (*this)[i].getCurvature();
00110 if(fabs(lR1) > lcMinRadius) {
00111 lR1 = 1.0 / lR1;
00112 lAlpha1 = lR1 - sqrt((lR1*lR1) - (lMinAperture*lMinAperture));
00113 }
00114
00115 // Calculates values for the second surface
00116 double lAlpha2 = 0;
00117 double lR2 = (*this)[i+1].getCurvature();
00118 if(fabs(lR2) > lcMinRadius) {
00119 lR2 = 1.0 / lR2;
00120 lAlpha2 = lR2 - sqrt((lR2*lR2) - (lMinAperture*lMinAperture));
00121 }
00122
00123 // Test whether the apertures are valid. If not, correct it
00124 // See maple spreadsheet file opsys_validate.pdf for calculation details.
00125 if((*this)[i].getThickness() < (lAlpha1+lAlpha2)) {
00126 lSystemValid = false;
00127 double lY = 0.0;
00128 double lT = (*this)[i].getThickness();
00129 if(fabs(lR1) <= lcMinRadius) {
00130 // R1 = infinity, x=0, using formula for y2b (see file opsys_validate.pdf)
00131 lY = sqrt( LOSR_Pow2M(lR2) - LOSR_Pow2M(lR2 - lT) );
00132 } else if(fabs(lR2) <= lcMinRadius) {
00133 // R2 = infinity, x=T, using formula for y2a (see file opsys_validate.pdf)
00134 lY = sqrt( LOSR_Pow2M(lR1) - LOSR_Pow2M(lT - lR1) );
00135 } else {
00136 // Using formula for y (see file opsys_validate.pdf)
00137 lY = sqrt(
00138 LOSR_Pow2M(lR1) -
00139 LOSR_Pow2M( ( - (lT * (lT - 2.0 * lR2)) / (2.0 * (lR1 + lR2 - lT)) ) - lR1 )
00140 );
00141 }
00142 (*this)[i].setAperture( LOSR_MinM( (*this)[i].getAperture(), lY ) );
00143 (*this)[i+1].setAperture( LOSR_MinM( (*this)[i+1].getAperture(), lY ) );
00144 }
00145
00146 }
00147 return lSystemValid;
00148 }
|
|
|
Write a LOSR::OpticalSystem into a C++ output stream.
00081 {
00082 ioOs << '(' << size() << ')' << std::endl;
00083 for(unsigned int i=0; i<size(); i++) {
00084 (*this)[i].write(ioOs);
00085 }
00086 }
|
1.2.8.1 written by Dimitri van Heesch,
© 1997-2001