📄 复件 subdivdlg.cpp
字号:
// SubdivDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Subdiv.h"
#include "SubdivDlg.h"
/*
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <algorithm>
*/
#include <iostream>
#include "mesh.h"
using namespace std;
#include "Redirect_DebugWindow.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSubdivDlg dialog
CSubdivDlg::CSubdivDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSubdivDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSubdivDlg)
m_renderType = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
// pMesh = new Mesh();
m_blMeshReady = false;
m_nowMeshIdx = -1;
}
CSubdivDlg::~CSubdivDlg()
{
clearMeshHistory(0);
}
void CSubdivDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSubdivDlg)
DDX_Control(pDX, IDC_OPENGLACTIVEXCTRL1, m_opengl);
DDX_Radio(pDX, IDC_RADIO_RENDER_VERTEX, m_renderType);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSubdivDlg, CDialog)
//{{AFX_MSG_MAP(CSubdivDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_RADIO_RENDER_EDGE, OnRadioRenderEdge)
ON_BN_CLICKED(IDC_RADIO_RENDER_FACE, OnRadioRenderFace)
ON_BN_CLICKED(IDC_RADIO_RENDER_VERTEX, OnRadioRenderVertex)
ON_BN_CLICKED(IDC_BUTTON_DUMP, OnButtonDump)
ON_BN_CLICKED(IDC_BUTTON_CATMULL, OnButtonCatmull)
ON_BN_CLICKED(IDC_BUTTON_DOOSABIN, OnButtonDoosabin)
ON_BN_CLICKED(IDC_BUTTON_SAVEOBJ, OnButtonSaveobj)
ON_BN_CLICKED(IDC_BUTTON_QUIT, OnButtonQuit)
ON_BN_CLICKED(IDC_BUTTON_BACK, OnButtonBack)
ON_BN_CLICKED(IDC_BUTTON_FORWARD, OnButtonForward)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSubdivDlg message handlers
BOOL CSubdivDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
CButton *bb = (CButton *)GetDlgItem(IDC_BUTTON_FORWARD);
bb->EnableWindow(FALSE);
bb = (CButton *)GetDlgItem(IDC_BUTTON_BACK);
bb->EnableWindow(FALSE);
#ifdef _DEBUG
RedirectIOToConsole("Redirect Debug Window");
#endif
return TRUE; // return TRUE unless you set the focus to a control
}
void CSubdivDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CSubdivDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
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;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
// cout << "hello redirected world";
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CSubdivDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
//#include "Edge.h"
void CSubdivDlg::OnButton1()
{
CFileDialog fd(TRUE,".obj",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
"文件(*.obj)|*.obj|所有文件(*.*)|*.*||",NULL);
if (fd.DoModal() == IDCANCEL)
return;
Mesh *pMesh = new Mesh();;
if( pMesh->loadObjFile(fd.GetPathName()) )
{
m_meshs.push_back(pMesh);
m_nowMeshIdx = m_meshs.size() - 1;
m_blMeshReady = true;;
}
m_opengl.Invalidate();
// m_meshs.clear();
/*
CString strLine = "f 1 2 3 4 5";
int i1, i = 2, j;
while( i < strLine.GetLength() )
{
j = strLine.Find(' ',i);
if( j == -1) j = strLine.GetLength();
sscanf(strLine.Mid(i,j-i), "%d", &i1);
cout << i1 << endl;
i = j + 1;
}
*/
}
/*typedef pair<int,int> INTPAIR;
typedef set<Edge> EDGESET;
typedef EDGESET::iterator EDGEPOS;
vector<int>v1;
map<int, int> m1;
EDGESET s1;
// std::iostream f("c:\\aaa.txt", "w");
SYSTEMTIME st1,st2;
GetSystemTime(&st1 );
for(int i = 0; i < 10000; i ++ )
{
v1.push_back(i);
}
//ort ( v1.begin () , v1.end() );
for( i = 0; i < 10000; i ++ )
{
// sort ( v1.begin () , v1.end() );
// vector<int>::const_iterator itr = v1.begin();
vector<int>::const_iterator itr = lower_bound(v1.begin(), v1.end(), i);
}
GetSystemTime(&st2 );
for( i = 0; i < 10000; i ++ )
{
m1.insert(INTPAIR(i,i));
}
int interval1 = st2.wMilliseconds - st1.wMilliseconds;
for( i = 0; i < 10000; i ++ )
{
int a, b;
a = (* m1.find(i)).first;
// b = (* m1.find(i)).second;
}
GetSystemTime(&st1 );
int interval2 = st1.wMilliseconds - st2.wMilliseconds;
for( i = 0; i < 10000; i ++ )
{
Edge e(i,i);
s1.insert(e);
}
EDGEPOS e;
for( i = 0; i < 10000; i ++ )
{
e = s1.find(Edge(i,i));
;
//s1[i];
}
TRACE("%d,%d\n", (*e).m_bgVertexIdx, (*e).m_edVertexIdx);
GetSystemTime(&st2 );
int interval3 = st2.wMilliseconds - st1.wMilliseconds;
s1.insert(Edge(200,200));
s1.insert(Edge(200,300));
s1.insert(Edge(5200,5200));
s1.insert(Edge(5200,5300));
e = s1.find(Edge(5000,5000));
TRACE("%d,%d\n size: %d\n", (*e).m_bgVertexIdx, (*e).m_edVertexIdx, s1.size());
CString str1, str2, str3;
str1.Format("%d",interval1 );
str2.Format("%d",interval2 );
str3.Format("%d",interval3 );
MessageBox(str1+"ms " + str2 + "ms " + str3);
// find_if()
*/
BEGIN_EVENTSINK_MAP(CSubdivDlg, CDialog)
//{{AFX_EVENTSINK_MAP(CSubdivDlg)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -