#include "StdAfx.h" #include "MedialInput.h" // -------------------------------------------------------------------------------------------- // // Description - // -------------------------------------------------------------------------------------------- void disable_inputs( MedialDialog *medial_dlg_ptr ) { // Note: common inputs disabled in dialog class medial_dlg_ptr->check_save_bs_cube.EnableWindow(false); medial_dlg_ptr->check_save_ss_cube.EnableWindow(false); medial_dlg_ptr->check_save_cl_cube.EnableWindow(false); medial_dlg_ptr->check_save_bs_cube_rgb.EnableWindow(false); medial_dlg_ptr->check_save_ss_cube_rgb.EnableWindow(false); medial_dlg_ptr->check_save_cl_cube_rgb.EnableWindow(false); medial_dlg_ptr->check_mark_cl_max.EnableWindow(false); medial_dlg_ptr->check_save_sp_cube.EnableWindow(false); medial_dlg_ptr->check_save_medial_axis_1bit.EnableWindow(false); medial_dlg_ptr->check_save_medial_axis_detailed.EnableWindow(false); medial_dlg_ptr->check_save_medial_axis_graph.EnableWindow(false); medial_dlg_ptr->check_network_graph_txt.EnableWindow(false); // Options medial_dlg_ptr->check_bounds_are_fiber.EnableWindow(false); medial_dlg_ptr->combo_rp_method.EnableWindow(false); medial_dlg_ptr->check_run_on_fiber.EnableWindow(false); medial_dlg_ptr->check_log_deleted_paths.EnableWindow(false); medial_dlg_ptr->check_log_forced_links.EnableWindow(false); medial_dlg_ptr->check_enable_caching_from_disc.EnableWindow(false); medial_dlg_ptr->field_cache_ram_limit_cntrl.EnableWindow(false); // Analysis medial_dlg_ptr->field_node_dens_um_cube_cntrl.EnableWindow(false); // Optional inputs medial_dlg_ptr->check_bs_input.EnableWindow(false); medial_dlg_ptr->check_ss_input.EnableWindow(false); medial_dlg_ptr->check_cl_input.EnableWindow(false); medial_dlg_ptr->check_ma_input.EnableWindow(false); medial_dlg_ptr->button_bs_cube.EnableWindow(false); medial_dlg_ptr->button_ss_cube.EnableWindow(false); medial_dlg_ptr->button_cl_cube.EnableWindow(false); medial_dlg_ptr->button_ma_cube.EnableWindow(false); medial_dlg_ptr->field_bs_file_name_cntrl.EnableWindow(false); medial_dlg_ptr->field_ss_file_name_cntrl.EnableWindow(false); medial_dlg_ptr->field_cl_file_name_cntrl.EnableWindow(false); medial_dlg_ptr->field_ma_file_name_cntrl.EnableWindow(false); } // -------------------------------------------------------------------------------------------- // // Description - // -------------------------------------------------------------------------------------------- void enable_inputs( MedialDialog *medial_dlg_ptr ) { // Enable the common inputs medial_dlg_ptr->EnableCommonInputs( ); medial_dlg_ptr->check_save_bs_cube.EnableWindow(true); medial_dlg_ptr->check_save_ss_cube.EnableWindow(true); medial_dlg_ptr->check_save_cl_cube.EnableWindow(true); medial_dlg_ptr->check_save_bs_cube_rgb.EnableWindow(true); medial_dlg_ptr->check_save_ss_cube_rgb.EnableWindow(true); medial_dlg_ptr->check_save_cl_cube_rgb.EnableWindow(true); //medial_dlg_ptr->check_mark_cl_max.EnableWindow(true); medial_dlg_ptr->check_save_sp_cube.EnableWindow(true); medial_dlg_ptr->check_save_medial_axis_1bit.EnableWindow(true); medial_dlg_ptr->check_save_medial_axis_detailed.EnableWindow(true); medial_dlg_ptr->check_save_medial_axis_graph.EnableWindow(true); medial_dlg_ptr->check_network_graph_txt.EnableWindow(true); // Options medial_dlg_ptr->check_bounds_are_fiber.EnableWindow(true); medial_dlg_ptr->combo_rp_method.EnableWindow(true); medial_dlg_ptr->check_run_on_fiber.EnableWindow(true); medial_dlg_ptr->check_log_deleted_paths.EnableWindow(true); medial_dlg_ptr->check_log_forced_links.EnableWindow(true); medial_dlg_ptr->check_enable_caching_from_disc.EnableWindow(true); if ( medial_dlg_ptr->check_enable_caching_from_disc.GetCheck() ) { medial_dlg_ptr->field_cache_ram_limit_cntrl.EnableWindow(true); } // Analysis medial_dlg_ptr->field_node_dens_um_cube_cntrl.EnableWindow(true); // Optional inputs medial_dlg_ptr->check_bs_input.EnableWindow(true); medial_dlg_ptr->check_ss_input.EnableWindow(true); medial_dlg_ptr->check_cl_input.EnableWindow(true); medial_dlg_ptr->check_ma_input.EnableWindow(true); if ( medial_dlg_ptr->check_bs_input.GetCheck() ) { medial_dlg_ptr->field_bs_file_name_cntrl.EnableWindow(true); medial_dlg_ptr->button_bs_cube.EnableWindow(true); } if ( medial_dlg_ptr->check_ss_input.GetCheck() ) { medial_dlg_ptr->button_ss_cube.EnableWindow(true); medial_dlg_ptr->field_ss_file_name_cntrl.EnableWindow(true); } if ( medial_dlg_ptr->check_bs_input.GetCheck() ) { medial_dlg_ptr->button_cl_cube.EnableWindow(true); medial_dlg_ptr->field_cl_file_name_cntrl.EnableWindow(true); } if ( medial_dlg_ptr->check_bs_input.GetCheck() ) { medial_dlg_ptr->button_ma_cube.EnableWindow(true); medial_dlg_ptr->field_ma_file_name_cntrl.EnableWindow(true); } // Flash for 3 seconds to alert user that we are done medial_dlg_ptr->FlashWindowEx( FLASHW_TRAY, 3, 0 ); } // -------------------------------------------------------------------------------------------- // // Description - // -------------------------------------------------------------------------------------------- UINT MedialSetup( LPVOID pParam ) { ma_options run_options = MA_OPTIONS_NONE; char medial_directory[MAX_FILE_STR_LEN], data_out_prefix[MAX_FILE_STR_LEN]; MedialDialog *MedialDlg = (MedialDialog*) pParam; // Disable dialog inputs disable_inputs( MedialDlg ); // Create a new sphere result directory if needed sprintf( medial_directory, "%sMedialAxis", MedialDlg->field_directory_work_str ); if ( !CreateDirectory(medial_directory, NULL) ) { write_to_log("MedialAxis: %s directory already exists, new one will not be created.", medial_directory); } sprintf( data_out_prefix, "%s\\%s", medial_directory, MedialDlg->field_name_output_str ); if ( !CreateDirectory(data_out_prefix, NULL) ) { write_to_log("MedialAxis: %s directory already exists, new one will not be created.", data_out_prefix); } sprintf( medial_directory, "%s\\%s", data_out_prefix, MedialDlg->field_name_output_str ); sprintf( data_out_prefix, "%s", medial_directory ); // Convert input to DS_1b_cube DS_1b_cube *input_cube_ptr = MedialDlg->Dlg_Input_to_cDS( ); // Create MA object write_to_log( "Starting medial axis analysis..." ); MA_VoxelCoding *MA_obj = new MA_VoxelCoding( input_cube_ptr, &MedialDlg->txt_field_progress, &MedialDlg->pbar_simulation_progress ); // Setup options run_options |= (ma_options) ( (MedialDlg->check_bounds_are_fiber.GetCheck())? (MA_BOUNDARY_IS_SOLID) : (0) ); run_options |= (ma_options) ( (MedialDlg->combo_rp_method.GetCurSel() == 1)? (MA_USE_MAX_BS_FOR_RP) : (0) ); run_options |= (ma_options) ( (MedialDlg->check_save_bs_cube.GetCheck())? (MA_SAVE_BS_GRAY) : (0) ); run_options |= (ma_options) ( (MedialDlg->check_save_bs_cube_rgb.GetCheck())? (MA_SAVE_BS_RGB) : (0) ); run_options |= (ma_options) ( (MedialDlg->check_save_ss_cube.GetCheck())? (MA_SAVE_SS_GRAY) : (0) ); run_options |= (ma_options) ( (MedialDlg->check_save_ss_cube_rgb.GetCheck())? (MA_SAVE_SS_RGB) : (0) ); run_options |= (ma_options) ( (MedialDlg->check_save_cl_cube.GetCheck())? (MA_SAVE_CL_GRAY) : (0) ); run_options |= (ma_options) ( (MedialDlg->check_save_cl_cube_rgb.GetCheck())? (MA_SAVE_CL_RGB) : (0) ); run_options |= (ma_options) ( (MedialDlg->check_mark_cl_max.GetCheck())? (MA_SAVE_CL_MARKED) : (0) ); run_options |= (ma_options) ( (MedialDlg->check_save_sp_cube.GetCheck())? (MA_SAVE_SP_CUBE) : (0) ); run_options |= (ma_options) ( (MedialDlg->check_save_medial_axis_1bit.GetCheck())? (MA_SAVE_MA_CUBE) : (0) ); run_options |= (ma_options) ( (MedialDlg->check_save_medial_axis_detailed.GetCheck())? (MA_SAVE_MA_DETAILED) : (0) ); run_options |= (ma_options) ( (MedialDlg->check_save_medial_axis_graph.GetCheck())? (MA_SAVE_MA_GRAPH) : (0) ); run_options |= (ma_options) ( (MedialDlg->check_network_graph_txt.GetCheck())? (MA_SAVE_NETWORK_TXT) : (0) ); run_options |= (ma_options) ( (MedialDlg->check_log_deleted_paths.GetCheck())? (MA_LOG_DELETED_PATHS) : (0) ); run_options |= (ma_options) ( (MedialDlg->check_log_forced_links.GetCheck())? (MA_LOG_FORCED_LINKS) : (0) ); MA_obj->changeNodeDistributionCubeSize( MedialDlg->field_node_dens_um_cube_float ); MA_obj->changePixelSize( MedialDlg->field_pixel_size_float ); // Set cache parameters if requested if ( MedialDlg->check_enable_caching_from_disc.GetCheck() ) { MA_obj->enableCachingFromDisc( (unsigned int)MedialDlg->field_cache_ram_limit_int ); } // Preload any cubes if ( MedialDlg->is_bs_input_valid == true ) { if ( MA_obj->preloadBSCube( MedialDlg->input_bs_cube_file_name ) != MA_NO_ERRORS ) { write_to_log("MedialSetup - Error loading existing BS cube '%s', will be created from scratch.", MedialDlg->input_bs_cube_file_name); } } if ( MedialDlg->is_ss_input_valid == true ) { if ( MA_obj->preloadSSCube( MedialDlg->input_ss_cube_file_name ) != MA_NO_ERRORS ) { write_to_log("MedialSetup - Error loading existing SS cube '%s', will be created from scratch.", MedialDlg->input_ss_cube_file_name); } } if ( MedialDlg->is_cl_input_valid == true ) { if ( MA_obj->preloadCLCube( MedialDlg->input_cl_cube_file_name ) != MA_NO_ERRORS ) { write_to_log("MedialSetup - Error loading existing CL cube '%s', will be created from scratch.", MedialDlg->input_cl_cube_file_name); } } if ( MedialDlg->is_ma_input_valid == true ) { if ( MA_obj->preloadMACube( MedialDlg->input_ma_cube_file_name ) != MA_NO_ERRORS ) { write_to_log("MedialSetup - Error loading existing MA cube '%s', will be created from scratch.", MedialDlg->input_ma_cube_file_name); } } if ( MedialDlg->check_run_on_fiber.GetCheck() ) { // Attach 'invert' to output name strcat( data_out_prefix, "_fiber" ); input_cube_ptr->invert(); } // Generate Medial Axis MA_obj->runMedialAxis( run_options, data_out_prefix ); // Incase queueing ever implemented, restore input cube back to original if ( MedialDlg->check_run_on_fiber.GetCheck() ) { input_cube_ptr->invert(); } delete MA_obj; delete input_cube_ptr; // Done enable_inputs(MedialDlg); MedialDlg->txt_field_progress.SetWindowText("Done with medial axis analysis!"); return 0; }