📄 readdoc.cpp
字号:
// readDoc.cpp : implementation of the CReadDoc class
//
#include "stdafx.h"
#include "read.h"
#include "fstream.h"
#include <iostream.h>
#include "math.h"
#include "readDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CReadDoc
IMPLEMENT_DYNCREATE(CReadDoc, CDocument)
BEGIN_MESSAGE_MAP(CReadDoc, CDocument)
//{{AFX_MSG_MAP(CReadDoc)
ON_COMMAND(ID_HJ, OnHj)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CReadDoc construction/destruction
CReadDoc::CReadDoc()
{
// TODO: add one-time construction code here
}
CReadDoc::~CReadDoc()
{
}
BOOL CReadDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CReadDoc serialization
void CReadDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CReadDoc diagnostics
#ifdef _DEBUG
void CReadDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CReadDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CReadDoc commands
void CReadDoc::OnHj()
{
// TODO: Add your command handler code here
CFileDialog OpenDlg(TRUE,NULL,NULL,OFN_HIDEREADONLY,NULL,NULL);
if(OpenDlg.DoModal()!=IDOK)
return;
CString FilePathName="";
FilePathName=OpenDlg.GetPathName();
ifstream InFile;
InFile.open(FilePathName,ios::in);//ios::in打开文件进行读取操作
if(!InFile)
{
AfxMessageBox("打开文件失败,无法读入数据");
return;
}
AfxMessageBox("请输入存储数据路径");
CStdioFile *file; CFileDialog dlg(true); CString tmp=CString("");
if(dlg.DoModal()!=IDOK)
{ AfxMessageBox("存储文件打开失败1");return;}
if ((file=new CStdioFile(dlg.GetPathName(),CFile::modeCreate|CFile::modeWrite))==FALSE)
{ AfxMessageBox("存储文件打开失败");return;}
AfxMessageBox("请输入相对定向结果数据路径");
if(OpenDlg.DoModal()!=IDOK)
return;
FilePathName=OpenDlg.GetPathName();
ifstream file_xddx;
file_xddx.open(FilePathName,ios::in);//ios::in打开文件进行读取操作
if(!file_xddx)
{
AfxMessageBox("打开文件失败,无法读入数据");
return;
}
int N,N1,a;char c;
double Xs,Ys,Zs,fhi,omiga,kappa,Xs1,Ys1,Zs1,fhi1,omiga1,kappa1;
double x,y,z,t,b,k,Bx;
InFile>>a;file_xddx>>b;
InFile>>N1>>Xs1>>Ys1>>Zs1>>fhi1>>omiga1>>kappa1;
for (int i=0;i<a-1;i++)
{
InFile>>N>>Xs>>Ys>>Zs>>fhi>>omiga>>kappa;
x=Xs-Xs1;y=Ys-Ys1;z=Zs-Zs1;
//归一化
t=sqrt(x*x+y*y+z*z);
file_xddx>>b>>c>>b>>Bx>>b>>b>>b>>b>>b>>b>>b;
// x=x/t*k;y=y/t*k;z=z/t*k;
x=x/t;y=y/t;z=z/t;
k=1/x;
x=x*k*Bx;y=y*k*Bx;z=z*k*Bx;
tmp.Format("%2d-%2d %15lf %15lf %15lf %15lf %15lf %15lf\n",N1,N,x,y,z,fhi-fhi1,omiga-omiga1,kappa-kappa1);
file->WriteString(tmp);
N1=N;Xs1=Xs;Ys1=Ys;Zs1=Zs;fhi1=fhi;omiga1=omiga;kappa1=kappa;
}
file->Close();
InFile.close();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -