#include "globals.h" #include #include #include using namespace std; vector LoadSpectrum(string filename) { //load a spectrum from a file and resample to 2wn intervals //create the spectrum vector S; //open the file ifstream inFile(filename.c_str()); SpecPair temp; while(!inFile.eof()){ inFile>>temp.nu; inFile>>temp.A; S.push_back(temp); } //compute the minimum and maximum input wavenumbers double inMin = S.front().nu; double inMax = S.back().nu; int nuMin = (int)ceil(inMin); int nuMax = (int)floor(inMax); //make sure both are either even or odd if(nuMin % 2 != nuMax % 2) nuMax--; //compute the number of values in the resampled spectrum int nVals = (nuMax - nuMin)/2 + 1; //allocate space for the spectrum vector outSpec; double nu, highVal, lowVal, a; int j=1; for(int i=0; i inMax) temp.A = 0.0; else { //move to the correct position in the input array while(j < (int)S.size()-1 && S[j].nu <= nu) j++; lowVal = S[j-1].nu; highVal = S[j].nu; a = (nu - lowVal)/(highVal - lowVal); temp.A = S[j-1].A * (1.0 - a) + S[j].A * a; } outSpec.push_back(temp); } return outSpec; } vector SetReferenceSpectrum(char* text) { stringstream inString(text); //create the spectrum vector S; SpecPair temp; while(!inString.eof()){ inString>>temp.nu; inString>>temp.A; S.push_back(temp); } return S; } void SaveK(string fileName) { ofstream outFile(fileName.c_str()); for(unsigned int i=0; i>nuMin; inFile>>nuMax; inFile>>aMin; inFile>>aMax; inFile>>dNu; //material parameters inFile>>radius; inFile>>baseIR; inFile>>cA; //optical parameters inFile>>cNAi; inFile>>cNAo; inFile>>oNAi; inFile>>oNAo; inFile.close(); } void SetDefaults() { nuMin = 800; nuMax = 4000; dNu = 2; aMin = 0; aMax = 1; //material parameters radius = 4.0f; baseIR = 1.49f; cA = 1.0; vector KMaterial; vector NMaterial; //optical parameters cNAi = 0.0; cNAo = 0.6; oNAi = 0.0; oNAo = 0.6; }