#include <Surface.hpp>
Public Methods | |
Surface (double inCurvature=0, double inIndex=0, double inAperture=0, double inThickness=0) | |
Construct a Surface object with the values given. By default, values are set to 0. More... | |
~Surface () | |
Destructor (do nothing). | |
double | getAperture () const |
Return aperture radius. | |
double | getCurvature () const |
Return curvature. | |
double | getIndex () const |
Return glass refraction index to the right. | |
double | getThickness () const |
Return distance to the next surface. | |
void | read (std::istream &ioIs=std::cin) |
Read a LOSR::Surface from a C++ input stream. More... | |
void | setAperture (double inAperture) |
Set aperture radius. | |
void | setCurvature (double inCurvature) |
Set curvature. | |
void | setIndex (double inIndex) |
Set glass refraction index. | |
void | setThickness (double inThickness) |
Set distance to next surface. | |
void | write (std::ostream &ioOs=std::cout) const |
Write a LOSR::Surface into a C++ output stream. More... | |
Protected Attributes | |
double | mCurvature |
Curvature of the spherical contact. | |
double | mIndex |
Glass refraction index of the material at the right of the surface. | |
double | mAperture |
Radius of the aperture of the surface. | |
double | mThickness |
Distance to the next surface at the right, on the optical axis. |
LOSR::Surface describe a sperical contact between two optical materials. It haves as attributes, the aperture radius of the surface, the glass refraction index of the material at the right of the surface, the curvature (1/radius) of the surface and the distance to the next surface on the axis.
|
Construct a Surface object with the values given. By default, values are set to 0.
00039 : 00040 mCurvature(inCurvature), 00041 mIndex(inIndex), 00042 mAperture(inAperture), 00043 mThickness(inThickness) 00044 { } |
|
Read a LOSR::Surface from a C++ input stream.
00053 { 00054 char c1 ='\0', c2='\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 // Looking for chars 'c:' 00061 ioIs >> c2; 00062 if((c1!='c') || (c2!=':')) throw LOSR_RuntimeErrorM("Invalide format!"); 00063 if(!ioIs) throw LOSR_RuntimeErrorM("Premature end of stream!"); 00064 // Found what was needed, read curvature 00065 ioIs >> mCurvature; 00066 00067 // Extract and ignore the rest of lines starting with a # 00068 for(ioIs >> c1; c1=='#'; ioIs >> c1) ioIs.getline(buf,2048,'\n'); 00069 if(!ioIs) throw LOSR_RuntimeErrorM("Premature end of stream!"); 00070 // Looking for chars 'i:' 00071 ioIs >> c2; 00072 if((c1!='i') || (c2!=':')) throw LOSR_RuntimeErrorM("Invalide format!"); 00073 if(!ioIs) throw LOSR_RuntimeErrorM("Premature end of stream!"); 00074 // Found what was needed, read glass refraction index 00075 ioIs >> mIndex; 00076 00077 // Extract and ignore the rest of lines starting with a # 00078 for(ioIs >> c1; c1=='#'; ioIs >> c1) ioIs.getline(buf,2048,'\n'); 00079 if(!ioIs) throw LOSR_RuntimeErrorM("Premature end of stream!"); 00080 // Looking for chars 'a:' 00081 ioIs >> c2; 00082 if((c1!='a') || (c2!=':')) throw LOSR_RuntimeErrorM("Invalide format!"); 00083 if(!ioIs) throw LOSR_RuntimeErrorM("Premature end of stream!"); 00084 // Found what was needed, read aperture of the surface 00085 ioIs >> mAperture; 00086 00087 // Extract and ignore the rest of lines starting with a # 00088 for(ioIs >> c1; c1=='#'; ioIs >> c1) ioIs.getline(buf,2048,'\n'); 00089 if(!ioIs) throw LOSR_RuntimeErrorM("Premature end of stream!"); 00090 // Looking for chars 't:' 00091 ioIs >> c2; 00092 if((c1!='t') || (c2!=':')) throw LOSR_RuntimeErrorM("Invalide format!"); 00093 if(!ioIs) throw LOSR_RuntimeErrorM("Premature end of stream!"); 00094 // Found what was needed, read distance to next surface 00095 ioIs >> mThickness; 00096 } |
|
Write a LOSR::Surface into a C++ output stream.
00105 { 00106 ioOs << "c:" << mCurvature 00107 << " \ti:" << mIndex 00108 << " \ta:" << mAperture 00109 << " \tt:" << mThickness 00110 << std::endl; 00111 } |