91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 56KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-17
  • 語言: C/C++
  • 標簽: 源碼??

資源簡介

經典多邊形裁剪算法 Sutherland-Hodgman的VC++實現

資源截圖

代碼片段和文件信息

//?ChildView.cpp
//

#include?“stdafx.h“
#include?“PolygonClipDemo.h“
#include?“ChildView.h“
#include?“SutherlandHodgman.h“

#include?

#ifdef?_DEBUG
#define?new?DEBUG_NEW
#endif

inline?int?Int(REAL?r) {?return?(int)?floor(r?+?0.5f);?}

CChildView::CChildView()
:?m_bDrawing(false)
{
m_hCursorClose?=?::LoadCursor(::AfxGetInstanceHandle()?MAKEINTRESOURCE(IDC_CLOSEPOLYGON));
}

CChildView::~CChildView()
{
}

BEGIN_MESSAGE_MAP(CChildView?CWnd)
ON_WM_PAINT()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_SETCURSOR()
ON_WM_SIZE()
ON_UPDATE_COMMAND_UI(IDS_STATISTICS?OnUpdateStatistics)
END_MESSAGE_MAP()

BOOL?CChildView::PreCreateWindow(CREATESTRUCT&?cs)?
{
if?(!CWnd::PreCreateWindow(cs))
return?FALSE;

cs.dwExstyle?|=?WS_EX_CLIENTEDGE;
cs.style?&=?~WS_BORDER;
cs.lpszClass?=?AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS?
::LoadCursor(NULL?IDC_ARROW)?reinterpret_cast(COLOR_WINDOW+1)?NULL);

return?TRUE;
}

void?CChildView::PrepareDC(CDC&?dc)
{
dc.SetMapMode(MM_ANISOTROPIC);
dc.SetWindowExt(800?800);
dc.SetViewportExt(m_WindowSize);
dc.SetViewportOrg(m_WindowSize.cx?/?2?m_WindowSize.cy?/?2);
}

void?CChildView::OnSize(UINT?nType?int?cx?int?cy)
{
CWnd::OnSize(nType?cx?cy);
m_WindowSize.SetSize(cx?cy);
}

void?CChildView::OnPaint()?
{
CPaintDC?dc(this);
PrepareDC(dc);

CRect?rc(-100?-100?100?100);

CBrush?brush(RGB(240?240?240));

CGdiobject?*?pOldBrush?=?dc.Selectobject(&?brush);
dc.Rectangle(rc);
if?(pOldBrush)?dc.Selectobject(pOldBrush);

DrawPolygon(dc?m_InputPolygon);

CPen?pen(PS_SOLID?2?RGB(255?0?0));
CGdiobject?*?pOldPen?=?dc.Selectobject(&?pen);

DrawPolygon(dc?m_ClippedPolygon);

if?(pOldPen)?dc.Selectobject(pOldPen);
}

void?CChildView::DrawPolygon(CDC&?dc?const?vector&?v)
{
int?s?=?(int)?v.size();
if?(s?>?0)
{
POINT?*?pPoints?=?new?POINT[s];

POINT?*?p(pPoints);
copy(v.begin()?v.end()?p);

dc.MoveTo(pPoints[s?-?1]);
dc.PolylineTo(pPoints?s);

delete[]?pPoints;
}
}

void?CChildView::OnLButtonUp(UINT?nFlags?CPoint?point)
{
CClientDC?dc(this);
PrepareDC(dc);
dc.DPtoLP(&?point);
if?(nFlags?&?MK_SHIFT)?RestrictPoint(point);

if?(m_bDrawing)
{

dc.MoveTo(m_PrevPoint);
dc.LineTo(point);
if?(m_StartPoint.PtInRect(point))
{
m_bDrawing?=?false;
Clip();
Invalidate();

return;
}
}
else
{
m_bDrawing?=?true;
m_CurrentPoint?=?point;
m_StartPoint.SetRectEmpty();
m_StartPoint.InflateRect(::GetSystemMetrics(SM_CXDRAG)?::GetSystemMetrics(SM_CYDRAG));
m_StartPoint.OffsetRect(point);
m_InputPolygon.clear();
m_ClippedPolygon.clear();
Invalidate();
}
m_InputPolygon.push_back(point);
m_PrevPoint?=?point;
}

void?CChildView::onmousemove(UINT?nFlags?CPoint?point)
{
if?(m_bDrawing)
{
CClientDC?dc(this);
PrepareDC(dc);
dc.DPtoLP(&?point);
if?(nFlags?&?MK_SHIFT)?Rest

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????4634??2004-12-29?11:55??PolygonClipDemo.vcproj
?????文件?????????771??2004-12-26?15:21??resource.h
?????文件?????????215??2004-12-20?11:09??stdafx.cpp
?????文件????????1873??2004-12-28?12:20??stdafx.h
?????文件????????8269??2004-12-29?11:44??SutherlandHodgman.h
?????文件?????????326??2004-12-26?22:07??res\closepoly.cur
?????文件???????21630??2001-04-20?08:48??res\PolygonClipDemo.ico
?????文件?????????705??2004-12-20?11:09??res\PolygonClipDemo.manifest
?????文件?????????406??2004-12-20?11:09??res\PolygonClipDemo.rc2
?????目錄???????????0??2004-12-26?22:07??res\
?????文件????????4703??2005-08-03?13:58??ChildView.cpp
?????文件?????????862??2004-12-26?17:17??ChildView.h
?????文件???????18349??2003-12-09?15:06??COPYING.txt
?????文件????????2211??2004-12-26?17:03??MainFrm.cpp
?????文件?????????872??2004-12-26?16:54??MainFrm.h
?????文件????????2779??2004-12-20?11:09??PolygonClipDemo.cpp
?????文件???????65536??2004-12-29?11:55??PolygonClipDemo.exe
?????文件?????????601??2004-12-20?11:09??PolygonClipDemo.h
?????文件????????9216??2004-12-26?22:07??PolygonClipDemo.rc

評論

共有 條評論