#include "stdafx.h" #include "BoundaryInput.h" using namespace std; void disable_inputs(BoundaryDialog* BoundaryDlg) { UNREFERENCED_PARAMETER(BoundaryDlg); //to get rid of compiler warning message //common inputs disabled in dialog class } /* re-enable the windows after an analysis run is done */ void enable_inputs(BoundaryDialog* BoundaryDlg){ //enable the common inputs BoundaryDlg->EnableCommonInputs(); //flash for 3 seconds to alert user that we are done BoundaryDlg->FlashWindowEx(FLASHW_TRAY, 3, 0); } UINT BoundarySetup(LPVOID pParam) { char boundary_directory[512]; BoundaryDialog* BoundaryDlg = (BoundaryDialog*) pParam; disable_inputs(BoundaryDlg); sprintf(boundary_directory, "%sSurfaceStructure", BoundaryDlg->field_directory_work_str); if (!CreateDirectory(boundary_directory, NULL)) //create a new surface structure directory if needed write_to_log("Surface Structure: 'SurfaceStructure' directory already exists, new one will not be created."); DS_1b_cube * ds_cube = BoundaryDlg->Dlg_Input_to_cDS(); UNREFERENCED_PARAMETER(ds_cube); //to get rid of compiler warning message //THICKNESS //if (BoundaryDlg->check_run_thickness_dist.GetCheck()) //{ // minT = BoundaryDlg.m_b_upper - BoundaryDlg.m_t_lower; // maxT = BoundaryDlg.m_b_lower - BoundaryDlg.m_t_upper; // for(int i = BoundaryDlg.m_first; i <= BoundaryDlg.m_last; i++) // { // sprintf(samplebmpname,"%s%d.bmp", pictureName, i); // sprintf(outputname,"resultThickness//thick_%s%d.txt", bmp_fname, i); // sprintf(newDirPath,"resultThickness/"); // CreateDirectory(newDirPath,NULL); // cout<<"Processing the "<<i<<" image: "<<samplebmpname<<endl; // cout<<"Output "<<outputname<<endl<<endl; // List<headtail>* result; // result=getboundary(samplebmpname, thres, BoundaryDlg.m_left, BoundaryDlg.m_right); // //AfxMessageBox("Running getboundary."); // getathickness(result,outputname);//OK // //AfxMessageBox("Running getthickness."); // } // getdist(bmp_fname, BoundaryDlg.m_first, BoundaryDlg.m_last, BoundaryDlg.m_t_upper, BoundaryDlg.m_t_lower, // BoundaryDlg.m_b_upper, BoundaryDlg.m_b_lower, BoundaryDlg.m_left, BoundaryDlg.m_right, manual, invert, BoundaryDlg.m_threshold); //} // // //SURFACE VOLUME // if (BoundaryDlg.m_runsurfacestructure == TRUE) // { // sprintf(newDirPath,"resultSurfaceVolume/"); // CreateDirectory(newDirPath,NULL); // sprintf(outputname,"resultSurfaceVolume/surface_blend3.txt"); // // for(i = BoundaryDlg.m_first; i <= BoundaryDlg.m_last; i++) // { // sprintf(samplebmpname,"%s%d.bmp", pictureName, i); // List<headtail>* result; // result=getboundary(samplebmpname, thres, BoundaryDlg.m_left, BoundaryDlg.m_right); // cout<<"Get Peak from "<<i<<" slice: "<<endl; // getpeak(result,&high,&low, BoundaryDlg.m_t_upper, BoundaryDlg.m_t_lower, // BoundaryDlg.m_b_upper, BoundaryDlg.m_b_lower); // cout<<"Get Surface Height from "<<i<<" slice: "<<endl; // getsurhigh(result,high,low,outputname, // BoundaryDlg.m_t_upper, BoundaryDlg.m_t_lower, // BoundaryDlg.m_b_upper, BoundaryDlg.m_b_lower); // } // // getsurdist(outputname, "surface_volume_distribution.csv", bmp_fname, BoundaryDlg.m_first, BoundaryDlg.m_last, // BoundaryDlg.m_t_upper, BoundaryDlg.m_t_lower, BoundaryDlg.m_b_upper, BoundaryDlg.m_b_lower, // BoundaryDlg.m_left, BoundaryDlg.m_right, manual, invert, BoundaryDlg.m_threshold); // // } // // //CONTACT FRACTION AND SURFACE PIT DIST // if ( (BoundaryDlg.m_runbottom == TRUE) || (BoundaryDlg.m_runtop == TRUE)) // { // peak1=10000; // peak2=0; // for(i = BoundaryDlg.m_first; i <= BoundaryDlg.m_last; i++) // { // cout<<"Get Peak from "<<i<<" slice: "<<endl; // sprintf(samplebmpname,"%s%d.bmp", pictureName, i);//sprintf(samplebmpname,"d://Users//Leiwang//project//w50edp//W50EDP_0%d.bmp",i); // List<headtail>* result; // result=getboundary(samplebmpname, thres, BoundaryDlg.m_left, BoundaryDlg.m_right); // //result=getboundary(samplebmpname); // if(result->getNumber() <= 100) // { // cout<<endl; // continue; // } // // //int high,low; // getpeak(result,&high,&low, BoundaryDlg.m_t_upper, BoundaryDlg.m_t_lower, // BoundaryDlg.m_b_upper, BoundaryDlg.m_b_lower); // //getpeak(result,&high,&low); // result->Clear(); // if(high < peak1) // peak1 = high; // if(low > peak2) // peak2 = low; // } // // if (BoundaryDlg.m_runtop == TRUE) // { // ofstream fout("contact_fraction_Top.csv",ios::out); // char bmp_name[512]; // if(!fout.is_open()) // { // cout<<"cannot write file..."<<endl; // exit(1); // } // //sample info // sprintf(bmp_name, "%s###.bmp", bmp_fname); // fout << "Results file for contact fraction on top layer."<<endl<<endl; // fout << "Sample Name:,," << bmp_name << endl; // fout << "Run Parameters:,,,First Slice," << BoundaryDlg.m_first << ",,Last Slice,"<< BoundaryDlg.m_last << endl; // fout << ",,Top:,Upper limit," << BoundaryDlg.m_t_upper << ",,Lower limit," << BoundaryDlg.m_t_lower << endl; // fout << ",,,Left limit," << BoundaryDlg.m_left << ",,Right limit," << BoundaryDlg.m_right << endl; // fout << ",,,Threshold," << BoundaryDlg.m_threshold; // if (manual == 1) // fout << ",(manual),Inverted?,"; // else // fout << ",(auto),Inverted?,"; // if (invert == 1) // fout << "YES" << endl; // else // fout << "NO" << endl; // fout << endl << endl; // // fout << "Layer" << "," << "Fraction" << endl; // for(i = peak1; i <= BoundaryDlg.m_t_lower; i++) // { // cout<<"On Level "<<i<<" ..."<<endl; // j = i - peak1; // //char pitoutname[40]; // sprintf(pitoutname,"resultContactFractTop/pitdist_%d.txt",j); // sprintf(newDirPath,"resultContactFractTop/"); // CreateDirectory(newDirPath,NULL); // // double contactfract=getcontactpit(pictureName, BoundaryDlg.m_first, // BoundaryDlg.m_last, j, pitoutname, true, thres, BoundaryDlg.m_left, BoundaryDlg.m_right, BoundaryDlg.m_t_upper, BoundaryDlg.m_t_lower, BoundaryDlg.m_b_upper, BoundaryDlg.m_b_lower); // // if(fabs(contactfract - 1.0) < 0.001) break; // // else // { // cout<<"The contact fraction of level "<<i<<" is: "<<contactfract<<endl; // fout << j << "," << contactfract << endl; // } // } // fout.close(); // getdistsurfpit("resultContactFractTop/pitdist_", "surfacepit_distribution_Top.csv", bmp_name, // BoundaryDlg.m_first, BoundaryDlg.m_last, BoundaryDlg.m_t_upper, BoundaryDlg.m_t_lower, // BoundaryDlg.m_left, BoundaryDlg.m_right, manual, invert, BoundaryDlg.m_res, BoundaryDlg.m_threshold, 0); // } // // if (BoundaryDlg.m_runbottom == TRUE) // { // ofstream fout("contact_fraction_Bottom.csv",ios::out); // char bmp_name[512]; // if(!fout.is_open()) // { // cout<<"cannot write file..."<<endl; // exit(1); // } // sprintf(bmp_name, "%s###.bmp", bmp_fname); // fout << "Results file for contact fraction on bottom layer."<<endl<<endl; // fout << "Sample Name:,,," << bmp_name << endl; // fout << "Run Parameters:,First Slice," << BoundaryDlg.m_first << ",,Last Slice,"<< BoundaryDlg.m_last << endl; // fout << ",,Bottom:,Upper limit," << BoundaryDlg.m_b_upper << ",,Lower limit," << BoundaryDlg.m_b_lower << endl; // fout << ",,,Left limit," << BoundaryDlg.m_left << ",,Right limit," << BoundaryDlg.m_right << endl; // fout << ",,,Threshold," << BoundaryDlg.m_threshold; // if (manual == 1) // fout << ",(manual),Inverted?,"; // else // fout << ",(auto),Inverted?,"; // if (invert == 1) // fout << "YES" << endl; // else // fout << "NO" << endl; // fout << endl << endl; // // fout << "Layer" << "," << "Fraction" << endl; // for(i = peak2; i >= BoundaryDlg.m_b_upper; i--) // { // cout<<"On Level "<<i<<" ..."<<endl; // int j = peak2 - i; // // sprintf(pitoutname,"resultContactFractBottom//pitdist_%d.txt",j); // sprintf(newDirPath,"resultContactFractBottom/"); // CreateDirectory(newDirPath,NULL); // // double contactfract=getcontactpit(pictureName, BoundaryDlg.m_first, // BoundaryDlg.m_last, j, pitoutname, false, thres, BoundaryDlg.m_left, BoundaryDlg.m_right, BoundaryDlg.m_t_upper, BoundaryDlg.m_t_lower, BoundaryDlg.m_b_upper, BoundaryDlg.m_b_lower); // // if(fabs(contactfract-1.0)<0.001) break; // // else // { // cout<<"The contact fraction of level "<<i<<" is: "<<contactfract<<endl; // fout<<j<<","<<contactfract<<endl; // } // } // fout.close(); // getdistsurfpit("resultContactFractBottom/pitdist_", "surfacepit_distribution_Bottom.csv", bmp_name, // BoundaryDlg.m_first, BoundaryDlg.m_last, BoundaryDlg.m_b_upper, BoundaryDlg.m_b_lower, // BoundaryDlg.m_left, BoundaryDlg.m_right, manual, invert, BoundaryDlg.m_res, BoundaryDlg.m_threshold, 1); // //getdistsurfpit("resultContactFractBottom/pitdist_", "surfacepit_distribution_Bottom.txt", // // BoundaryDlg.m_b_upper, BoundaryDlg.m_b_lower, BoundaryDlg.m_res, thres); // //cout<<"done!"<<endl; // } // } // // enable_inputs(BoundaryDlg); return 0; }