Created
          November 2, 2012 07:12 
        
      - 
      
- 
        Save anonymous/3999190 to your computer and use it in GitHub Desktop. 
    熊锋求大神!
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // XF_FLT_OMPDlg.cpp : 实现文件 | |
| // | |
| #include "stdafx.h" | |
| #include "XF_FLT_OMP.h" | |
| #include "XF_FLT_OMPDlg.h" | |
| #include "afxdialogex.h" | |
| #ifdef _DEBUG | |
| #define new DEBUG_NEW | |
| #endif | |
| int ThreadCount = 5; | |
| int Progress1, Progress2; | |
| int iPro = 40; | |
| int ProCount[40+1] = {0}; | |
| int iFinishThread; | |
| bool Is45n; | |
| int w, h; | |
| double x, y; | |
| double cell; | |
| int Rw, Rh; | |
| double Rx, Ry; | |
| double Rcell; | |
| double m_Rotate; | |
| int Bw1, Bh1, Bw2, Bh2; | |
| FILE* fp1; //源FLT | |
| FILE* fp2; //目标FLT | |
| CCriticalSection critical_section; | |
| CCriticalSection critical_section_progress; | |
| CCriticalSection critical_section_finish; | |
| CString s_Flt2,s_Flt; | |
| // 用于应用程序“关于”菜单项的 CAboutDlg 对话框 | |
| class CAboutDlg : public CDialogEx | |
| { | |
| public: | |
| CAboutDlg(); | |
| // 对话框数据 | |
| enum { IDD = IDD_ABOUTBOX }; | |
| protected: | |
| virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 | |
| // 实现 | |
| protected: | |
| DECLARE_MESSAGE_MAP() | |
| }; | |
| CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD) | |
| { | |
| } | |
| void CAboutDlg::DoDataExchange(CDataExchange* pDX) | |
| { | |
| CDialogEx::DoDataExchange(pDX); | |
| } | |
| BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) | |
| END_MESSAGE_MAP() | |
| // CXF_FLT_OMPDlg 对话框 | |
| CXF_FLT_OMPDlg::CXF_FLT_OMPDlg(CWnd* pParent /*=NULL*/) | |
| : CDialogEx(CXF_FLT_OMPDlg::IDD, pParent) | |
| , m_Flt(_T("")) | |
| , m_Offsets(_T("")) | |
| , m_Path(_T("")) | |
| , m_Name(_T("")) | |
| , m_ThreadCount(20) | |
| { | |
| m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); | |
| } | |
| void CXF_FLT_OMPDlg::DoDataExchange(CDataExchange* pDX) | |
| { | |
| CDialogEx::DoDataExchange(pDX); | |
| DDX_Text(pDX, IDC_EDIT1, m_Flt); | |
| DDX_Text(pDX, IDC_EDIT2, m_Offsets); | |
| DDX_Text(pDX, IDC_EDIT3, m_Path); | |
| DDX_Text(pDX, IDC_EDIT4, m_Name); | |
| DDX_Control(pDX, IDC_COMMONDIALOG1, m_CCommondialog1); | |
| DDX_Control(pDX, IDC_COMMONDIALOG2, m_CCommondialog2); | |
| DDX_Control(pDX, IDC_PROGRESS1, m_CProgressCtrl1); | |
| DDX_Text(pDX, IDC_EDIT5, m_ThreadCount); | |
| } | |
| BEGIN_MESSAGE_MAP(CXF_FLT_OMPDlg, CDialogEx) | |
| ON_WM_SYSCOMMAND() | |
| ON_WM_PAINT() | |
| ON_WM_QUERYDRAGICON() | |
| ON_BN_CLICKED(IDOK, &CXF_FLT_OMPDlg::OnBnClickedOk) | |
| ON_BN_CLICKED(IDCANCEL, &CXF_FLT_OMPDlg::OnBnClickedCancel) | |
| ON_BN_CLICKED(IDC_BUTTON1, &CXF_FLT_OMPDlg::OnBnClickedButton1) | |
| ON_BN_CLICKED(IDC_BUTTON2, &CXF_FLT_OMPDlg::OnBnClickedButton2) | |
| ON_BN_CLICKED(IDC_BUTTON3, &CXF_FLT_OMPDlg::OnBnClickedButton3) | |
| ON_BN_CLICKED(IDC_BUTTON4, &CXF_FLT_OMPDlg::OnBnClickedButton4) | |
| ON_WM_TIMER() | |
| END_MESSAGE_MAP() | |
| // CXF_FLT_OMPDlg 消息处理程序 | |
| BOOL CXF_FLT_OMPDlg::OnInitDialog() | |
| { | |
| CDialogEx::OnInitDialog(); | |
| // 将“关于...”菜单项添加到系统菜单中。 | |
| // IDM_ABOUTBOX 必须在系统命令范围内。 | |
| ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); | |
| ASSERT(IDM_ABOUTBOX < 0xF000); | |
| CMenu* pSysMenu = GetSystemMenu(FALSE); | |
| if (pSysMenu != NULL) | |
| { | |
| BOOL bNameValid; | |
| CString strAboutMenu; | |
| bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); | |
| ASSERT(bNameValid); | |
| if (!strAboutMenu.IsEmpty()) | |
| { | |
| pSysMenu->AppendMenu(MF_SEPARATOR); | |
| pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); | |
| } | |
| } | |
| // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动 | |
| // 执行此操作 | |
| SetIcon(m_hIcon, TRUE); // 设置大图标 | |
| SetIcon(m_hIcon, FALSE); // 设置小图标 | |
| // TODO: 在此添加额外的初始化代码 | |
| return TRUE; // 除非将焦点设置到控件,否则返回 TRUE | |
| } | |
| void CXF_FLT_OMPDlg::OnSysCommand(UINT nID, LPARAM lParam) | |
| { | |
| if ((nID & 0xFFF0) == IDM_ABOUTBOX) | |
| { | |
| CAboutDlg dlgAbout; | |
| dlgAbout.DoModal(); | |
| } | |
| else | |
| { | |
| CDialogEx::OnSysCommand(nID, lParam); | |
| } | |
| } | |
| // 如果向对话框添加最小化按钮,则需要下面的代码 | |
| // 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序, | |
| // 这将由框架自动完成。 | |
| void CXF_FLT_OMPDlg::OnPaint() | |
| { | |
| if (IsIconic()) | |
| { | |
| CPaintDC dc(this); // 用于绘制的设备上下文 | |
| SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); | |
| // 使图标在工作区矩形中居中 | |
| int cxIcon = GetSystemMetrics(SM_CXICON); | |
| int cyIcon = GetSystemMetrics(SM_CYICON); | |
| CRect rect; | |
| GetClientRect(&rect); | |
| int x = (rect.Width() - cxIcon + 1) / 2; | |
| int y = (rect.Height() - cyIcon + 1) / 2; | |
| // 绘制图标 | |
| dc.DrawIcon(x, y, m_hIcon); | |
| } | |
| else | |
| { | |
| CDialogEx::OnPaint(); | |
| } | |
| } | |
| //当用户拖动最小化窗口时系统调用此函数取得光标 | |
| //显示。 | |
| HCURSOR CXF_FLT_OMPDlg::OnQueryDragIcon() | |
| { | |
| return static_cast<HCURSOR>(m_hIcon); | |
| } | |
| void CXF_FLT_OMPDlg::OnBnClickedOk() | |
| { | |
| // TODO: 在此添加控件通知处理程序代码 | |
| CDialogEx::OnOK(); | |
| } | |
| void CXF_FLT_OMPDlg::OnBnClickedCancel() | |
| { | |
| // TODO: 在此添加控件通知处理程序代码 | |
| CDialogEx::OnCancel(); | |
| } | |
| void CXF_FLT_OMPDlg::OnBnClickedButton1() | |
| { | |
| // TODO: 在此添加控件通知处理程序代码 | |
| m_CCommondialog1.put_DialogTitle(CComBSTR("打开FLT")); | |
| m_CCommondialog1.put_Filter(CComBSTR("FLT文件(*.flt)|*.flt")); | |
| m_CCommondialog1.put_InitDir(_T("FLT\\")); | |
| m_CCommondialog1.ShowOpen(); | |
| CComBSTR bstrFilePath; | |
| bstrFilePath = m_CCommondialog1.get_FileName(); | |
| if (SysStringLen(bstrFilePath) == 0) | |
| { | |
| MessageBox(_T("不是有效的flt文件")); | |
| return; | |
| } | |
| GetDlgItem(IDC_EDIT1)->SetWindowText(bstrFilePath); | |
| } | |
| // 读offsets文件 | |
| void CXF_FLT_OMPDlg::OnBnClickedButton2() | |
| { | |
| // TODO: 在此添加控件通知处理程序代码 | |
| m_CCommondialog2.put_DialogTitle(CComBSTR("打开offsets")); | |
| m_CCommondialog2.put_Filter(CComBSTR("offsets文件(*.dat)|*.dat")); | |
| m_CCommondialog2.put_InitDir(_T("FLT\\")); | |
| m_CCommondialog2.ShowOpen(); | |
| CComBSTR bstrFilePath; | |
| bstrFilePath = m_CCommondialog2.get_FileName(); | |
| if (SysStringLen(bstrFilePath) == 0) | |
| { | |
| MessageBox(_T("不是有效的offsets文件")); | |
| return; | |
| } | |
| GetDlgItem(IDC_EDIT2)->SetWindowText(bstrFilePath); | |
| } | |
| void CXF_FLT_OMPDlg::OnBnClickedButton3() | |
| { | |
| // TODO: 在此添加控件通知处理程序代码 | |
| LPITEMIDLIST pidlPath; | |
| TCHAR pszDplName[MAX_PATH]; | |
| BROWSEINFO biFile; | |
| IMalloc *pDllMlc; | |
| biFile.hwndOwner = m_hWnd; | |
| biFile.pidlRoot = NULL; | |
| biFile.pszDisplayName = NULL; | |
| biFile.lpszTitle = _T("请选择要打开的文件夹:"); | |
| biFile.ulFlags = BIF_RETURNFSANCESTORS; | |
| biFile.lpfn = NULL; | |
| biFile.lParam = NULL; | |
| biFile.iImage = 0; | |
| if(SUCCEEDED(SHGetMalloc(&pDllMlc))) | |
| { | |
| pidlPath=SHBrowseForFolder(&biFile); | |
| if(pidlPath != NULL) | |
| { | |
| SHGetPathFromIDList(pidlPath,pszDplName); //pszDplName:文件的路径地址 | |
| // this->MessageBox(pszDplName); //显示获取的地址 | |
| // GetDlgItem(IDC_EDIT6)->SetWindowText(pszDplName); | |
| GetDlgItem(IDC_EDIT3)->SetWindowText(pszDplName); | |
| } | |
| else | |
| return; | |
| pDllMlc->Free(NULL); | |
| pDllMlc->Release(); | |
| } | |
| } | |
| CString CXF_FLT_OMPDlg::ReNewAddress(CString str) | |
| { | |
| CString str1 = str; | |
| for (int i = 0; i < str1.GetLength(); i++) | |
| { | |
| int unicode = (int)str1.GetAt(i); | |
| if (unicode == 92) | |
| { | |
| str1.Insert(i,_T("\\")); | |
| i++; | |
| } | |
| } | |
| return str1; | |
| } | |
| void CXF_FLT_OMPDlg::DeleteCh(char* ch1, int ch1count, int delCount, int pos) | |
| { | |
| for (int i = pos; i<ch1count-delCount; i++) | |
| { | |
| ch1[i] = ch1[i + delCount]; | |
| } | |
| } | |
| void CXF_FLT_OMPDlg::InesrtCh(char* ch1, int ch1count, char* ch2, int insCount, int pos) | |
| { | |
| for (int i = ch1count; i>=pos; i-- ) | |
| { | |
| ch1[i+insCount] = ch1[i]; | |
| } | |
| for (int i = pos,k = 0; k<insCount;i++,k++) | |
| { | |
| ch1[i] = ch2[k]; | |
| } | |
| } | |
| void CXF_FLT_OMPDlg::CreateHdr() | |
| { | |
| CFile file_1(_T(""+s_Hdr2+""),CFile::modeCreate); | |
| file_1.Close(); | |
| fstream file1(s_Hdr); | |
| char ch_box[1000]=""; | |
| int countbox=0; | |
| char ch; | |
| while(file1.get(ch)) | |
| { | |
| ch_box[countbox]=ch; | |
| // cout.put(ch); | |
| countbox++; | |
| } | |
| file1.close(); | |
| //修改ch_box 第一行 ncols | |
| //删除原ncols | |
| int countbox1 = 0, position1 = 0; | |
| for (int j=0; j<countbox; j++) | |
| { | |
| if (ch_box[j]==32) | |
| { | |
| for (int k=j;k<countbox;k++) | |
| { | |
| if (ch_box[k]<=57 && ch_box[k]>=48) | |
| { | |
| position1 = k; | |
| break; | |
| } | |
| } | |
| for (int k=j;;k++) | |
| { | |
| if (ch_box[k]==10) | |
| { | |
| countbox1 = k - position1; | |
| break; | |
| } | |
| } | |
| break; | |
| } | |
| } | |
| DeleteCh(ch_box,countbox,countbox1,position1); | |
| countbox = countbox - countbox1; | |
| //添加新ncols | |
| char *buffer=new char[30]; | |
| sprintf(buffer,"%d ",Rw); | |
| int insertCount=0; | |
| for (int i = 0; buffer[i]<=57 && buffer[i]>=48;i++ ) | |
| { | |
| insertCount = i + 1; | |
| } | |
| InesrtCh(ch_box,countbox,buffer,insertCount,position1); | |
| countbox = countbox + insertCount; | |
| //修改ch_box 第2行 nrows | |
| //删除原nrows | |
| int count10 = 0; | |
| int start=0; | |
| for (int j=0; j<countbox; j++) | |
| { | |
| if (ch_box[j]==10) | |
| { | |
| start = j; | |
| break; | |
| } | |
| } | |
| for (int j=start; j<countbox; j++) | |
| { | |
| if (ch_box[j]==32) | |
| { | |
| for (int k=j;k<countbox;k++) | |
| { | |
| if (ch_box[k]<=57 && ch_box[k]>=48) | |
| { | |
| position1 = k; | |
| break; | |
| } | |
| } | |
| for (int k=j;;k++) | |
| { | |
| if (ch_box[k]==10) | |
| { | |
| countbox1 = k - position1; | |
| break; | |
| } | |
| } | |
| break; | |
| } | |
| } | |
| DeleteCh(ch_box,countbox,countbox1,position1); | |
| countbox = countbox - countbox1; | |
| //添加新nrows | |
| sprintf(buffer,"%d ",Rh); | |
| for (int i = 0; buffer[i]<=57 && buffer[i]>=48;i++ ) | |
| { | |
| insertCount = i + 1; | |
| } | |
| InesrtCh(ch_box,countbox,buffer,insertCount,position1); | |
| countbox = countbox + insertCount; | |
| //修改ch_box 第3行 x | |
| //删除原x | |
| count10=0; | |
| for (int j=0; j<countbox; j++) | |
| { | |
| if (ch_box[j]==10) | |
| { | |
| count10++; | |
| if (count10 == 2) | |
| { | |
| start = j; | |
| break; | |
| } | |
| } | |
| } | |
| for (int j=start; j<countbox; j++) | |
| { | |
| if (ch_box[j]==32) | |
| { | |
| for (int k=j;k<countbox;k++) | |
| { | |
| if (ch_box[k]<=57 && ch_box[k]>=48) | |
| { | |
| position1 = k; | |
| break; | |
| } | |
| } | |
| for (int k=j;;k++) | |
| { | |
| if (ch_box[k]==10) | |
| { | |
| countbox1 = k - position1; | |
| break; | |
| } | |
| } | |
| break; | |
| } | |
| } | |
| DeleteCh(ch_box,countbox,countbox1,position1); | |
| countbox = countbox - countbox1; | |
| //添加新x | |
| double dRx; | |
| dRx = Rx + m_Xshift - m_RXoffset; | |
| sprintf(buffer,"%lf ",dRx); | |
| for (int i = 0; buffer[i]<=57 && buffer[i]>=48 || buffer[i]==45;i++ ) | |
| { | |
| insertCount = i + 6; | |
| } | |
| InesrtCh(ch_box,countbox,buffer,insertCount,position1); | |
| countbox = countbox + insertCount; | |
| //修改ch_box 第4行 y | |
| //删除原y | |
| count10=0; | |
| for (int j=0; j<countbox; j++) | |
| { | |
| if (ch_box[j]==10) | |
| { | |
| count10++; | |
| if (count10 == 3) | |
| { | |
| start = j; | |
| break; | |
| } | |
| } | |
| } | |
| for (int j=start; j<countbox; j++) | |
| { | |
| if (ch_box[j]==32) | |
| { | |
| for (int k=j;k<countbox;k++) | |
| { | |
| if (ch_box[k]<=57 && ch_box[k]>=48) | |
| { | |
| position1 = k; | |
| break; | |
| } | |
| } | |
| for (int k=j;k<countbox;k++) | |
| { | |
| if (ch_box[k]==10) | |
| { | |
| countbox1 = k - position1; | |
| break; | |
| } | |
| } | |
| break; | |
| } | |
| } | |
| DeleteCh(ch_box,countbox,countbox1,position1); | |
| countbox = countbox - countbox1; | |
| //添加新y | |
| double dRy; | |
| dRy = Ry - m_RYoffset; | |
| // double dRy = Ry; | |
| sprintf(buffer,"%f ",dRy); | |
| for (int i = 0; buffer[i]<=57 && buffer[i]>=48 || buffer[i]==45;i++ ) | |
| { | |
| insertCount = i + 6; | |
| } | |
| InesrtCh(ch_box,countbox,buffer,insertCount,position1); | |
| countbox = countbox + insertCount; | |
| //修改ch_box 第5行 cell | |
| //删除原cell | |
| count10=0; | |
| for (int j=0; j<countbox; j++) | |
| { | |
| if (ch_box[j]==10) | |
| { | |
| count10++; | |
| if (count10 == 4) | |
| { | |
| start = j; | |
| break; | |
| } | |
| } | |
| } | |
| for (int j=start; j<countbox; j++) | |
| { | |
| if (ch_box[j]==32) | |
| { | |
| for (int k=j;k<countbox;k++) | |
| { | |
| if (ch_box[k]<=57 && ch_box[k]>=48) | |
| { | |
| position1 = k; | |
| break; | |
| } | |
| } | |
| for (int k=j;k<countbox;k++) | |
| { | |
| if (ch_box[k]==10) | |
| { | |
| countbox1 = k - position1; | |
| break; | |
| } | |
| } | |
| break; | |
| } | |
| } | |
| DeleteCh(ch_box,countbox,countbox1,position1); | |
| countbox = countbox - countbox1; | |
| //添加新cell | |
| sprintf(buffer,"%f ",Rcell); | |
| for (int i = 0; buffer[i]<=57 && buffer[i]>=48;i++ ) | |
| { | |
| insertCount = i + 6; | |
| } | |
| InesrtCh(ch_box,countbox,buffer,insertCount,position1); | |
| countbox = countbox + insertCount; | |
| fstream file5(s_Hdr2); | |
| file5.write(ch_box,countbox); | |
| file5.close(); | |
| } | |
| bool CXF_FLT_OMPDlg::CreateFlt() | |
| { | |
| UpdateData(); | |
| s_Flt = ReNewAddress(m_Flt); | |
| s_Hdr = s_Flt; | |
| s_Hdr.Delete(s_Hdr.GetLength()-3,3); | |
| s_Hdr.Insert(s_Hdr.GetLength(),_T("hdr")); | |
| s_Flt2 = ReNewAddress(m_Path); | |
| if (m_Name == _T("")) | |
| { | |
| MessageBox(_T("未输入新文件名")); | |
| return 0; | |
| } | |
| s_Flt2.Insert(s_Flt2.GetLength(),_T("\\\\")); | |
| s_Flt2.Insert(s_Flt2.GetLength(),_T(""+m_Name+"")); | |
| s_Hdr2 = s_Flt2; | |
| s_Flt2.Insert(s_Flt2.GetLength(),_T(".flt")); | |
| s_Hdr2.Insert(s_Hdr2.GetLength(),_T(".hdr")); | |
| //读取HDR信息 | |
| FILE* fp = _wfopen(s_Hdr,L"rt"); | |
| if (fp==NULL) | |
| { | |
| MessageBox(_T("错误的FLT文件!")); | |
| return 0; | |
| } | |
| char buf[_MAX_PATH]; | |
| fscanf(fp,"%s %d",buf,&w); | |
| fscanf(fp,"%s %d",buf,&h); | |
| fscanf(fp,"%s %lf",buf,&x); | |
| fscanf(fp,"%s %lf",buf,&y); | |
| fscanf(fp,"%s %lf",buf,&cell); | |
| fclose(fp); | |
| // x -= m_Xoffset; | |
| // y -= m_Yoffset; | |
| //计算原矩阵 顶点坐标 | |
| point Vertex[4]; | |
| for (int i=0; i<2; i++) | |
| { | |
| for (int j=0; j<2; j++) | |
| { | |
| Vertex[i*2+j].x = x + (w-1) * cell *j; | |
| Vertex[i*2+j].y = y + (h-1) * cell *i; | |
| } | |
| } | |
| //计算变换后矩阵 顶点坐标 | |
| point RVertex[4]; | |
| for (int i=0; i<2; i++) | |
| { | |
| for (int j=0; j<2; j++) | |
| { | |
| //RVertex[i*2+j].x =Vertex[i*2+j].x*cos(m_Rotate/180*PI)-Vertex[i*2+j].y*sin(m_Rotate/180*PI) + m_Xoffset; | |
| //RVertex[i*2+j].y =Vertex[i*2+j].x*sin(m_Rotate/180*PI)+Vertex[i*2+j].y*cos(m_Rotate/180*PI) + m_Yoffset; | |
| RVertex[i*2+j].x =Vertex[i*2+j].x*cos(-m_Rotate/180*PI)-Vertex[i*2+j].y*sin(-m_Rotate/180*PI); | |
| RVertex[i*2+j].y =Vertex[i*2+j].x*sin(-m_Rotate/180*PI)+Vertex[i*2+j].y*cos(-m_Rotate/180*PI); | |
| } | |
| } | |
| //计算变换后 Rw,Rh Rx,Ry Rcell | |
| Rcell = (abs(cos(-m_Rotate/180*PI)) + abs(sin(-m_Rotate/180*PI))) * cell; | |
| float xmin = RVertex[1].x,ymin = RVertex[1].y; | |
| float xmax = RVertex[1].x,ymax = RVertex[1].y; | |
| for (int i=0; i<2; i++) | |
| { | |
| for (int j=0; j<2; j++) | |
| { | |
| if (RVertex[i*2+j].x< xmin) | |
| { | |
| xmin = RVertex[i*2+j].x; | |
| } | |
| if (RVertex[i*2+j].y<ymin) | |
| { | |
| ymin = RVertex[i*2+j].y; | |
| } | |
| if (RVertex[i*2+j].x> xmax) | |
| { | |
| xmax = RVertex[i*2+j].x; | |
| } | |
| if (RVertex[i*2+j].y>ymax) | |
| { | |
| ymax = RVertex[i*2+j].y; | |
| } | |
| } | |
| } | |
| Rw = (xmax - xmin) / Rcell + 1; | |
| Rh = (ymax - ymin) / Rcell + 1; | |
| Rx = xmin; | |
| Ry = ymin; | |
| CreateHdr(); | |
| // //重新计算 简化坐标 令 X = Y = 0 | |
| // x = y =0; | |
| // for (int i=0; i<2; i++) | |
| // { | |
| // for (int j=0; j<2; j++) | |
| // { | |
| // Vertex[i*2+j].x = x + (w-1) * cell *j; | |
| // Vertex[i*2+j].y = y + (h-1) * cell *i; | |
| // } | |
| // } | |
| // | |
| // //计算变换后矩阵 顶点坐标 | |
| // for (int i=0; i<2; i++) | |
| // { | |
| // for (int j=0; j<2; j++) | |
| // { | |
| // RVertex[i*2+j].x =Vertex[i*2+j].x*cos(-m_Rotate/180*PI)-Vertex[i*2+j].y*sin(-m_Rotate/180*PI); | |
| // RVertex[i*2+j].y =Vertex[i*2+j].x*sin(-m_Rotate/180*PI)+Vertex[i*2+j].y*cos(-m_Rotate/180*PI); | |
| // } | |
| // } | |
| // | |
| // //计算变换后 | |
| // for (int i=0; i<2; i++) | |
| // { | |
| // for (int j=0; j<2; j++) | |
| // { | |
| // if (RVertex[i*2+j].x< xmin) | |
| // { | |
| // xmin = RVertex[i*2+j].x; | |
| // } | |
| // if (RVertex[i*2+j].y<ymin) | |
| // { | |
| // ymin = RVertex[i*2+j].y; | |
| // } | |
| // if (RVertex[i*2+j].x> xmax) | |
| // { | |
| // xmax = RVertex[i*2+j].x; | |
| // } | |
| // if (RVertex[i*2+j].y>ymax) | |
| // { | |
| // ymax = RVertex[i*2+j].y; | |
| // } | |
| // } | |
| // } | |
| // Rx = xmin; | |
| // Ry = ymin; | |
| CFile file_2(_T(""+s_Flt2+""),CFile::modeCreate); | |
| file_2.Close(); | |
| fp2 = _wfopen(s_Flt2,L"wb"); | |
| if (fp2 == NULL) | |
| { | |
| MessageBox(_T("未输入新文件路径或名字")); | |
| return 0; | |
| } | |
| float* z = new float[Rw]; | |
| for (int i = 0; i < Rw ; i++) | |
| { | |
| z[i] = -9999; | |
| } | |
| for (int i = 0; i < Rh ; i++) | |
| { | |
| fwrite(z,1,sizeof(float)*Rw,fp2); | |
| } | |
| fclose(fp2); | |
| // MessageBox(_T("OK")); | |
| return 1; | |
| } | |
| //开始 | |
| void CXF_FLT_OMPDlg::OnBnClickedButton4() | |
| { | |
| // TODO: 在此添加控件通知处理程序代码 | |
| UpdateData(); | |
| ThreadCount = m_ThreadCount; | |
| if (m_ThreadCount<1 || m_ThreadCount>40) | |
| { | |
| MessageBox(_T("线程输入错误,请输入1--40的整数!")); | |
| return; | |
| } | |
| //return; | |
| s_Offsets = ReNewAddress(m_Offsets); | |
| FILE* fp = _wfopen(s_Offsets, L"rt"); | |
| if (fp == NULL) | |
| { | |
| MessageBox(_T("错误的Offsets文件!")); | |
| return; | |
| } | |
| char buf[_MAX_PATH]; | |
| fscanf(fp,"%s",buf); | |
| fscanf(fp,"%s %lf",buf,&m_Xoffset); | |
| fscanf(fp,"%s %lf",buf,&m_Yoffset); | |
| fscanf(fp,"%s %lf",buf,&m_RXoffset); | |
| fscanf(fp,"%s %lf",buf,&m_RYoffset); | |
| fscanf(fp,"%s %lf",buf,&m_Xshift); | |
| fscanf(fp,"%s %lf",buf,&m_Rotate); | |
| fclose(fp); | |
| if (m_Rotate==0 || int(m_Rotate)%45 == 0 && m_Rotate == int(m_Rotate)) | |
| { | |
| Is45n = true; | |
| } | |
| else Is45n = false; | |
| //return ; | |
| if (!CreateFlt()) | |
| { | |
| return; | |
| } | |
| GetDlgItem(IDC_BUTTON4)->EnableWindow(FALSE); | |
| UpdateData(); | |
| ThreadCount = m_ThreadCount; | |
| Bw1 = Rw; | |
| Bh1 = Rh / ThreadCount; | |
| // Bh1 = Bh1; | |
| // Bw2 = Rw - Bw1*k; | |
| Progress1 = 100 / ThreadCount; | |
| Progress2 = 100 - Progress1 * ThreadCount; | |
| Bh2 = Rh - Bh1*ThreadCount; | |
| if (Bh2 == 0) | |
| { | |
| if (Progress2!=0) | |
| { | |
| m_CProgressCtrl1.SetPos(Progress2); | |
| } | |
| else | |
| { | |
| m_CProgressCtrl1.SetPos(0); | |
| } | |
| iFinishThread = 1; | |
| } | |
| else | |
| { | |
| iFinishThread = 0; | |
| m_CProgressCtrl1.SetPos(0); | |
| } | |
| for (int i = 0; i <= iPro; i++) | |
| { | |
| ProCount[i] = 0; | |
| } | |
| int i = 1; | |
| CWinThread *pWrite1 = AfxBeginThread(Write1,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| CWinThread *pWriteLast= AfxBeginThread(WriteLast,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite2 = AfxBeginThread(Write2,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite3 = AfxBeginThread(Write3,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite4 = AfxBeginThread(Write4,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite5 = AfxBeginThread(Write5,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite6 = AfxBeginThread(Write6,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite7 = AfxBeginThread(Write7,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite8 = AfxBeginThread(Write8,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite9 = AfxBeginThread(Write9,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite10 = AfxBeginThread(Write10,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite11 = AfxBeginThread(Write11,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite12 = AfxBeginThread(Write12,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite13 = AfxBeginThread(Write13,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite14 = AfxBeginThread(Write14,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite15 = AfxBeginThread(Write15,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite16 = AfxBeginThread(Write16,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite17 = AfxBeginThread(Write17,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite18 = AfxBeginThread(Write18,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite19 = AfxBeginThread(Write19,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite20 = AfxBeginThread(Write20,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite21 = AfxBeginThread(Write21,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite22 = AfxBeginThread(Write22,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite23 = AfxBeginThread(Write23,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite24 = AfxBeginThread(Write24,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite25 = AfxBeginThread(Write25,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite26 = AfxBeginThread(Write26,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite27 = AfxBeginThread(Write27,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite28 = AfxBeginThread(Write28,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite29 = AfxBeginThread(Write29,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite30 = AfxBeginThread(Write30,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite31 = AfxBeginThread(Write31,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite32 = AfxBeginThread(Write32,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite33 = AfxBeginThread(Write33,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite34 = AfxBeginThread(Write34,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite35 = AfxBeginThread(Write35,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite36 = AfxBeginThread(Write36,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite37 = AfxBeginThread(Write37,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite38 = AfxBeginThread(Write38,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite39 = AfxBeginThread(Write39,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| if (i == ThreadCount) return; i++; | |
| CWinThread *pWrite40 = AfxBeginThread(Write40,&m_CProgressCtrl1,THREAD_PRIORITY_NORMAL, 0, NULL); | |
| } | |
| UINT Write1(LPVOID lpParam) | |
| { | |
| int iThread = 1; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write2(LPVOID lpParam) | |
| { | |
| int iThread = 2; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write3(LPVOID lpParam) | |
| { | |
| int iThread = 3; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write4(LPVOID lpParam) | |
| { | |
| int iThread = 4; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write5(LPVOID lpParam) | |
| { | |
| int iThread = 5; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write6(LPVOID lpParam) | |
| { | |
| int iThread = 6; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write7(LPVOID lpParam) | |
| { | |
| int iThread = 7; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write8(LPVOID lpParam) | |
| { | |
| int iThread = 8; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write9(LPVOID lpParam) | |
| { | |
| int iThread = 9; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write10(LPVOID lpParam) | |
| { | |
| int iThread = 10; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write11(LPVOID lpParam) | |
| { | |
| int iThread = 11; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write12(LPVOID lpParam) | |
| { | |
| int iThread = 12; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write13(LPVOID lpParam) | |
| { | |
| int iThread = 13; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write14(LPVOID lpParam) | |
| { | |
| int iThread = 14; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write15(LPVOID lpParam) | |
| { | |
| int iThread = 15; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write16(LPVOID lpParam) | |
| { | |
| int iThread = 16; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write17(LPVOID lpParam) | |
| { | |
| int iThread = 17; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write18(LPVOID lpParam) | |
| { | |
| int iThread = 18; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write19(LPVOID lpParam) | |
| { | |
| int iThread = 19; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write20(LPVOID lpParam) | |
| { | |
| int iThread = 20; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write21(LPVOID lpParam) | |
| { | |
| int iThread = 21; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write22(LPVOID lpParam) | |
| { | |
| int iThread = 22; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write23(LPVOID lpParam) | |
| { | |
| int iThread = 23; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write24(LPVOID lpParam) | |
| { | |
| int iThread = 24; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write25(LPVOID lpParam) | |
| { | |
| int iThread = 25; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write26(LPVOID lpParam) | |
| { | |
| int iThread = 26; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write27(LPVOID lpParam) | |
| { | |
| int iThread = 27; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write28(LPVOID lpParam) | |
| { | |
| int iThread = 28; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write29(LPVOID lpParam) | |
| { | |
| int iThread = 29; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write30(LPVOID lpParam) | |
| { | |
| int iThread = 30; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write31(LPVOID lpParam) | |
| { | |
| int iThread = 31; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write32(LPVOID lpParam) | |
| { | |
| int iThread = 32; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write33(LPVOID lpParam) | |
| { | |
| int iThread = 33; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write34(LPVOID lpParam) | |
| { | |
| int iThread = 34; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write35(LPVOID lpParam) | |
| { | |
| int iThread = 35; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write36(LPVOID lpParam) | |
| { | |
| int iThread = 36; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write37(LPVOID lpParam) | |
| { | |
| int iThread = 37; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write38(LPVOID lpParam) | |
| { | |
| int iThread = 38; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write39(LPVOID lpParam) | |
| { | |
| int iThread = 39; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT Write40(LPVOID lpParam) | |
| { | |
| int iThread = 40; | |
| if (iThread > ThreadCount) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; //对应源数据 左下角零点的位置 | |
| int numX, numY; //对应源数据 左下角零点的位置 | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; //进度条 | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh1 -1 ; row >= 0 ; row--) | |
| { | |
| yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| offX += xplus; | |
| offY += yplus; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*((Bh1 * iThread - row -1)*Rw),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress1 * (Bh1 - row) / Bh1 > ProCount[iThread]) | |
| { | |
| ProCount[iThread] = Progress1 * (Bh1 - row) / Bh1; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| delete z2; | |
| delete Fxy; | |
| delete z; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| UINT WriteLast(LPVOID lpParam) | |
| { | |
| if (Bh2 == 0) return 0; | |
| FILE* fp0 = _wfopen(s_Flt,L"rb"); | |
| float* z = new float[1]; | |
| double xformer, yformer, yafter;//, xafter; //变换前后坐标 | |
| double offX, offY; | |
| int numX, numY; | |
| double Bili_X,Bili_Y; //相对位置 0-1 | |
| float* Fxy = new float[4]; | |
| float* z2 = new float[Bw1]; | |
| CProgressCtrl* CPC = (CProgressCtrl*)lpParam; | |
| double cosR = cos(-m_Rotate/180*PI); | |
| double sinR = sin(-m_Rotate/180*PI); | |
| double xplus = Rcell * cosR / cell; | |
| double yplus = Rcell * (-sinR) / cell; | |
| for (int row = Bh2 -1 ; row >= 0 ; row--) | |
| { | |
| // yafter = Ry + (row + Rh - Bh1*iThread) * Rcell; | |
| yafter = Ry + row * Rcell; | |
| xformer = cosR * (Rx) + sinR * (yafter); | |
| yformer = -sinR * (Rx) + cosR * (yafter); | |
| offX = (xformer - x) / cell -xplus; | |
| offY = (yformer - y) / cell -yplus; | |
| for (int col = 0; col < Bw1 ; col++) | |
| { | |
| // xafter = Rx + col * Rcell; | |
| // xformer = cos(-m_Rotate/180.0*PI) * (xafter) + sin(-m_Rotate/180.0*PI) * (yafter); | |
| // yformer = -sin(-m_Rotate/180.0*PI) * (xafter) + cos(-m_Rotate/180.0*PI) * (yafter); | |
| // | |
| // offX = (xformer - x) / cell; | |
| // offY = (yformer - y) / cell; | |
| offX += xplus; | |
| offY += yplus; | |
| //numX = numY =0; | |
| if ( offX >=0 && offX <= w-1 && offY>=0 && offY<=h-1) | |
| { | |
| if (Is45n) | |
| { | |
| numX = (int)(offX+0.5); | |
| numY = (int)(offY+0.5); | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(z,1,sizeof(float),fp0); | |
| z2[col] = z[0]; | |
| } | |
| else | |
| { | |
| numX = (int)offX; | |
| numY = (int)offY; | |
| Bili_X = offX - numX; | |
| Bili_Y = offY - numY; | |
| if (Bili_X == 0 && Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| z2[col] = Fxy[0]; | |
| continue; | |
| } | |
| if (Bili_X == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*1,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*1,fp0); | |
| Fxy[1]=Fxy[3]=0; | |
| } | |
| else if (Bili_Y == 0) | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| Fxy[2]=Fxy[3]=0; | |
| } | |
| else | |
| { | |
| fseek(fp0,sizeof(float)*((h - numY -1) * w + numX),SEEK_SET); | |
| fread(Fxy,1,sizeof(float)*2,fp0); | |
| fseek(fp0,sizeof(float)*((h - numY -1 - 1) * w + numX),SEEK_SET); | |
| fread(Fxy+2,1,sizeof(float)*2,fp0); | |
| } | |
| if (Fxy[0]!=-9999 && Fxy[1]!=-9999 && Fxy[2]!=-9999 &&Fxy[3]!=-9999) | |
| { | |
| z2[col] = Fxy[0] * (1 - Bili_X) *(1 - Bili_Y) | |
| + Fxy[1] * (Bili_X) *(1 - Bili_Y) | |
| + Fxy[2] * (1 - Bili_X) *(Bili_Y) | |
| + Fxy[3] * (Bili_X) *(Bili_Y); | |
| } | |
| else z2[col] = -9999; | |
| } | |
| } | |
| else | |
| { | |
| z2[col] = -9999; | |
| } | |
| } | |
| critical_section.Lock(); | |
| fp2 = _wfopen(s_Flt2,L"rb+"); | |
| fseek(fp2,sizeof(float)*(((Rh - row -1)*Rw)),SEEK_SET); | |
| fwrite(z2,sizeof(float),Bw1,fp2); | |
| fclose(fp2); | |
| critical_section.Unlock(); | |
| if (Progress2 * (Bh2 - row) / Bh2 > ProCount[0]) | |
| { | |
| if (Bh2 == 1) | |
| { | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp += Progress2; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| else if (Progress2>Bh2) | |
| { | |
| int p = Progress2 / (Bh2 -1); | |
| int q = Progress2 - p * (Bh2-1); | |
| ProCount[0]++; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| if (q == 0) | |
| { | |
| nTemp += p; | |
| } | |
| else | |
| { | |
| if (ProCount[0] != Bh2) | |
| { | |
| nTemp += p; | |
| } | |
| else nTemp += q; | |
| } | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| else{ | |
| ProCount[0] = Progress2 * (Bh2 - row) / Bh2; | |
| critical_section_progress.Lock(); | |
| int nTemp = CPC->GetPos(); | |
| nTemp++; | |
| CPC->SetPos(nTemp); | |
| critical_section_progress.Unlock(); | |
| } | |
| } | |
| // int nTemp = 100 * (Bh1 - row) / Bh1 ; | |
| // CPC->SetPos(nTemp); | |
| } | |
| delete z; | |
| delete Fxy; | |
| delete z2; | |
| fclose(fp0); | |
| critical_section_finish.Lock(); | |
| iFinishThread++; | |
| if (iFinishThread == ( ThreadCount +1 )) | |
| { | |
| CXF_FLT_OMPDlg *pMMM = (CXF_FLT_OMPDlg*)AfxGetMainWnd(); | |
| pMMM->SetTimer(1,300,NULL); | |
| } | |
| critical_section_finish.Unlock(); | |
| return 0; | |
| } | |
| void CXF_FLT_OMPDlg::OnTimer(UINT_PTR nIDEvent) | |
| { | |
| // TODO: 在此添加消息处理程序代码和/或调用默认值 | |
| if (nIDEvent == 1) | |
| { | |
| KillTimer(1); | |
| GetDlgItem(IDC_BUTTON4)->EnableWindow(TRUE); | |
| MessageBox(_T("完成")); | |
| } | |
| CDialogEx::OnTimer(nIDEvent); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // XF_FLT_OMPDlg.h : 头文件 | |
| // | |
| #pragma once | |
| #include "commondialog1.h" | |
| #include "afxcmn.h" | |
| #define PI 3.14159265359 | |
| UINT Write1(LPVOID lpParam); | |
| UINT Write2(LPVOID lpParam); | |
| UINT Write3(LPVOID lpParam); | |
| UINT Write4(LPVOID lpParam); | |
| UINT Write5(LPVOID lpParam); | |
| UINT Write6(LPVOID lpParam); | |
| UINT Write7(LPVOID lpParam); | |
| UINT Write8(LPVOID lpParam); | |
| UINT Write9(LPVOID lpParam); | |
| UINT Write10(LPVOID lpParam); | |
| UINT Write11(LPVOID lpParam); | |
| UINT Write12(LPVOID lpParam); | |
| UINT Write13(LPVOID lpParam); | |
| UINT Write14(LPVOID lpParam); | |
| UINT Write15(LPVOID lpParam); | |
| UINT Write16(LPVOID lpParam); | |
| UINT Write17(LPVOID lpParam); | |
| UINT Write18(LPVOID lpParam); | |
| UINT Write19(LPVOID lpParam); | |
| UINT Write20(LPVOID lpParam); | |
| UINT Write21(LPVOID lpParam); | |
| UINT Write22(LPVOID lpParam); | |
| UINT Write23(LPVOID lpParam); | |
| UINT Write24(LPVOID lpParam); | |
| UINT Write25(LPVOID lpParam); | |
| UINT Write26(LPVOID lpParam); | |
| UINT Write27(LPVOID lpParam); | |
| UINT Write28(LPVOID lpParam); | |
| UINT Write29(LPVOID lpParam); | |
| UINT Write30(LPVOID lpParam); | |
| UINT Write31(LPVOID lpParam); | |
| UINT Write32(LPVOID lpParam); | |
| UINT Write33(LPVOID lpParam); | |
| UINT Write34(LPVOID lpParam); | |
| UINT Write35(LPVOID lpParam); | |
| UINT Write36(LPVOID lpParam); | |
| UINT Write37(LPVOID lpParam); | |
| UINT Write38(LPVOID lpParam); | |
| UINT Write39(LPVOID lpParam); | |
| UINT Write40(LPVOID lpParam); | |
| UINT WriteLast(LPVOID lpParam); | |
| // CXF_FLT_OMPDlg 对话框 | |
| class CXF_FLT_OMPDlg : public CDialogEx | |
| { | |
| // 构造 | |
| public: | |
| CXF_FLT_OMPDlg(CWnd* pParent = NULL); // 标准构造函数 | |
| // 对话框数据 | |
| enum { IDD = IDD_XF_FLT_OMP_DIALOG }; | |
| protected: | |
| virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 | |
| // 实现 | |
| protected: | |
| HICON m_hIcon; | |
| // 生成的消息映射函数 | |
| virtual BOOL OnInitDialog(); | |
| afx_msg void OnSysCommand(UINT nID, LPARAM lParam); | |
| afx_msg void OnPaint(); | |
| afx_msg HCURSOR OnQueryDragIcon(); | |
| DECLARE_MESSAGE_MAP() | |
| public: | |
| afx_msg void OnBnClickedOk(); | |
| afx_msg void OnBnClickedCancel(); | |
| CString m_Flt; | |
| CString m_Offsets; | |
| CString m_Path; | |
| CString m_Name; | |
| CCommondialog1 m_CCommondialog1; | |
| CCommondialog1 m_CCommondialog2; | |
| afx_msg void OnBnClickedButton1(); | |
| afx_msg void OnBnClickedButton2(); | |
| afx_msg void OnBnClickedButton3(); | |
| afx_msg void OnBnClickedButton4(); | |
| afx_msg CString ReNewAddress(CString str); | |
| afx_msg void DeleteCh(char* ch1, int ch1count, int delCount, int pos); | |
| afx_msg void InesrtCh(char* ch1, int ch1count, char* ch2, int insCount, int pos); | |
| afx_msg bool CreateFlt(); | |
| afx_msg void CreateHdr(); | |
| // int w, h; | |
| // double x, y; | |
| // double cell; | |
| // | |
| // int Rw, Rh; | |
| // double Rx, Ry; | |
| // double Rcell; | |
| // | |
| // int Bw1, Bh1, Bw2, Bh2; | |
| // | |
| // FILE* fp1; //源FLT | |
| // FILE* fp2; //目标FLT | |
| // CCriticalSection critical_section; | |
| // CString s_Flt2,s_Flt; | |
| // double m_Rotate; | |
| struct point | |
| { | |
| double x; | |
| double y; | |
| }; | |
| double m_Xshift, m_Xoffset, m_Yoffset,m_RXoffset,m_RYoffset; | |
| CString s_Hdr, s_Offsets, s_Hdr2; | |
| CProgressCtrl m_CProgressCtrl1; | |
| int m_ThreadCount; | |
| afx_msg void OnTimer(UINT_PTR nIDEvent); | |
| }; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment