3f56f1f9
dmayerich
initial commit
|
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
for(int i=0; i<matVec.size(); i+=2)
{
rts::material<ptype> newM(vm["lambda"].as<ptype>(), matVec[i], matVec[i+1]);
SCOPE->nf.mVector.push_back(newM);
}
}
else
{
//add the command line material as the default (material 0)
rts::material<ptype> newM(vm["lambda"].as<ptype>(), vm["n"].as<ptype>(), vm["k"].as<ptype>());
SCOPE->nf.mVector.push_back(newM);
}
//if file names are specified, load the materials
if(vm.count("material-file"))
{
vector<string> filenames = vm["material-file"].as< vector<string> >();
for(int i=0; i<filenames.size(); i++)
{
//load the file into a string
std::ifstream ifs(filenames[i].c_str());
std::string instr((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
//load the list of spheres from a string
rts::material<ptype> newM;
newM.fromStr(instr, "");
SCOPE->nf.mVector.push_back(newM);
}
}
}
static void loadNearfieldParams(po::variables_map vm)
{
//test to see if we are simulating a plane wave
bool planeWave = DEFAULT_PLANEWAVE;
if(vm.count("plane-wave"))
planeWave = !planeWave;
SCOPE->nf.planeWave = planeWave;
//get the wavelength
SCOPE->nf.lambda = vm["lambda"].as<ptype>();
//get the incident field amplitude
SCOPE->nf.A = vm["amplitude"].as<ptype>();
//get the condenser parameters
SCOPE->nf.condenser[0] = vm["condenser-min"].as<ptype>();
SCOPE->nf.condenser[1] = vm["condenser-max"].as<ptype>();
//get the focal rtsPoint position
SCOPE->nf.focus[0] = vm["fx"].as<ptype>();
SCOPE->nf.focus[1] = vm["fy"].as<ptype>();
SCOPE->nf.focus[2] = vm["fz"].as<ptype>();
//get the incident light direction (k-vector)
bsVector spherical;
spherical[0] = 1.0;
spherical[1] = vm["theta"].as<ptype>();
spherical[2] = vm["phi"].as<ptype>();
SCOPE->nf.k = spherical.sph2cart();
//incident field order
SCOPE->nf.m = vm["field-order"].as<int>();
//number of Monte-Carlo samples
SCOPE->nf.nWaves = vm["samples"].as<int>();
}
static void loadSliceParams(po::variables_map vm)
{
//parameters for the sample plane
//set the default values for the slice position and orientation
bsPoint pMin(vm["plane-min-x"].as<ptype>(), vm["plane-min-y"].as<ptype>(), vm["plane-min-z"].as<ptype>());
bsPoint pMax(vm["plane-max-x"].as<ptype>(), vm["plane-max-y"].as<ptype>(), vm["plane-max-z"].as<ptype>());
bsVector normal(vm["plane-norm-x"].as<ptype>(), vm["plane-norm-y"].as<ptype>(), vm["plane-norm-z"].as<ptype>());
SCOPE->setPos(pMin, pMax, normal);
//resolution
SCOPE->setRes(vm["resolution"].as<unsigned int>(),
vm["resolution"].as<unsigned int>(),
vm["padding"].as<unsigned int>(),
vm["supersample"].as<unsigned int>());
SCOPE->setNearfield();
}
static void loadMicroscopeParams(po::variables_map vm)
{
//objective
SCOPE->objective[0] = vm["objective-min"].as<ptype>();
SCOPE->objective[1] = vm["objective-max"].as<ptype>();
}
static void loadOutputParams(po::variables_map vm)
{
|
3f56f1f9
dmayerich
initial commit
|
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
|
}
static void SetOptions(po::options_description &desc)
{
desc.add_options()
("help,h", "prints this help")
("plane-wave,P", "simulates an incident plane wave")
("intensity,I", po::value<string>()->default_value(DEFAULT_INTENSITY_FILE), "output measured intensity (filename)")
("absorbance,A", po::value<string>()->default_value(DEFAULT_ABSORBANCE_FILE), "output measured absorbance (filename)")
("transmittance,T", po::value<string>()->default_value(DEFAULT_TRANSMITTANCE_FILE), "output measured transmittance (filename)")
("far-field,F", po::value<string>()->default_value(DEFAULT_FAR_FILE), "output far-field at detector (filename)")
("near-field,N", po::value<string>()->default_value(DEFAULT_NEAR_FILE), "output field at focal plane (filename)")
("extended-source,X", po::value<string>()->default_value(DEFAULT_EXTENDED_SOURCE), "image of source at focus (filename)")
//("sx,x", po::value<ptype>()->default_value(DEFAULT_SPHERE_X), "sphere coordinates")
//("sy,y", po::value<ptype>()->default_value(DEFAULT_SPHERE_Y))
//("sz,z", po::value<ptype>()->default_value(DEFAULT_SPHERE_Z))
("sx,x", po::value<ptype>(), "sphere coordinates")
("sy,y", po::value<ptype>())
("sz,z", po::value<ptype>())
("radius,r", po::value<ptype>()->default_value(DEFAULT_SPHERE_A), "sphere radius")
("samples,s", po::value<int>()->default_value(DEFAULT_SAMPLES), "Monte-Carlo samples used to compute Us")
("sphere-file,S", po::value< vector<string> >()->multitoken(), "sphere file:\n [x y z radius material]")
("amplitude,a", po::value<ptype>()->default_value(DEFAULT_AMPLITUDE), "incident field amplitude")
("n,n", po::value<ptype>()->default_value(DEFAULT_N, "1.4"), "sphere phase speed")
("k,k", po::value<ptype>()->default_value(DEFAULT_K), "sphere absorption coefficient")
("material-file,M", po::value< vector<string> >()->multitoken(), "material file:\n [lambda n k]")
("materials", po::value< vector<ptype> >()->multitoken(), "materials specified using n, k pairs:\n ex. --materials n1 k1 n2 k2\n (if used --n and --k are ignored)")
("lambda,l", po::value<ptype>()->default_value(DEFAULT_LAMBDA), "incident wavelength")
("theta,t", po::value<ptype>()->default_value(DEFAULT_K_THETA), "light direction (polar coords)")
("phi,p", po::value<ptype>()->default_value(DEFAULT_K_PHI))
("fx", po::value<ptype>()->default_value(DEFAULT_FOCUS_X), "incident focal point")
("fy", po::value<ptype>()->default_value(DEFAULT_FOCUS_Y))
("fz", po::value<ptype>()->default_value(DEFAULT_FOCUS_Z))
("condenser-max,C", po::value<ptype>()->default_value(DEFAULT_CONDENSER_MAX), "condenser numerical aperature")
("condenser-min,c", po::value<ptype>()->default_value(DEFAULT_CONDENSER_MIN), "condenser obscuration NA")
("objective-max,O", po::value<ptype>()->default_value(DEFAULT_OBJECTIVE_MAX), "objective numerical aperature")
("objective-min,o", po::value<ptype>()->default_value(DEFAULT_OBJECTIVE_MIN), "objective obscuration NA")
("field-order", po::value<int>()->default_value(DEFAULT_FIELD_ORDER), "order of the incident field")
("output-type,f", po::value<string>()->default_value(DEFAULT_FIELD_TYPE), "output field value:\n magnitude, polarization, real, imaginary, angular-spectrum")
("resolution,R", po::value<unsigned int>()->default_value(DEFAULT_SLICE_RES), "resolution of the detector")
("padding,d", po::value<unsigned int>()->default_value(DEFAULT_PADDING), "FFT padding for the objective bandpass")
("supersample", po::value<unsigned int>()->default_value(DEFAULT_SUPERSAMPLE), "super-sampling rate for the detector field")
("colormap", po::value<string>()->default_value(DEFAULT_COLORMAP), "colormap: gray, brewer")
("append", "append result to an existing file\n (binary files only)")
("plane-min-x,u", po::value<ptype>()->default_value(DEFAULT_SLICE_MIN_X), "lower-left corner of the field slice")
("plane-min-y,v", po::value<ptype>()->default_value(DEFAULT_SLICE_MIN_Y))
("plane-min-z,w", po::value<ptype>()->default_value(DEFAULT_SLICE_MIN_Z))
("plane-max-x,U", po::value<ptype>()->default_value(DEFAULT_SLICE_MAX_X), "upper-right corner of the field slice")
("plane-max-y,V", po::value<ptype>()->default_value(DEFAULT_SLICE_MAX_Y))
("plane-max-z,W", po::value<ptype>()->default_value(DEFAULT_SLICE_MAX_Z))
("plane-norm-x", po::value<ptype>()->default_value(DEFAULT_SLICE_NORM_X), "field slice normal")
("plane-norm-y", po::value<ptype>()->default_value(DEFAULT_SLICE_NORM_Y))
("plane-norm-z", po::value<ptype>()->default_value(DEFAULT_SLICE_NORM_Z));
}
static void LoadParameters(int argc, char *argv[])
{
//create an option description
po::options_description desc("Allowed options");
//fill it with options
SetOptions(desc);
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
//display help and exit
if(vm.count("help"))
{
cout<<desc<<endl;
exit(1);
}
//load spheres
loadSpheres(vm);
//load materials
loadMaterials(vm);
loadNearfieldParams(vm);
loadOutputParams(vm);
loadMicroscopeParams(vm);
loadSliceParams(vm);
//if an extended source will be used
if(vm["extended-source"].as<string>() != "")
{
//load the point sources
string filename = vm["extended-source"].as<string>();
SCOPE->LoadExtendedSource(filename);
}
}
|