Commit 190d5b42ff7427e0de32215ca150d847a1f245eb

Authored by David Mayerich
1 parent f28a7240

Updated for changes in STIM and CMake

Showing 3 changed files with 33 additions and 15 deletions   Show diff stats
CMakeLists.txt
1 1 #Specify the version being used aswell as the language
2   -cmake_minimum_required(VERSION 2.8)
  2 +cmake_minimum_required(VERSION 3.19)
3 3 #Name your project here
4 4 project(bimsim)
5 5  
... ... @@ -10,7 +10,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
10 10 find_package(CUDA)
11 11  
12 12 #find OpenCV
13   -find_package(OpenCV REQUIRED )
  13 +#find_package(OpenCV REQUIRED )
14 14  
15 15 find_package(Boost REQUIRED)
16 16  
... ...
FindSTIM.cmake
  1 +# finds the STIM library (downloads it if it isn't present)
  2 +# set STIMLIB_PATH to the directory containing the stim subdirectory (the stim repository)
  3 +
1 4 include(FindPackageHandleStandardArgs)
2 5  
3   -set(STIM_INCLUDE_DIR $ENV{STIMLIB_PATH})
  6 +set(STIM_ROOT $ENV{STIM_ROOT})
  7 +
  8 +IF(NOT UNIX)
  9 + IF(NOT STIM_ROOT)
  10 + MESSAGE("ERROR: STIM_ROOT environment variable must be set!")
  11 + ENDIF(NOT STIM_ROOT)
4 12  
5   -find_package_handle_standard_args(STIM DEFAULT_MSG STIM_INCLUDE_DIR)
  13 + FIND_PATH(STIM_INCLUDE_DIRS DOC "Path to GLFW include directory."
  14 + NAMES stim/image/image.h
  15 + PATHS ${STIM_ROOT})
  16 +ENDIF(NOT UNIX)
  17 +
  18 +find_package_handle_standard_args(STIM DEFAULT_MSG STIM_INCLUDE_DIRS)
6 19  
7 20 if(STIM_FOUND)
8   - set(STIM_INCLUDE_DIRS ${STIM_INCLUDE_DIR})
9   -endif()
  21 + set(STIM_INCLUDE_DIRS ${STIM_INCLUDE_DIRS})
  22 +elseif(STIM_FOUND)
  23 + message("STIM library not found. Set the STIM_ROOT environment variable to the STIM location.")
  24 + message("STIMLIB can be found here: https://git.stim.ee.uh.edu/codebase/stimlib")
  25 +endif(STIM_FOUND)
  26 +
  27 +find_package_handle_standard_args(STIM DEFAULT_MSG STIM_INCLUDE_DIRS)
... ...
bimsim.cu
... ... @@ -356,7 +356,7 @@ int main(int argc, char* argv[]){
356 356 beam.eval(E0, g_Nl); //evaluate the incident field
357 357  
358 358 if(g_debug_images && s == 0){
359   - stim::filename incident_file = outfile.prefix(outfile.prefix() + "_0_nfi");
  359 + stim::filename incident_file = outfile.with_prefix(outfile.prefix() + "_0_nfi");
360 360 E0.image(incident_file.str(), stim::complexMag);
361 361 }
362 362 E0.lowpass(stim::TAU / g_lambda * g_NA_obj[1]); //apply the objective cut-off filter to generate the far-field image
... ... @@ -366,14 +366,14 @@ int main(int argc, char* argv[]){
366 366 spheres.eval(E, beam, g_Nl, g_MC);
367 367  
368 368 if(g_debug_images && s == 0){
369   - stim::filename nf_file = outfile.prefix(outfile.prefix() + "_1_nfs");
  369 + stim::filename nf_file = outfile.with_prefix(outfile.prefix() + "_1_nfs");
370 370 E.image(nf_file.str(), stim::complexMag);
371 371 }
372 372  
373 373 E.propagate(g_backprop, stim::TAU / g_lambda); //propagate the field back to the origin
374 374  
375 375 if(g_debug_images && s == 0){
376   - stim::filename propagate_file = outfile.prefix(outfile.prefix()+"_2_nfprop");
  376 + stim::filename propagate_file = outfile.with_prefix(outfile.prefix()+"_2_nfprop");
377 377 E.image(propagate_file.str(), stim::complexMag);
378 378 }
379 379  
... ... @@ -382,7 +382,7 @@ int main(int argc, char* argv[]){
382 382 Eff.intensity(I); //calculate the far field intensity and add it to the single-beam image
383 383  
384 384 if(g_debug_images && s == 0){
385   - stim::filename cropped_file = outfile.prefix(outfile.prefix() + "_3_cropped");
  385 + stim::filename cropped_file = outfile.with_prefix(outfile.prefix() + "_3_cropped");
386 386 Eff.image(cropped_file.str(), stim::complexMag);
387 387 }
388 388 P = (double)(s + 1) / (double)g_sources.size() * 100;
... ... @@ -396,15 +396,15 @@ int main(int argc, char* argv[]){
396 396  
397 397 //save the near-field image
398 398 if (g_debug_images) {
399   - stim::filename nearfield_real_file = outfile.prefix(outfile.prefix() + "_3_detector_real");
  399 + stim::filename nearfield_real_file = outfile.with_prefix(outfile.prefix() + "_3_detector_real");
400 400 E.image(nearfield_real_file.str(), stim::complexReal);
401   - stim::filename nearfield_imag_file = outfile.prefix(outfile.prefix() + "_3_detector_imag");
  401 + stim::filename nearfield_imag_file = outfile.with_prefix(outfile.prefix() + "_3_detector_imag");
402 402 E.image(nearfield_imag_file.str(), stim::complexImaginary);
403 403 }
404 404  
405 405 //save the background and single-beam images
406   - stim::filename background_file = outfile.prefix(outfile.prefix() + "background");
407   - stim::filename intensity_file = outfile.prefix(outfile.prefix() + "intensity");
  406 + stim::filename background_file = outfile.with_prefix(outfile.prefix() + "background");
  407 + stim::filename intensity_file = outfile.with_prefix(outfile.prefix() + "intensity");
408 408  
409 409 if (use_cuda) {
410 410 stim::gpu2image<float>(I0, background_file.str(), g_R_ff, g_R_ff, stim::cmBrewer);
... ... @@ -419,6 +419,6 @@ int main(int argc, char* argv[]){
419 419 float* A;
420 420 HANDLE_ERROR( cudaMalloc(&A, sizeof(float) * g_R_ff * g_R_ff) );
421 421 gpu_absorbance(A, I, I0, g_R_ff * g_R_ff);
422   - stim::filename absorbance_file = outfile.prefix(outfile.prefix() + "absorbance");
  422 + stim::filename absorbance_file = outfile.with_prefix(outfile.prefix() + "absorbance");
423 423 stim::gpu2image<float>(A, absorbance_file.str(), g_R_ff, g_R_ff, stim::cmBrewer);
424 424 }
425 425 \ No newline at end of file
... ...