diff --git a/Hidden-lineRemoval/Face.cpp b/Hidden-lineRemoval/Face.cpp new file mode 100644 index 0000000..f6ad50c --- /dev/null +++ b/Hidden-lineRemoval/Face.cpp @@ -0,0 +1,45 @@ +// Face.cpp: implementation of the CFace class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Test.h" +#include "Face.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CFace::CFace() +{ + vI=NULL; + fNormal=CVector(CP3(0.0,0.0,1.0)); +} + +CFace::~CFace() +{ + if(vI!=NULL) + { + delete []vI; + vI=NULL; + } +} + +void CFace::SetNum(int n) +{ + vN=n; + vI=new int[n]; +} + +void CFace::SetFaceNormal(CP3 pt0,CP3 pt1,CP3 pt2)//计算小面法矢量 +{ + CVector V01(pt0,pt1); + CVector V02(pt0,pt2); + fNormal=Cross(V01,V02); +} \ No newline at end of file diff --git a/Hidden-lineRemoval/Face.h b/Hidden-lineRemoval/Face.h new file mode 100644 index 0000000..02f51a8 --- /dev/null +++ b/Hidden-lineRemoval/Face.h @@ -0,0 +1,26 @@ +// Face.h: interface for the CFace class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_FACE_H__82BF93AE_A82E_407D_AF42_6E6608253C1C__INCLUDED_) +#define AFX_FACE_H__82BF93AE_A82E_407D_AF42_6E6608253C1C__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include "Vector.h" + +class CFace +{ +public: + CFace(); + virtual ~CFace(); + void SetNum(int); + void SetFaceNormal(CP3,CP3,CP3);//设置小面法矢量 +public: + int vN; //小面的顶点数 + int *vI; //小面的顶点索引 + CVector fNormal; //小面的法矢量 +}; + +#endif // !defined(AFX_FACE_H__82BF93AE_A82E_407D_AF42_6E6608253C1C__INCLUDED_) diff --git a/Hidden-lineRemoval/Line.cpp b/Hidden-lineRemoval/Line.cpp new file mode 100644 index 0000000..8274bc1 --- /dev/null +++ b/Hidden-lineRemoval/Line.cpp @@ -0,0 +1,141 @@ +// Line.cpp: implementation of the CLine class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Line.h" +#include "math.h" +#define Round(d) int(floor(d+0.5))//四舍五入宏定义 +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CLine::CLine() +{ + +} + +CLine::~CLine() +{ + +} + +void CLine::MoveTo(CDC *pDC,CP2 p0)//绘制直线起点函数 +{ + P0=p0; +} + +void CLine::MoveTo(CDC *pDC,double x0,double y0)//重载函数 +{ + P0=CP2(x0,y0); +} + +void CLine::LineTo(CDC *pDC,CP2 p1) +{ + P1=p1; + CP2 p,t; + CRGB clr=CRGB(0.0,0.0,0.0);//黑色像素点 + if(fabs(P0.x-P1.x)<1e-6)//绘制垂线 + { + if(P0.y>P1.y)//交换顶点,使得起始点低于终点 + { + t=P0;P0=P1;P1=t; + } + for(p=P0;p.ySetPixelV(Round(p.x),Round(p.y),RGB(clr.red*255,clr.green*255,clr.blue*255)); + } + } + else + { + double k,d; + k=(P1.y-P0.y)/(P1.x-P0.x); + if(k>1.0)//绘制k>1 + { + if(P0.y>P1.y) + { + t=P0;P0=P1;P1=t; + } + d=1-0.5*k; + for(p=P0;p.ySetPixelV(Round(p.x),Round(p.y),RGB(clr.red*255,clr.green*255,clr.blue*255)); + if(d>=0) + { + p.x++; + d+=1-k; + } + else + d+=1; + } + } + if(0.0<=k && k<=1.0)//绘制0<=k<=1 + { + if(P0.x>P1.x) + { + t=P0;P0=P1;P1=t; + } + d=0.5-k; + for(p=P0;p.xSetPixelV(Round(p.x),Round(p.y),RGB(clr.red*255,clr.green*255,clr.blue*255)); + if(d<0) + { + p.y++; + d+=1-k; + } + else + d-=k; + } + } + if(k>=-1.0 && k<0.0)//绘制-1<=k<0 + { + if(P0.x>P1.x) + { + t=P0;P0=P1;P1=t; + } + d=-0.5-k; + for(p=P0;p.xSetPixelV(Round(p.x),Round(p.y),RGB(clr.red*255,clr.green*255,clr.blue*255)); + if(d>0) + { + p.y--; + d-=1+k; + } + else + d-=k; + } + } + if(k<-1.0)//绘制k<-1 + { + if(P0.yP1.y;p.y--) + { + pDC->SetPixelV(Round(p.x),Round(p.y),RGB(clr.red*255,clr.green*255,clr.blue*255)); + if(d<0) + { + p.x++; + d-=1+k; + } + else + d-=1; + } + } + } + P0=p1; +} +void CLine::LineTo(CDC *pDC,double x1,double y1)//重载函数 +{ + LineTo(pDC,CP2(x1,y1)); +} \ No newline at end of file diff --git a/Hidden-lineRemoval/Line.h b/Hidden-lineRemoval/Line.h new file mode 100644 index 0000000..32ff30e --- /dev/null +++ b/Hidden-lineRemoval/Line.h @@ -0,0 +1,28 @@ +// Line.h: interface for the CLine class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_LINE_H__4F2B9CBA_79F9_412F_8E9F_4A7D0B14C66C__INCLUDED_) +#define AFX_LINE_H__4F2B9CBA_79F9_412F_8E9F_4A7D0B14C66C__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include "P2.h" +#include "RGB.h" + +class CLine +{ +public: + CLine(); + virtual ~CLine(); + void MoveTo(CDC *,CP2);//移动到指定位置 + void MoveTo(CDC *,double,double); + void LineTo(CDC *,CP2);//绘制直线,不含终点 + void LineTo(CDC *,double,double); +public: + CP2 P0;//起点 + CP2 P1;//终点 +}; + +#endif // !defined(AFX_LINE_H__4F2B9CBA_79F9_412F_8E9F_4A7D0B14C66C__INCLUDED_) diff --git a/Hidden-lineRemoval/MainFrm.cpp b/Hidden-lineRemoval/MainFrm.cpp new file mode 100644 index 0000000..4b8fbd9 --- /dev/null +++ b/Hidden-lineRemoval/MainFrm.cpp @@ -0,0 +1,107 @@ +// MainFrm.cpp : implementation of the CMainFrame class +// + +#include "stdafx.h" +#include "Test.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame + +IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) + +BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) + //{{AFX_MSG_MAP(CMainFrame) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code ! + ON_WM_CREATE() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // status line indicator + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame construction/destruction + +CMainFrame::CMainFrame() +{ + // TODO: add member initialization code here + +} + +CMainFrame::~CMainFrame() +{ +} + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CFrameWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP + | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) + { + TRACE0("Failed to create toolbar\n"); + return -1; // fail to create + } + + if (!m_wndStatusBar.Create(this) || + !m_wndStatusBar.SetIndicators(indicators, + sizeof(indicators)/sizeof(UINT))) + { + TRACE0("Failed to create status bar\n"); + return -1; // fail to create + } + + // TODO: Delete these three lines if you don't want the toolbar to + // be dockable + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + EnableDocking(CBRS_ALIGN_ANY); + DockControlBar(&m_wndToolBar); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CFrameWnd::PreCreateWindow(cs) ) + return FALSE; + // TODO: Modify the Window class or styles here by modifying + // the CREATESTRUCT cs + + return TRUE; +} + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame diagnostics + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CFrameWnd::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CFrameWnd::Dump(dc); +} + +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame message handlers + diff --git a/Hidden-lineRemoval/MainFrm.h b/Hidden-lineRemoval/MainFrm.h new file mode 100644 index 0000000..a52d77a --- /dev/null +++ b/Hidden-lineRemoval/MainFrm.h @@ -0,0 +1,58 @@ +// MainFrm.h : interface of the CMainFrame class +// +///////////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_MAINFRM_H__7BDF38E2_1C35_4E15_804B_2AB491FCC818__INCLUDED_) +#define AFX_MAINFRM_H__7BDF38E2_1C35_4E15_804B_2AB491FCC818__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class CMainFrame : public CFrameWnd +{ + +protected: // create from serialization only + CMainFrame(); + DECLARE_DYNCREATE(CMainFrame) + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMainFrame) + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // control bar embedded members + CStatusBar m_wndStatusBar; + CToolBar m_wndToolBar; + +// Generated message map functions +protected: + //{{AFX_MSG(CMainFrame) + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MAINFRM_H__7BDF38E2_1C35_4E15_804B_2AB491FCC818__INCLUDED_) diff --git a/Hidden-lineRemoval/P2.cpp b/Hidden-lineRemoval/P2.cpp new file mode 100644 index 0000000..1b3c848 --- /dev/null +++ b/Hidden-lineRemoval/P2.cpp @@ -0,0 +1,36 @@ +// P2.cpp: implementation of the CP2 class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Test.h" +#include "P2.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CP2::CP2() +{ + x=0; + y=0; + w=1; +} + +CP2::~CP2() +{ + +} + +CP2::CP2(double x,double y) +{ + this->x=x; + this->y=y; + this->w=1; +} \ No newline at end of file diff --git a/Hidden-lineRemoval/P2.h b/Hidden-lineRemoval/P2.h new file mode 100644 index 0000000..f84ad5b --- /dev/null +++ b/Hidden-lineRemoval/P2.h @@ -0,0 +1,24 @@ +// P2.h: interface for the CP2 class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_P2_H__F5B8C5D7_BC9B_4346_817B_F55E89EE7598__INCLUDED_) +#define AFX_P2_H__F5B8C5D7_BC9B_4346_817B_F55E89EE7598__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class CP2 +{ +public: + CP2(); + virtual ~CP2(); + CP2(double,double); +public: + double x; + double y; + double w; +}; + +#endif // !defined(AFX_P2_H__F5B8C5D7_BC9B_4346_817B_F55E89EE7598__INCLUDED_) diff --git a/Hidden-lineRemoval/P3.cpp b/Hidden-lineRemoval/P3.cpp new file mode 100644 index 0000000..0a655ec --- /dev/null +++ b/Hidden-lineRemoval/P3.cpp @@ -0,0 +1,31 @@ +// P3.cpp: implementation of the CP3 class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Test.h" +#include "P3.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CP3::CP3() +{ + z=0.0; +} + +CP3::~CP3() +{ + +} +CP3::CP3(double x,double y,double z):CP2(x,y) +{ + this->z=z; +} \ No newline at end of file diff --git a/Hidden-lineRemoval/P3.h b/Hidden-lineRemoval/P3.h new file mode 100644 index 0000000..6ecfac5 --- /dev/null +++ b/Hidden-lineRemoval/P3.h @@ -0,0 +1,23 @@ +// P3.h: interface for the CP3 class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_P3_H__5B85FC65_6516_4259_941E_FAB30D13824E__INCLUDED_) +#define AFX_P3_H__5B85FC65_6516_4259_941E_FAB30D13824E__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include "P2.h" + +class CP3:public CP2 +{ +public: + CP3(); + virtual ~CP3(); + CP3(double,double,double); +public: + double z; +}; + +#endif // !defined(AFX_P3_H__5B85FC65_6516_4259_941E_FAB30D13824E__INCLUDED_) diff --git a/Hidden-lineRemoval/RES/APP.ICO b/Hidden-lineRemoval/RES/APP.ICO new file mode 100644 index 0000000..ff42f3e Binary files /dev/null and b/Hidden-lineRemoval/RES/APP.ICO differ diff --git a/Hidden-lineRemoval/RES/EXIT.ICO b/Hidden-lineRemoval/RES/EXIT.ICO new file mode 100644 index 0000000..a2fcaed Binary files /dev/null and b/Hidden-lineRemoval/RES/EXIT.ICO differ diff --git a/Hidden-lineRemoval/RES/Help.ico b/Hidden-lineRemoval/RES/Help.ico new file mode 100644 index 0000000..b1aaffa Binary files /dev/null and b/Hidden-lineRemoval/RES/Help.ico differ diff --git a/Hidden-lineRemoval/RES/Test.ico b/Hidden-lineRemoval/RES/Test.ico new file mode 100644 index 0000000..168ef77 Binary files /dev/null and b/Hidden-lineRemoval/RES/Test.ico differ diff --git a/Hidden-lineRemoval/RES/Test.rc2 b/Hidden-lineRemoval/RES/Test.rc2 new file mode 100644 index 0000000..f3b43e0 --- /dev/null +++ b/Hidden-lineRemoval/RES/Test.rc2 @@ -0,0 +1,13 @@ +// +// TEST.RC2 - resources Microsoft Visual C++ does not edit directly +// + +#ifdef APSTUDIO_INVOKED + #error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Add manually edited resources here... + +///////////////////////////////////////////////////////////////////////////// diff --git a/Hidden-lineRemoval/RES/TestDoc.ico b/Hidden-lineRemoval/RES/TestDoc.ico new file mode 100644 index 0000000..2a1f1ae Binary files /dev/null and b/Hidden-lineRemoval/RES/TestDoc.ico differ diff --git a/Hidden-lineRemoval/RES/Thumbs.db b/Hidden-lineRemoval/RES/Thumbs.db new file mode 100644 index 0000000..cb88f01 Binary files /dev/null and b/Hidden-lineRemoval/RES/Thumbs.db differ diff --git a/Hidden-lineRemoval/RES/Toolbar.bmp b/Hidden-lineRemoval/RES/Toolbar.bmp new file mode 100644 index 0000000..738aa37 Binary files /dev/null and b/Hidden-lineRemoval/RES/Toolbar.bmp differ diff --git a/Hidden-lineRemoval/RES/about.bmp b/Hidden-lineRemoval/RES/about.bmp new file mode 100644 index 0000000..a9d3f73 Binary files /dev/null and b/Hidden-lineRemoval/RES/about.bmp differ diff --git a/Hidden-lineRemoval/RES/bitmap3.bmp b/Hidden-lineRemoval/RES/bitmap3.bmp new file mode 100644 index 0000000..6e8e840 Binary files /dev/null and b/Hidden-lineRemoval/RES/bitmap3.bmp differ diff --git a/Hidden-lineRemoval/RES/draw.ico b/Hidden-lineRemoval/RES/draw.ico new file mode 100644 index 0000000..911bdce Binary files /dev/null and b/Hidden-lineRemoval/RES/draw.ico differ diff --git a/Hidden-lineRemoval/RGB.cpp b/Hidden-lineRemoval/RGB.cpp new file mode 100644 index 0000000..0e06fd3 --- /dev/null +++ b/Hidden-lineRemoval/RGB.cpp @@ -0,0 +1,129 @@ +// CRGB.cpp: implementation of the CRGB class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Test.h" +#include "RGB.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CRGB::CRGB() +{ + red=1.0; + green=1.0; + blue=1.0; +} +CRGB::CRGB(double r,double g,double b)//重载构造函数 +{ + red=r; + green=g; + blue=b; +} + +CRGB::~CRGB() +{ + +} + +CRGB operator +(const CRGB &c1,const CRGB &c2)//+运算符重载 +{ + CRGB c; + c.red=c1.red+c2.red; + c.green=c1.green+c2.green; + c.blue=c1.blue+c2.blue; + return c; +} + +CRGB operator -(const CRGB &c1,const CRGB &c2)//-运算符重载 +{ + CRGB c; + c.red=c1.red-c2.red; + c.green=c1.green-c2.green; + c.blue=c1.blue-c2.blue; + return c; +} + +CRGB operator *(const CRGB &c1,const CRGB &c2)//*运算符重载 +{ + CRGB c; + c.red=c1.red*c2.red; + c.green=c1.green*c2.green; + c.blue=c1.blue*c2.blue; + return c; +} + +CRGB operator *(const CRGB &c1,double k)//*运算符重载 +{ + CRGB c; + c.red=k*c1.red; + c.green=k*c1.green; + c.blue=k*c1.blue; + return c; +} + +CRGB operator *(double k,const CRGB &c1)//*运算符重载 +{ + CRGB c; + c.red=k*c1.red; + c.green=k*c1.green; + c.blue=k*c1.blue; + return c; +} + +CRGB operator /(const CRGB &c1,double k)///运算符重载 +{ + CRGB c; + c.red=c1.red/k; + c.green=c1.green/k; + c.blue=c1.blue/k; + return c; +} + +CRGB operator +=(CRGB &c1,CRGB &c2)//+=运算符重载 +{ + c1.red=c1.red+c2.red; + c1.green=c1.green+c2.green; + c1.blue=c1.blue+c2.blue; + return c1; +} + +CRGB operator -=(CRGB &c1,CRGB &c2)//-=运算符重载 +{ + c1.red=c1.red-c2.red; + c1.green=c1.green-c2.green; + c1.blue=c1.blue-c2.blue; + return c1; +} + +CRGB operator *=(CRGB &c1,CRGB &c2)//*=运算符重载 +{ + c1.red=c1.red*c2.red; + c1.green=c1.green*c2.green; + c1.blue=c1.blue*c2.blue; + return c1; +} + +CRGB operator /=(CRGB &c1,double k)///=运算符重载 +{ + c1.red=c1.red/k; + c1.green=c1.green/k; + c1.blue=c1.blue/k; + return c1; +} + +void CRGB::Normalize()//归一化 +{ + red=(red < 0.0) ? 0.0 : ((red > 1.0) ? 1.0 : red); + green=(green < 0.0) ? 0.0 : ((green > 1.0) ? 1.0 : green); + blue=(blue < 0.0) ? 0.0 : ((blue > 1.0) ? 1.0 : blue); +} + diff --git a/Hidden-lineRemoval/RGB.h b/Hidden-lineRemoval/RGB.h new file mode 100644 index 0000000..c5cb879 --- /dev/null +++ b/Hidden-lineRemoval/RGB.h @@ -0,0 +1,35 @@ +// CRGB.h: interface for the CRGB class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_CRGB_H__F14E5B6C_E5FA_4DD9_8051_EB943E4929E7__INCLUDED_) +#define AFX_CRGB_H__F14E5B6C_E5FA_4DD9_8051_EB943E4929E7__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class CRGB +{ +public: + CRGB(); + CRGB(double,double,double); + virtual ~CRGB(); + friend CRGB operator+(const CRGB &,const CRGB &);//运算符重载 + friend CRGB operator-(const CRGB &,const CRGB &); + friend CRGB operator*(const CRGB &,const CRGB &); + friend CRGB operator*(const CRGB &,double); + friend CRGB operator*(double,const CRGB &); + friend CRGB operator/(const CRGB &,double); + friend CRGB operator+=(CRGB &,CRGB &); + friend CRGB operator-=(CRGB &,CRGB &); + friend CRGB operator*=(CRGB &,CRGB &); + friend CRGB operator/=(CRGB &,double); + void Normalize(); //归一化到[0,1]区间 +public: + double red;//红色分量 + double green;//绿色分量 + double blue;//蓝色分量 +}; + +#endif // !defined(AFX_CRGB_H__F14E5B6C_E5FA_4DD9_8051_EB943E4929E7__INCLUDED_) diff --git a/Hidden-lineRemoval/ReadMe.txt b/Hidden-lineRemoval/ReadMe.txt new file mode 100644 index 0000000..a7f11b9 --- /dev/null +++ b/Hidden-lineRemoval/ReadMe.txt @@ -0,0 +1,105 @@ +======================================================================== + MICROSOFT FOUNDATION CLASS LIBRARY : Test +======================================================================== + + +AppWizard has created this Test application for you. This application +not only demonstrates the basics of using the Microsoft Foundation classes +but is also a starting point for writing your application. + +This file contains a summary of what you will find in each of the files that +make up your Test application. + +Test.dsp + This file (the project file) contains information at the project level and + is used to build a single project or subproject. Other users can share the + project (.dsp) file, but they should export the makefiles locally. + +Test.h + This is the main header file for the application. It includes other + project specific headers (including Resource.h) and declares the + CTestApp application class. + +Test.cpp + This is the main application source file that contains the application + class CTestApp. + +Test.rc + This is a listing of all of the Microsoft Windows resources that the + program uses. It includes the icons, bitmaps, and cursors that are stored + in the RES subdirectory. This file can be directly edited in Microsoft + Visual C++. + +Test.clw + This file contains information used by ClassWizard to edit existing + classes or add new classes. ClassWizard also uses this file to store + information needed to create and edit message maps and dialog data + maps and to create prototype member functions. + +res\Test.ico + This is an icon file, which is used as the application's icon. This + icon is included by the main resource file Test.rc. + +res\Test.rc2 + This file contains resources that are not edited by Microsoft + Visual C++. You should place all resources not editable by + the resource editor in this file. + + + +///////////////////////////////////////////////////////////////////////////// + +For the main frame window: + +MainFrm.h, MainFrm.cpp + These files contain the frame class CMainFrame, which is derived from + CFrameWnd and controls all SDI frame features. + +res\Toolbar.bmp + This bitmap file is used to create tiled images for the toolbar. + The initial toolbar and status bar are constructed in the CMainFrame + class. Edit this toolbar bitmap using the resource editor, and + update the IDR_MAINFRAME TOOLBAR array in Test.rc to add + toolbar buttons. +///////////////////////////////////////////////////////////////////////////// + +AppWizard creates one document type and one view: + +TestDoc.h, TestDoc.cpp - the document + These files contain your CTestDoc class. Edit these files to + add your special document data and to implement file saving and loading + (via CTestDoc::Serialize). + +TestView.h, TestView.cpp - the view of the document + These files contain your CTestView class. + CTestView objects are used to view CTestDoc objects. + + + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named Test.pch and a precompiled types file named StdAfx.obj. + +Resource.h + This is the standard header file, which defines new resource IDs. + Microsoft Visual C++ reads and updates this file. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" to indicate parts of the source code you +should add to or customize. + +If your application uses MFC in a shared DLL, and your application is +in a language other than the operating system's current language, you +will need to copy the corresponding localized resources MFC42XXX.DLL +from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, +and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. +For example, MFC42DEU.DLL contains resources translated to German.) If you +don't do this, some of the UI elements of your application will remain in the +language of the operating system. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Hidden-lineRemoval/StdAfx.cpp b/Hidden-lineRemoval/StdAfx.cpp new file mode 100644 index 0000000..0f878dd --- /dev/null +++ b/Hidden-lineRemoval/StdAfx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// Test.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + + diff --git a/Hidden-lineRemoval/StdAfx.h b/Hidden-lineRemoval/StdAfx.h new file mode 100644 index 0000000..227ba92 --- /dev/null +++ b/Hidden-lineRemoval/StdAfx.h @@ -0,0 +1,33 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__40591CFA_4C1D_4FD7_8414_6EA0BBACA787__INCLUDED_) +#define AFX_STDAFX_H__40591CFA_4C1D_4FD7_8414_6EA0BBACA787__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include // MFC core and standard components +#include // MFC extensions +#include // MFC Automation classes +#include // MFC support for Internet Explorer 4 Common Controls +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT +// 版权所有(2013) +// Copyright(2013) +// 编写者: 孔令德 +// Author: Kong Lingde +// 网址:www.klingde.com +// QQ:997796978 +// 地址:太原工业学院 计算机工程系 + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__40591CFA_4C1D_4FD7_8414_6EA0BBACA787__INCLUDED_) diff --git a/Hidden-lineRemoval/Test.aps b/Hidden-lineRemoval/Test.aps new file mode 100644 index 0000000..8f55d70 Binary files /dev/null and b/Hidden-lineRemoval/Test.aps differ diff --git a/Hidden-lineRemoval/Test.clw b/Hidden-lineRemoval/Test.clw new file mode 100644 index 0000000..3b56fee --- /dev/null +++ b/Hidden-lineRemoval/Test.clw @@ -0,0 +1,101 @@ +; CLW file contains information for the MFC ClassWizard + +[General Info] +Version=1 +LastClass=CTestView +LastTemplate=CDialog +NewFileInclude1=#include "stdafx.h" +NewFileInclude2=#include "Test.h" +LastPage=0 + +ClassCount=5 +Class1=CTestApp +Class2=CTestDoc +Class3=CTestView +Class4=CMainFrame + +ResourceCount=2 +Resource1=IDR_MAINFRAME +Class5=CAboutDlg +Resource2=IDD_ABOUTBOX + +[CLS:CTestApp] +Type=0 +HeaderFile=Test.h +ImplementationFile=Test.cpp +Filter=N + +[CLS:CTestDoc] +Type=0 +HeaderFile=TestDoc.h +ImplementationFile=TestDoc.cpp +Filter=N + +[CLS:CTestView] +Type=0 +HeaderFile=TestView.h +ImplementationFile=TestView.cpp +Filter=C +BaseClass=CView +VirtualFilter=VWC +LastObject=CTestView + + +[CLS:CMainFrame] +Type=0 +HeaderFile=MainFrm.h +ImplementationFile=MainFrm.cpp +Filter=T +LastObject=IDM_PLAY + + + + +[CLS:CAboutDlg] +Type=0 +HeaderFile=Test.cpp +ImplementationFile=Test.cpp +Filter=D + +[DLG:IDD_ABOUTBOX] +Type=1 +Class=CAboutDlg +ControlCount=2 +Control1=IDOK,button,1342373889 +Control2=IDB_BITMAP1,static,1342177294 + +[MNU:IDR_MAINFRAME] +Type=1 +Class=CMainFrame +Command1=ID_APP_EXIT +Command2=IDM_PLAY +Command3=ID_APP_ABOUT +CommandCount=3 + +[ACL:IDR_MAINFRAME] +Type=1 +Class=CMainFrame +Command1=ID_FILE_NEW +Command2=ID_FILE_OPEN +Command3=ID_FILE_SAVE +Command4=ID_FILE_PRINT +Command5=ID_EDIT_UNDO +Command6=ID_EDIT_CUT +Command7=ID_EDIT_COPY +Command8=ID_EDIT_PASTE +Command9=ID_EDIT_UNDO +Command10=ID_EDIT_CUT +Command11=ID_EDIT_COPY +Command12=ID_EDIT_PASTE +Command13=ID_NEXT_PANE +Command14=ID_PREV_PANE +CommandCount=14 + +[TB:IDR_MAINFRAME] +Type=1 +Class=? +Command1=ID_APP_EXIT +Command2=IDM_PLAY +Command3=ID_APP_ABOUT +CommandCount=3 + diff --git a/Hidden-lineRemoval/Test.cpp b/Hidden-lineRemoval/Test.cpp new file mode 100644 index 0000000..e072e1f --- /dev/null +++ b/Hidden-lineRemoval/Test.cpp @@ -0,0 +1,154 @@ +// Test.cpp : Defines the class behaviors for the application. +// + +#include "stdafx.h" +#include "Test.h" + +#include "MainFrm.h" +#include "TestDoc.h" +#include "TestView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CTestApp + +BEGIN_MESSAGE_MAP(CTestApp, CWinApp) + //{{AFX_MSG_MAP(CTestApp) + ON_COMMAND(ID_APP_ABOUT, OnAppAbout) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG_MAP + // Standard file based document commands + ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) + // Standard print setup command + ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CTestApp construction + +CTestApp::CTestApp() +{ + // TODO: add construction code here, + // Place all significant initialization in InitInstance +} + +///////////////////////////////////////////////////////////////////////////// +// The one and only CTestApp object + +CTestApp theApp; + +///////////////////////////////////////////////////////////////////////////// +// CTestApp initialization + +BOOL CTestApp::InitInstance() +{ + AfxEnableControlContainer(); + + // Standard initialization + // If you are not using these features and wish to reduce the size + // of your final executable, you should remove from the following + // the specific initialization routines you do not need. + +#ifdef _AFXDLL + Enable3dControls(); // Call this when using MFC in a shared DLL +#else + Enable3dControlsStatic(); // Call this when linking to MFC statically +#endif + + // Change the registry key under which our settings are stored. + // TODO: You should modify this string to be something appropriate + // such as the name of your company or organization. + SetRegistryKey(_T("Local AppWizard-Generated Applications")); + + LoadStdProfileSettings(); // Load standard INI file options (including MRU) + + // Register the application's document templates. Document templates + // serve as the connection between documents, frame windows and views. + + CSingleDocTemplate* pDocTemplate; + pDocTemplate = new CSingleDocTemplate( + IDR_MAINFRAME, + RUNTIME_CLASS(CTestDoc), + RUNTIME_CLASS(CMainFrame), // main SDI frame window + RUNTIME_CLASS(CTestView)); + AddDocTemplate(pDocTemplate); + + // Parse command line for standard shell commands, DDE, file open + CCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + + // Dispatch commands specified on the command line + if (!ProcessShellCommand(cmdInfo)) + return FALSE; + + // The one and only window has been initialized, so show and update it. + m_pMainWnd->ShowWindow(SW_MAXIMIZE); + m_pMainWnd->SetWindowText("案例38:正二十面体动态隐线算法"); + m_pMainWnd->UpdateWindow(); + return TRUE; +} + + +///////////////////////////////////////////////////////////////////////////// +// 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) + // No message handlers + //}}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() + +// App command to run the dialog +void CTestApp::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + +///////////////////////////////////////////////////////////////////////////// +// CTestApp message handlers + diff --git a/Hidden-lineRemoval/Test.dsp b/Hidden-lineRemoval/Test.dsp new file mode 100644 index 0000000..6927636 --- /dev/null +++ b/Hidden-lineRemoval/Test.dsp @@ -0,0 +1,246 @@ +# Microsoft Developer Studio Project File - Name="Test" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=Test - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Test.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Test.mak" CFG="Test - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Test - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "Test - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Test - Win32 Release" + +# PROP BASE Use_MFC 6 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 6 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x804 /d "NDEBUG" /d "_AFXDLL" +# ADD RSC /l 0x804 /d "NDEBUG" /d "_AFXDLL" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 +# ADD LINK32 /nologo /subsystem:windows /machine:I386 + +!ELSEIF "$(CFG)" == "Test - Win32 Debug" + +# PROP BASE Use_MFC 6 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 6 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /Yu"stdafx.h" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x804 /d "_DEBUG" /d "_AFXDLL" +# ADD RSC /l 0x804 /d "_DEBUG" /d "_AFXDLL" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "Test - Win32 Release" +# Name "Test - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\Face.cpp +# End Source File +# Begin Source File + +SOURCE=.\Line.cpp +# End Source File +# Begin Source File + +SOURCE=.\MainFrm.cpp +# End Source File +# Begin Source File + +SOURCE=.\P2.cpp +# End Source File +# Begin Source File + +SOURCE=.\P3.cpp +# End Source File +# Begin Source File + +SOURCE=.\RGB.cpp +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# Begin Source File + +SOURCE=.\Test.cpp +# End Source File +# Begin Source File + +SOURCE=.\Test.rc +# End Source File +# Begin Source File + +SOURCE=.\TestDoc.cpp +# End Source File +# Begin Source File + +SOURCE=.\TestView.cpp +# End Source File +# Begin Source File + +SOURCE=".\Transform .cpp" +# End Source File +# Begin Source File + +SOURCE=.\Vector.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\Face.h +# End Source File +# Begin Source File + +SOURCE=.\Line.h +# End Source File +# Begin Source File + +SOURCE=.\MainFrm.h +# End Source File +# Begin Source File + +SOURCE=.\P2.h +# End Source File +# Begin Source File + +SOURCE=.\P3.h +# End Source File +# Begin Source File + +SOURCE=.\Resource.h +# End Source File +# Begin Source File + +SOURCE=.\RGB.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# Begin Source File + +SOURCE=.\Test.h +# End Source File +# Begin Source File + +SOURCE=.\TestDoc.h +# End Source File +# Begin Source File + +SOURCE=.\TestView.h +# End Source File +# Begin Source File + +SOURCE=.\TransForm.h +# End Source File +# Begin Source File + +SOURCE=.\Vector.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\RES\about.bmp +# End Source File +# Begin Source File + +SOURCE=.\res\app.ico +# End Source File +# Begin Source File + +SOURCE=.\res\draw.ico +# End Source File +# Begin Source File + +SOURCE=.\res\exit.ico +# End Source File +# Begin Source File + +SOURCE=.\res\Help.ico +# End Source File +# Begin Source File + +SOURCE=.\res\Test.ico +# End Source File +# Begin Source File + +SOURCE=.\res\Test.rc2 +# End Source File +# Begin Source File + +SOURCE=.\res\TestDoc.ico +# End Source File +# Begin Source File + +SOURCE=.\res\Toolbar.bmp +# End Source File +# End Group +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# End Target +# End Project diff --git a/Hidden-lineRemoval/Test.dsw b/Hidden-lineRemoval/Test.dsw new file mode 100644 index 0000000..d4e2b94 --- /dev/null +++ b/Hidden-lineRemoval/Test.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "Test"=.\Test.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/Hidden-lineRemoval/Test.h b/Hidden-lineRemoval/Test.h new file mode 100644 index 0000000..15c93e0 --- /dev/null +++ b/Hidden-lineRemoval/Test.h @@ -0,0 +1,49 @@ +// Test.h : main header file for the TEST application +// + +#if !defined(AFX_TEST_H__687EC7D4_477F_4BD3_BCC6_BD41AD64322D__INCLUDED_) +#define AFX_TEST_H__687EC7D4_477F_4BD3_BCC6_BD41AD64322D__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CTestApp: +// See Test.cpp for the implementation of this class +// + +class CTestApp : public CWinApp +{ +public: + CTestApp(); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CTestApp) + public: + virtual BOOL InitInstance(); + //}}AFX_VIRTUAL + +// Implementation + //{{AFX_MSG(CTestApp) + afx_msg void OnAppAbout(); + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_TEST_H__687EC7D4_477F_4BD3_BCC6_BD41AD64322D__INCLUDED_) diff --git a/Hidden-lineRemoval/Test.ncb b/Hidden-lineRemoval/Test.ncb new file mode 100644 index 0000000..7335764 Binary files /dev/null and b/Hidden-lineRemoval/Test.ncb differ diff --git a/Hidden-lineRemoval/Test.opt b/Hidden-lineRemoval/Test.opt new file mode 100644 index 0000000..77772a1 Binary files /dev/null and b/Hidden-lineRemoval/Test.opt differ diff --git a/Hidden-lineRemoval/Test.plg b/Hidden-lineRemoval/Test.plg new file mode 100644 index 0000000..3936715 --- /dev/null +++ b/Hidden-lineRemoval/Test.plg @@ -0,0 +1,45 @@ + + +
+

Build Log

+

+--------------------Configuration: Test - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\Users\ADMINI~1\AppData\Local\Temp\RSP6F3C.tmp" with contents +[ +/nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR"Debug/" /Fp"Debug/Test.pch" /Yu"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"H:\2021秋计算机图形学\修改版\球体一系列效果\球动态隐线算法\TestView.cpp" +] +Creating command line "cl.exe @C:\Users\ADMINI~1\AppData\Local\Temp\RSP6F3C.tmp" +Creating temporary file "C:\Users\ADMINI~1\AppData\Local\Temp\RSP6F3D.tmp" with contents +[ +/nologo /subsystem:windows /incremental:yes /pdb:"Debug/Test.pdb" /debug /machine:I386 /out:"Debug/Test.exe" /pdbtype:sept +".\Debug\Face.obj" +".\Debug\Line.obj" +".\Debug\MainFrm.obj" +".\Debug\P2.obj" +".\Debug\P3.obj" +".\Debug\RGB.obj" +".\Debug\StdAfx.obj" +".\Debug\Test.obj" +".\Debug\TestDoc.obj" +".\Debug\TestView.obj" +".\Debug\Transform .obj" +".\Debug\Vector.obj" +".\Debug\Test.res" +] +Creating command line "link.exe @C:\Users\ADMINI~1\AppData\Local\Temp\RSP6F3D.tmp" +

Output Window

+Compiling... +TestView.cpp +h:\2021秋计算机图形学\修改版\球体一系列效果\球动态隐线算法\testview.cpp(4) : fatal error C1853: 'Debug/Test.pch' is not a precompiled header file created with this compiler +执行 cl.exe 时出错. + + + +

Results

+Test.exe - 1 error(s), 0 warning(s) +
+ + diff --git a/Hidden-lineRemoval/Test.rc b/Hidden-lineRemoval/Test.rc new file mode 100644 index 0000000..4dfb340 --- /dev/null +++ b/Hidden-lineRemoval/Test.rc @@ -0,0 +1,373 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Chinese (P.R.C.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) +#ifdef _WIN32 +LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED +#pragma code_page(936) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)\r\n" + "#ifdef _WIN32\r\n" + "LANGUAGE 4, 2\r\n" + "#pragma code_page(936)\r\n" + "#endif //_WIN32\r\n" + "#include ""res\\Test.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""l.chs\\afxres.rc"" // Standard components\r\n" + "#include ""l.chs\\afxprint.rc"" // printing/print preview resources\r\n" + "#endif\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON DISCARDABLE "res\\Test.ico" +IDR_TESTTYPE ICON DISCARDABLE "res\\TestDoc.ico" +IDI_ICON1 ICON DISCARDABLE "res\\Help.ico" +IDI_ICON2 ICON DISCARDABLE "res\\app.ico" +IDI_ICON5 ICON DISCARDABLE "res\\exit.ico" +IDI_ICON6 ICON DISCARDABLE "res\\draw.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp" +IDB_ABOUT BITMAP DISCARDABLE "res\\about.bmp" + +///////////////////////////////////////////////////////////////////////////// +// +// Toolbar +// + +IDR_MAINFRAME TOOLBAR DISCARDABLE 32, 32 +BEGIN + BUTTON ID_APP_EXIT + BUTTON IDM_PLAY + BUTTON ID_APP_ABOUT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_MAINFRAME MENU PRELOAD DISCARDABLE +BEGIN + POPUP "文件(&F)" + BEGIN + MENUITEM "退出(&X)", ID_APP_EXIT + END + POPUP "绘图(&D)" + BEGIN + MENUITEM "Play", IDM_PLAY + END + POPUP "帮助(&H)" + BEGIN + MENUITEM "关于 Test(&A)...", ID_APP_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE +BEGIN + "N", ID_FILE_NEW, VIRTKEY, CONTROL + "O", ID_FILE_OPEN, VIRTKEY, CONTROL + "S", ID_FILE_SAVE, VIRTKEY, CONTROL + "P", ID_FILE_PRINT, VIRTKEY, CONTROL + "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL + "X", ID_EDIT_CUT, VIRTKEY, CONTROL + "C", ID_EDIT_COPY, VIRTKEY, CONTROL + "V", ID_EDIT_PASTE, VIRTKEY, CONTROL + VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT + VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT + VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL + VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT + VK_F6, ID_NEXT_PANE, VIRTKEY + VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 216, 180 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "关于 Test" +FONT 9, "宋体" +BEGIN + DEFPUSHBUTTON "确定",IDOK,85,159,50,14,WS_GROUP + CONTROL 134,IDB_BITMAP1,"Static",SS_BITMAP,7,7,200,150 +END + + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080404B0" + BEGIN + VALUE "CompanyName", "\0" + VALUE "FileDescription", "Test Microsoft 基础类应用程序\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "Test\0" + VALUE "LegalCopyright", "版权所有 (C) 2006\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "Test.EXE\0" + VALUE "ProductName", "Test 应用程序\0" + VALUE "ProductVersion", "1, 0, 0, 1\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x804, 1200 + END +END + +#endif // !_MAC + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 208 + TOPMARGIN, 7 + BOTTOMMARGIN, 173 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE PRELOAD DISCARDABLE +BEGIN + IDR_MAINFRAME "Test\n\nTest\n\n\nTest.Document\nTest Document" +END + +STRINGTABLE PRELOAD DISCARDABLE +BEGIN + AFX_IDS_APP_TITLE "Test" + AFX_IDS_IDLEMESSAGE "就绪" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_INDICATOR_EXT "扩展名" + ID_INDICATOR_CAPS "大写" + ID_INDICATOR_NUM "数字" + ID_INDICATOR_SCRL "滚动" + ID_INDICATOR_OVR "改写" + ID_INDICATOR_REC "记录" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_FILE_NEW "建立新文档\n新建" + ID_FILE_OPEN "打开一个现有文档\n打开" + ID_FILE_CLOSE "关闭活动文档\n关闭" + ID_FILE_SAVE "保存活动文档\n保存" + ID_FILE_SAVE_AS "将活动文档以一个新文件名保存\n另存为" + ID_FILE_PAGE_SETUP "改变打印选项\n页面设置" + ID_FILE_PRINT_SETUP "改变打印机及打印选项\n打印设置" + ID_FILE_PRINT "打印活动文档\n打印" + ID_FILE_PRINT_PREVIEW "显示整页\n打印预览" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_APP_ABOUT "开发人员信息\n关于" + ID_APP_EXIT "退出应用程序\n退出" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_FILE_MRU_FILE1 "打开该文档" + ID_FILE_MRU_FILE2 "打开该文档" + ID_FILE_MRU_FILE3 "打开该文档" + ID_FILE_MRU_FILE4 "打开该文档" + ID_FILE_MRU_FILE5 "打开该文档" + ID_FILE_MRU_FILE6 "打开该文档" + ID_FILE_MRU_FILE7 "打开该文档" + ID_FILE_MRU_FILE8 "打开该文档" + ID_FILE_MRU_FILE9 "打开该文档" + ID_FILE_MRU_FILE10 "打开该文档" + ID_FILE_MRU_FILE11 "打开该文档" + ID_FILE_MRU_FILE12 "打开该文档" + ID_FILE_MRU_FILE13 "打开该文档" + ID_FILE_MRU_FILE14 "打开该文档" + ID_FILE_MRU_FILE15 "打开该文档" + ID_FILE_MRU_FILE16 "打开该文档" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_NEXT_PANE "切换到下一个窗格\n下一窗格" + ID_PREV_PANE "切换回前一个窗格\n前一窗格" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_WINDOW_SPLIT "将活动的窗口分隔成窗格\n分隔" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_EDIT_CLEAR "删除被选对象\n删除" + ID_EDIT_CLEAR_ALL "全部删除\n全部删除" + ID_EDIT_COPY "复制被选对象并将其置于剪贴板上\n复制" + ID_EDIT_CUT "剪切被选对象并将其置于剪贴板上\n剪切" + ID_EDIT_FIND "查找指定的正文\n查找" + ID_EDIT_PASTE "插入剪贴板内容\n粘贴" + ID_EDIT_REPEAT "重复上一步操作\n重复" + ID_EDIT_REPLACE "用不同的正文替换指定的正文\n替换" + ID_EDIT_SELECT_ALL "选择整个文档\n选择全部" + ID_EDIT_UNDO "撤消最后一步操作\n撤消" + ID_EDIT_REDO "重新执行先前已撤消的操作\n重新执行" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_VIEW_TOOLBAR "显示或隐藏工具栏\n显隐工具栏" + ID_VIEW_STATUS_BAR "显示或隐藏状态栏\n显隐状态栏" +END + +STRINGTABLE DISCARDABLE +BEGIN + AFX_IDS_SCSIZE "改变窗口大小" + AFX_IDS_SCMOVE "改变窗口位置" + AFX_IDS_SCMINIMIZE "将窗口缩小成图标" + AFX_IDS_SCMAXIMIZE "把窗口放大到最大尺寸" + AFX_IDS_SCNEXTWINDOW "切换到下一个文档窗口" + AFX_IDS_SCPREVWINDOW "切换到先前的文档窗口" + AFX_IDS_SCCLOSE "关闭活动的窗口并提示保存所有文档" +END + +STRINGTABLE DISCARDABLE +BEGIN + AFX_IDS_SCRESTORE "把窗口恢复到正常大小" + AFX_IDS_SCTASKLIST "激活任务表" +END + +STRINGTABLE DISCARDABLE +BEGIN + AFX_IDS_PREVIEW_CLOSE "关闭打印预览模式\n取消预阅" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_MENUPlay "动画演示\n动画" + IDM_PLAY "动画演示\n动画" +END + +#endif // Chinese (P.R.C.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) +#ifdef _WIN32 +LANGUAGE 4, 2 +#pragma code_page(936) +#endif //_WIN32 +#include "res\Test.rc2" // non-Microsoft Visual C++ edited resources +#include "l.chs\afxres.rc" // Standard components +#include "l.chs\afxprint.rc" // printing/print preview resources +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Hidden-lineRemoval/Test.sdf b/Hidden-lineRemoval/Test.sdf new file mode 100644 index 0000000..c89086f Binary files /dev/null and b/Hidden-lineRemoval/Test.sdf differ diff --git a/Hidden-lineRemoval/Test.sln b/Hidden-lineRemoval/Test.sln new file mode 100644 index 0000000..53b3ffa --- /dev/null +++ b/Hidden-lineRemoval/Test.sln @@ -0,0 +1,20 @@ +锘� +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test.vcxproj", "{EE0FCB75-4D20-59E8-BC74-E71A46198F33}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EE0FCB75-4D20-59E8-BC74-E71A46198F33}.Debug|Win32.ActiveCfg = Debug|Win32 + {EE0FCB75-4D20-59E8-BC74-E71A46198F33}.Debug|Win32.Build.0 = Debug|Win32 + {EE0FCB75-4D20-59E8-BC74-E71A46198F33}.Release|Win32.ActiveCfg = Release|Win32 + {EE0FCB75-4D20-59E8-BC74-E71A46198F33}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Hidden-lineRemoval/Test.suo b/Hidden-lineRemoval/Test.suo new file mode 100644 index 0000000..207d15a Binary files /dev/null and b/Hidden-lineRemoval/Test.suo differ diff --git a/Hidden-lineRemoval/Test.vcxproj b/Hidden-lineRemoval/Test.vcxproj new file mode 100644 index 0000000..35da324 --- /dev/null +++ b/Hidden-lineRemoval/Test.vcxproj @@ -0,0 +1,189 @@ +锘� + + + + Debug + Win32 + + + Release + Win32 + + + + + + MFCProj + {EE0FCB75-4D20-59E8-BC74-E71A46198F33} + 10.0 + + + + Application + Dynamic + MultiByte + v143 + + + Application + Dynamic + MultiByte + v143 + + + + + + + + + + + + + + + .\Release\ + .\Release\ + false + + + .\Debug\ + .\Debug\ + true + + + + MultiThreadedDLL + OnlyExplicitInline + true + true + MaxSpeed + true + Level3 + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + .\Release\ + .\Release\Test.pch + Use + stdafx.h + .\Release\ + .\Release\ + + + true + NDEBUG;%(PreprocessorDefinitions) + .\Release\Test.tlb + true + Win32 + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + + + true + .\Release\Test.bsc + + + true + Windows + .\Release\Test.exe + + + + + MultiThreadedDebugDLL + Default + true + Disabled + true + Level3 + true + EditAndContinue + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + .\Debug\ + true + .\Debug\Test.pch + Use + stdafx.h + .\Debug\ + .\Debug\ + EnableFastChecks + + + true + _DEBUG;%(PreprocessorDefinitions) + .\Debug\Test.tlb + true + Win32 + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + + + true + .\Debug\Test.bsc + + + true + true + Windows + .\Debug\Test.exe + + + + + + + + + + + Create + stdafx.h + Create + stdafx.h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RC + + + + + + + + + \ No newline at end of file diff --git a/Hidden-lineRemoval/Test.vcxproj.filters b/Hidden-lineRemoval/Test.vcxproj.filters new file mode 100644 index 0000000..32860f0 --- /dev/null +++ b/Hidden-lineRemoval/Test.vcxproj.filters @@ -0,0 +1,131 @@ +锘� + + + + {fc33366b-55fb-433f-921c-1b4f9564ad6c} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {7ed3f8cf-ae41-4b1c-923a-0bc403061a39} + h;hpp;hxx;hm;inl + + + {8582452c-0132-48a4-8aae-1584f3c0dfdd} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + + \ No newline at end of file diff --git a/Hidden-lineRemoval/Test.vcxproj.user b/Hidden-lineRemoval/Test.vcxproj.user new file mode 100644 index 0000000..ace9a86 --- /dev/null +++ b/Hidden-lineRemoval/Test.vcxproj.user @@ -0,0 +1,3 @@ +锘� + + \ No newline at end of file diff --git a/Hidden-lineRemoval/TestDoc.cpp b/Hidden-lineRemoval/TestDoc.cpp new file mode 100644 index 0000000..b35f16f --- /dev/null +++ b/Hidden-lineRemoval/TestDoc.cpp @@ -0,0 +1,84 @@ +// TestDoc.cpp : implementation of the CTestDoc class +// + +#include "stdafx.h" +#include "Test.h" + +#include "TestDoc.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CTestDoc + +IMPLEMENT_DYNCREATE(CTestDoc, CDocument) + +BEGIN_MESSAGE_MAP(CTestDoc, CDocument) + //{{AFX_MSG_MAP(CTestDoc) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CTestDoc construction/destruction + +CTestDoc::CTestDoc() +{ + // TODO: add one-time construction code here + +} + +CTestDoc::~CTestDoc() +{ +} + +BOOL CTestDoc::OnNewDocument() +{ + if (!CDocument::OnNewDocument()) + return FALSE; + + // TODO: add reinitialization code here + // (SDI documents will reuse this document) + + return TRUE; +} + + + +///////////////////////////////////////////////////////////////////////////// +// CTestDoc serialization + +void CTestDoc::Serialize(CArchive& ar) +{ + if (ar.IsStoring()) + { + // TODO: add storing code here + } + else + { + // TODO: add loading code here + } +} + +///////////////////////////////////////////////////////////////////////////// +// CTestDoc diagnostics + +#ifdef _DEBUG +void CTestDoc::AssertValid() const +{ + CDocument::AssertValid(); +} + +void CTestDoc::Dump(CDumpContext& dc) const +{ + CDocument::Dump(dc); +} +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CTestDoc commands diff --git a/Hidden-lineRemoval/TestDoc.h b/Hidden-lineRemoval/TestDoc.h new file mode 100644 index 0000000..2638266 --- /dev/null +++ b/Hidden-lineRemoval/TestDoc.h @@ -0,0 +1,57 @@ +// TestDoc.h : interface of the CTestDoc class +// +///////////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_TESTDOC_H__72DBD624_92AB_462A_B0FD_D3F54BA45097__INCLUDED_) +#define AFX_TESTDOC_H__72DBD624_92AB_462A_B0FD_D3F54BA45097__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +class CTestDoc : public CDocument +{ +protected: // create from serialization only + CTestDoc(); + DECLARE_DYNCREATE(CTestDoc) + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CTestDoc) + public: + virtual BOOL OnNewDocument(); + virtual void Serialize(CArchive& ar); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CTestDoc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// Generated message map functions +protected: + //{{AFX_MSG(CTestDoc) + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_TESTDOC_H__72DBD624_92AB_462A_B0FD_D3F54BA45097__INCLUDED_) diff --git a/Hidden-lineRemoval/TestView.cpp b/Hidden-lineRemoval/TestView.cpp new file mode 100644 index 0000000..996446c --- /dev/null +++ b/Hidden-lineRemoval/TestView.cpp @@ -0,0 +1,456 @@ +// TestView.cpp : implementation of the CTestView class +// + +#include "stdafx.h" +#include "Test.h" +#include "TestDoc.h" +#include "TestView.h" +#include "math.h" //数学头文件 +#define PI 3.1415926 // 圆周率 +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CTestView + +IMPLEMENT_DYNCREATE(CTestView, CView) + +BEGIN_MESSAGE_MAP(CTestView, CView) +//{{AFX_MSG_MAP(CTestView) +ON_WM_LBUTTONDOWN() +ON_WM_RBUTTONDBLCLK() +ON_WM_TIMER() +ON_WM_KEYDOWN() +ON_WM_ERASEBKGND() +ON_COMMAND(IDM_PLAY, OnPlay) +ON_UPDATE_COMMAND_UI(IDM_PLAY, OnUpdatePlay) +//}}AFX_MSG_MAP +// Standard printing commands +ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) +ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) +ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CTestView construction/destruction + +CTestView::CTestView() +{ + // TODO: add construction code here + bPlay = FALSE; + R = 800.0; + d = 1000; + Phi = 45.0; + Theta = 45.0; + Alpha = 0.0; + Beta = 0.0; +} + +CTestView::~CTestView() +{ +} + +BOOL CTestView::PreCreateWindow(CREATESTRUCT &cs) +{ + // TODO: Modify the Window class or styles here by modifying + // the CREATESTRUCT cs + + return CView::PreCreateWindow(cs); +} + +///////////////////////////////////////////////////////////////////////////// +// CTestView drawing + +void CTestView::OnDraw(CDC *pDC) +{ + CTestDoc *pDoc = GetDocument(); + ASSERT_VALID(pDoc); + // TODO: add draw code for native data here + DoubleBuffer(); +} + +///////////////////////////////////////////////////////////////////////////// +// CTestView printing + +BOOL CTestView::OnPreparePrinting(CPrintInfo *pInfo) +{ + // default preparation + return DoPreparePrinting(pInfo); +} + +void CTestView::OnBeginPrinting(CDC * /*pDC*/, CPrintInfo * /*pInfo*/) +{ + // TODO: add extra initialization before printing +} + +void CTestView::OnEndPrinting(CDC * /*pDC*/, CPrintInfo * /*pInfo*/) +{ + // TODO: add cleanup after printing +} + +///////////////////////////////////////////////////////////////////////////// +// CTestView diagnostics + +#ifdef _DEBUG +void CTestView::AssertValid() const +{ + CView::AssertValid(); +} + +void CTestView::Dump(CDumpContext &dc) const +{ + CView::Dump(dc); +} + +CTestDoc *CTestView::GetDocument() // non-debug version is inline +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTestDoc))); + return (CTestDoc *)m_pDocument; +} +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CTestView message handlers + +void CTestView::ReadVertex() // 点表 +{ + const double Golden_Section = (sqrt(5.0) - 1.0) / 2.0; // 黄金分割比例 + double a = 160; // 黄金矩形长半边的边长 + double b = a * Golden_Section; // 黄金矩形短半边的边长 + // 顶点的三维坐标(x,y,z) + V[0].x = 0; + V[0].y = a; + V[0].z = b; + V[1].x = 0; + V[1].y = a; + V[1].z = -b; + V[2].x = a; + V[2].y = b; + V[2].z = 0; + V[3].x = a; + V[3].y = -b; + V[3].z = 0; + V[4].x = 0; + V[4].y = -a; + V[4].z = -b; + V[5].x = 0; + V[5].y = -a; + V[5].z = b; + V[6].x = b; + V[6].y = 0; + V[6].z = a; + V[7].x = -b; + V[7].y = 0; + V[7].z = a; + V[8].x = b; + V[8].y = 0; + V[8].z = -a; + V[9].x = -b; + V[9].y = 0; + V[9].z = -a; + V[10].x = -a; + V[10].y = b; + V[10].z = 0; + V[11].x = -a; + V[11].y = -b; + V[11].z = 0; +} + +void CTestView::ReadFace() // 面表 +{ + // 面的顶点数和面的顶点索引 + F[0].SetNum(3); + F[0].vI[0] = 0; + F[0].vI[1] = 6; + F[0].vI[2] = 2; + F[1].SetNum(3); + F[1].vI[0] = 2; + F[1].vI[1] = 6; + F[1].vI[2] = 3; + F[2].SetNum(3); + F[2].vI[0] = 3; + F[2].vI[1] = 6; + F[2].vI[2] = 5; + F[3].SetNum(3); + F[3].vI[0] = 5; + F[3].vI[1] = 6; + F[3].vI[2] = 7; + F[4].SetNum(3); + F[4].vI[0] = 0; + F[4].vI[1] = 7; + F[4].vI[2] = 6; + F[5].SetNum(3); + F[5].vI[0] = 2; + F[5].vI[1] = 3; + F[5].vI[2] = 8; + F[6].SetNum(3); + F[6].vI[0] = 1; + F[6].vI[1] = 2; + F[6].vI[2] = 8; + F[7].SetNum(3); + F[7].vI[0] = 0; + F[7].vI[1] = 2; + F[7].vI[2] = 1; + F[8].SetNum(3); + F[8].vI[0] = 0; + F[8].vI[1] = 1; + F[8].vI[2] = 10; + F[9].SetNum(3); + F[9].vI[0] = 1; + F[9].vI[1] = 9; + F[9].vI[2] = 10; + F[10].SetNum(3); + F[10].vI[0] = 1; + F[10].vI[1] = 8; + F[10].vI[2] = 9; + F[11].SetNum(3); + F[11].vI[0] = 3; + F[11].vI[1] = 4; + F[11].vI[2] = 8; + F[12].SetNum(3); + F[12].vI[0] = 3; + F[12].vI[1] = 5; + F[12].vI[2] = 4; + F[13].SetNum(3); + F[13].vI[0] = 4; + F[13].vI[1] = 5; + F[13].vI[2] = 11; + F[14].SetNum(3); + F[14].vI[0] = 7; + F[14].vI[1] = 10; + F[14].vI[2] = 11; + F[15].SetNum(3); + F[15].vI[0] = 0; + F[15].vI[1] = 10; + F[15].vI[2] = 7; + F[16].SetNum(3); + F[16].vI[0] = 4; + F[16].vI[1] = 11; + F[16].vI[2] = 9; + F[17].SetNum(3); + F[17].vI[0] = 4; + F[17].vI[1] = 9; + F[17].vI[2] = 8; + F[18].SetNum(3); + F[18].vI[0] = 5; + F[18].vI[1] = 7; + F[18].vI[2] = 11; + F[19].SetNum(3); + F[19].vI[0] = 9; + F[19].vI[1] = 11; + F[19].vI[2] = 10; +} + +void CTestView::InitParameter() // 透视变换参数初始化 +{ + k[1] = sin(PI * Theta / 180); + k[2] = sin(PI * Phi / 180); + k[3] = cos(PI * Theta / 180); + k[4] = cos(PI * Phi / 180); + k[5] = k[2] * k[3]; + k[6] = k[2] * k[1]; + k[7] = k[4] * k[3]; + k[8] = k[4] * k[1]; + ViewPoint.x = R * k[6]; + ViewPoint.y = R * k[4]; + ViewPoint.z = R * k[5]; +} + +void CTestView::PerProject(CP3 P) // 透视变换 +{ + CP3 ViewP; + ViewP.x = P.x * k[3] - P.z * k[1]; // 观察坐标系三维坐标 + ViewP.y = -P.x * k[8] + P.y * k[2] - P.z * k[7]; + ViewP.z = -P.x * k[6] - P.y * k[4] - P.z * k[5] + R; + ScreenP.x = d * ViewP.x / ViewP.z; // 屏幕坐标系二维坐标 + ScreenP.y = d * ViewP.y / ViewP.z; +} + +void CTestView::DoubleBuffer() // 双缓冲 +{ + CDC *pDC = GetDC(); + CRect rect; // 定义客户区 + GetClientRect(&rect); // 获得客户区的大小 + pDC->SetMapMode(MM_ANISOTROPIC); // pDC自定义坐标系 + pDC->SetWindowExt(rect.Width(), rect.Height()); // 设置窗口范围 + pDC->SetViewportExt(rect.Width(), -rect.Height()); // x轴水平向右,y轴垂直向上 + pDC->SetViewportOrg(rect.Width() / 2, rect.Height() / 2); // 屏幕中心为原点 + CDC MemDC; // 内存DC + CBitmap NewBitmap, *pOldBitmap; // 内存中承载图像的临时位图 + MemDC.CreateCompatibleDC(pDC); // 建立与屏幕pDC兼容的MemDC + NewBitmap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height()); // 创建兼容位图 + pOldBitmap = MemDC.SelectObject(&NewBitmap); // 将兼容位图选入MemDC + MemDC.FillSolidRect(&rect, pDC->GetBkColor()); // 按原来背景填充客户区,否则是黑色 + MemDC.SetMapMode(MM_ANISOTROPIC); // MemDC自定义坐标系 + MemDC.SetWindowExt(rect.Width(), rect.Height()); + MemDC.SetViewportExt(rect.Width(), -rect.Height()); + MemDC.SetViewportOrg(rect.Width() / 2, rect.Height() / 2); + DrawObject(&MemDC); + pDC->BitBlt(-rect.Width() / 2, -rect.Height() / 2, rect.Width(), rect.Height(), &MemDC, -rect.Width() / 2, -rect.Height() / 2, SRCCOPY); // 将内存位图拷贝到屏幕 + MemDC.SelectObject(pOldBitmap); // 恢复位图 + NewBitmap.DeleteObject(); // 删除位图 + ReleaseDC(pDC); // 释放DC +} + +void CTestView::DrawObject(CDC *pDC) // 绘制物体表面 +{ + CP3 p[4]; + double theta, phi; // theta控制小圆旋转,phi控制大圆旋转 + double pi = 3.14159, delta = pi / 20; + double R = 150; // 大圆半径 + double r = 50; // 小圆半径 + + for (theta = 0; theta <= 2 * pi; theta += delta) + for (phi = 0; phi <= 2 * pi; phi += delta) + { + // 计算圆环体上的四个顶点 + p[0].x = (R + r * cos(theta)) * cos(phi); + p[0].y = (R + r * cos(theta)) * sin(phi); + p[0].z = r * sin(theta); + + p[1].x = (R + r * cos(theta)) * cos(phi + delta); + p[1].y = (R + r * cos(theta)) * sin(phi + delta); + p[1].z = r * sin(theta); + + p[2].x = (R + r * cos(theta + delta)) * cos(phi + delta); + p[2].y = (R + r * cos(theta + delta)) * sin(phi + delta); + p[2].z = r * sin(theta + delta); + + p[3].x = (R + r * cos(theta + delta)) * cos(phi); + p[3].y = (R + r * cos(theta + delta)) * sin(phi); + p[3].z = r * sin(theta + delta); + + // ... 保持其余代码不变 ... + tran.SetMat(p, 4); + tran.RotateX(Alpha); + tran.RotateY(Beta); + + CVector ViewVector(p[0], ViewPoint); + ViewVector = ViewVector.Normalize(); + CFace f; + f.SetFaceNormal(p[0], p[1], p[2]); + f.fNormal.Normalize(); + if (Dot(ViewVector, f.fNormal) >= 0) + { + CP2 t; + CLine *line = new CLine; + for (int nPoint = 0; nPoint < 4; nPoint++) + { + PerProject(p[nPoint]); + if (0 == nPoint) + { + line->MoveTo(pDC, ScreenP); + t = ScreenP; + } + else + line->LineTo(pDC, ScreenP); + } + line->LineTo(pDC, t); + delete line; + } + } +} + +void CTestView::OnLButtonDown(UINT nFlags, CPoint point) // 鼠标左键函数 +{ + // TODO: Add your message handler code here and/or call default + R = R + 100; + InitParameter(); + Invalidate(FALSE); + CView::OnLButtonDown(nFlags, point); +} + +void CTestView::OnRButtonDblClk(UINT nFlags, CPoint point) // 鼠标右键函数 +{ + // TODO: Add your message handler code here and/or call default + R = R - 100; + InitParameter(); + Invalidate(FALSE); + CView::OnRButtonDblClk(nFlags, point); +} + +void CTestView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + // TODO: Add your message handler code here and/or call default + if (!bPlay) + { + switch (nChar) + { + case VK_UP: + Alpha = -5; + tran.RotateX(Alpha); + break; + case VK_DOWN: + Alpha = 5; + tran.RotateX(Alpha); + break; + case VK_LEFT: + Beta = -5; + tran.RotateY(Beta); + break; + case VK_RIGHT: + Beta = 5; + tran.RotateY(Beta); + break; + default: + break; + } + Invalidate(FALSE); + } + CView::OnKeyDown(nChar, nRepCnt, nFlags); +} + +void CTestView::OnPlay() +{ + // TODO: Add your command handler code here + bPlay = bPlay ? FALSE : TRUE; + if (bPlay) + SetTimer(1, 150, NULL); // 启动定时器 + else + KillTimer(1); // 关闭定时器 +} + +void CTestView::OnTimer(UINT nIDEvent) // 动画时间函数 +{ + // TODO: Add your message handler code here and/or call default + Alpha += 5; + Beta += 5; + // tran.RotateX(Alpha); + // tran.RotateY(Beta); + Invalidate(FALSE); + CView::OnTimer(nIDEvent); +} + +void CTestView::OnUpdatePlay(CCmdUI *pCmdUI) +{ + // TODO: Add your command update UI handler code here + if (bPlay) + { + pCmdUI->SetCheck(TRUE); + pCmdUI->SetText("停止"); + } + else + { + pCmdUI->SetCheck(FALSE); + pCmdUI->SetText("开始"); + } +} + +BOOL CTestView::OnEraseBkgnd(CDC *pDC) +{ + // TODO: Add your message handler code here and/or call default + return TRUE; +} + +void CTestView::OnInitialUpdate() +{ + CView::OnInitialUpdate(); + // TODO: Add your specialized code here and/or call the base class + ReadVertex(); + ReadFace(); + // tran.SetMat(V,12); + InitParameter(); +} diff --git a/Hidden-lineRemoval/TestView.h b/Hidden-lineRemoval/TestView.h new file mode 100644 index 0000000..88146ca --- /dev/null +++ b/Hidden-lineRemoval/TestView.h @@ -0,0 +1,88 @@ +// TestView.h : interface of the CTestView class +// +///////////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_TESTVIEW_H__A75FDCFB_621C_4E38_A154_C344803E6372__INCLUDED_) +#define AFX_TESTVIEW_H__A75FDCFB_621C_4E38_A154_C344803E6372__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include "Line.h" +#include "Face.h" +#include "Transform.h" + +class CTestView : public CView +{ +protected: // create from serialization only + CTestView(); + DECLARE_DYNCREATE(CTestView) + +// Attributes +public: + CTestDoc* GetDocument(); + +// Operations +public: + void ReadVertex();//读入点表 + void ReadFace();//读入面表 + void InitParameter();//参数初始化 + void PerProject(CP3);//透视投影 + void DoubleBuffer();//双缓冲绘图 + void DrawObject(CDC *);//绘制物体 +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CTestView) + public: + virtual void OnDraw(CDC* pDC); // overridden to draw this view + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual void OnInitialUpdate(); + protected: + virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); + virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); + virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CTestView(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + CP3 V[12];//点表 + CFace F[20];//面表 + double R,Theta,Phi,d;//R,Theta,Phi视点在用户坐标系的球坐标,d视距 + double k[9];//运算常量 + CP3 ViewPoint;//视点球坐标 + CP2 ScreenP;//屏幕坐标系的二维坐标点 + BOOL bPlay;//动画开关 + double Alpha,Beta;//x方向旋转α角,y方向旋转β角 + CTransform tran;//变换对象 + // Generated message map functions +protected: + //{{AFX_MSG(CTestView) + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point); + afx_msg void OnTimer(UINT nIDEvent); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnPlay(); + afx_msg void OnUpdatePlay(CCmdUI* pCmdUI); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +#ifndef _DEBUG // debug version in TestView.cpp +inline CTestDoc* CTestView::GetDocument() + { return (CTestDoc*)m_pDocument; } +#endif + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_TESTVIEW_H__A75FDCFB_621C_4E38_A154_C344803E6372__INCLUDED_) diff --git a/Hidden-lineRemoval/Transform .cpp b/Hidden-lineRemoval/Transform .cpp new file mode 100644 index 0000000..bee6c0e --- /dev/null +++ b/Hidden-lineRemoval/Transform .cpp @@ -0,0 +1,200 @@ +// Transform.cpp: implementation of the CTransForm class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Test.h" +#include "Transform.h" +#include "math.h" +#define PI 3.14159 +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CTransform::CTransform() +{ + +} + +CTransform::~CTransform() +{ + +} + +void CTransform::SetMat(CP3 *p,int n) +{ + POld=p; + num=n; +} + +void CTransform::Identity()//单位矩阵 +{ + T[0][0]=1.0;T[0][1]=0.0;T[0][2]=0.0;T[0][3]=0.0; + T[1][0]=0.0;T[1][1]=1.0;T[1][2]=0.0;T[1][3]=0.0; + T[2][0]=0.0;T[2][1]=0.0;T[2][2]=1.0;T[2][3]=0.0; + T[3][0]=0.0;T[3][1]=0.0;T[3][2]=0.0;T[3][3]=1.0; +} + +void CTransform::Translate(double tx,double ty,double tz)//平移变换矩阵 +{ + Identity(); + T[3][0]=tx; + T[3][1]=ty; + T[3][2]=tz; + MultiMatrix(); +} + +void CTransform::Scale(double sx,double sy,double sz)//比例变换矩阵 +{ + Identity(); + T[0][0]=sx; + T[1][1]=sy; + T[2][2]=sz; + MultiMatrix(); +} + +void CTransform::Scale(double sx,double sy,double sz,CP3 p)//相对于任意点的比例变换矩阵 +{ + Translate(-p.x,-p.y,-p.z); + Scale(sx,sy,sz); + Translate(p.x,p.y,p.z); +} + +void CTransform::RotateX(double beta)//绕X轴旋转变换矩阵 +{ + Identity(); + double rad=beta*PI/180; + T[1][1]=cos(rad); T[1][2]=sin(rad); + T[2][1]=-sin(rad);T[2][2]=cos(rad); + MultiMatrix(); +} + +void CTransform::RotateX(double beta,CP3 p)//相对于任意点的绕X轴旋转变换矩阵 +{ + Translate(-p.x,-p.y,-p.z); + RotateX(beta); + Translate(p.x,p.y,p.z); +} + +void CTransform::RotateY(double beta)//绕Y轴旋转变换矩阵 +{ + Identity(); + double rad=beta*PI/180; + T[0][0]=cos(rad);T[0][2]=-sin(rad); + T[2][0]=sin(rad);T[2][2]=cos(rad); + MultiMatrix(); +} + +void CTransform::RotateY(double beta,CP3 p)//相对于任意点的绕Y轴旋转变换矩阵 +{ + Translate(-p.x,-p.y,-p.z); + RotateY(beta); + Translate(p.x,p.y,p.z); +} + +void CTransform::RotateZ(double beta)//绕Z轴旋转变换矩阵 +{ + Identity(); + double rad=beta*PI/180; + T[0][0]=cos(rad); T[0][1]=sin(rad); + T[1][0]=-sin(rad);T[1][1]=cos(rad); + MultiMatrix(); +} + +void CTransform::RotateZ(double beta,CP3 p)//相对于任意点的绕Z轴旋转变换矩阵 +{ + Translate(-p.x,-p.y,-p.z); + RotateZ(beta); + Translate(p.x,p.y,p.z); +} + +void CTransform::ReflectX()//X轴反射变换矩阵 +{ + Identity(); + T[1][1]=-1; + T[2][2]=-1; + MultiMatrix(); +} + +void CTransform::ReflectY()//Y轴反射变换矩阵 +{ + Identity(); + T[0][0]=-1; + T[2][2]=-1; + MultiMatrix(); +} + +void CTransform::ReflectZ()//Z轴反射变换矩阵 +{ + Identity(); + T[0][0]=-1; + T[1][1]=-1; + MultiMatrix(); +} + +void CTransform::ReflectXOY()//XOY面反射变换矩阵 +{ + Identity(); + T[2][2]=-1; + MultiMatrix(); +} + +void CTransform::ReflectYOZ()//YOZ面反射变换矩阵 +{ + Identity(); + T[0][0]=-1; + MultiMatrix(); +} + +void CTransform::ReflectXOZ()//ZOX面反射变换矩阵 +{ + Identity(); + T[1][1]=-1; + MultiMatrix(); +} + +void CTransform::ShearX(double d,double g)//X方向错切变换矩阵 +{ + Identity(); + T[1][0]=d; + T[2][0]=g; + MultiMatrix(); +} + +void CTransform::ShearY(double b,double h)//Y方向错切变换矩阵 +{ + Identity(); + T[0][1]=b; + T[2][1]=h; + MultiMatrix(); +} + +void CTransform::ShearZ(double c,double f)//Z方向错切变换矩阵 +{ + Identity(); + T[0][2]=c; + T[1][2]=f; + MultiMatrix(); +} +void CTransform::MultiMatrix()//矩阵相乘 +{ + CP3 *PNew=new CP3[num]; + for(int i=0;i 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include "P3.h" + +class CTransform//三维变换 +{ +public: + CTransform(); + virtual ~CTransform(); + void SetMat(CP3 *,int); + void Identity(); + void Translate(double,double,double);//平移变换矩阵 + void Scale(double,double,double);//比例变换矩阵 + void Scale(double,double,double,CP3);//相对于任意点的比例变换矩阵 + void RotateX(double);//旋转变换矩阵 + void RotateX(double,CP3);//相对于任意点的X旋转变换矩阵 + void RotateY(double);//旋转变换矩阵 + void RotateY(double,CP3);//相对于任意点的Y旋转变换矩阵 + void RotateZ(double);//旋转变换矩阵 + void RotateZ(double,CP3);//相对于任意点的Z旋转变换矩阵 + void ReflectX();//X轴反射变换矩阵 + void ReflectY();//Y轴反射变换矩阵 + void ReflectZ();//Z轴反射变换矩阵 + void ReflectXOY();//XOY面反射变换矩阵 + void ReflectYOZ();//YOZ面反射变换矩阵 + void ReflectXOZ();//XOZ面反射变换矩阵 + void ShearX(double,double);//X方向错切变换矩阵 + void ShearY(double,double);//Y方向错切变换矩阵 + void ShearZ(double,double);//Z方向错切变换矩阵 + void MultiMatrix();//矩阵相乘 +public: + double T[4][4]; + CP3 *POld; + int num; +}; +#endif // !defined(AFX_TRANSFORM_H__C4FA86B2_0AF5_409A_94EB_B02A1EE13E05__INCLUDED_) diff --git a/Hidden-lineRemoval/Vector.cpp b/Hidden-lineRemoval/Vector.cpp new file mode 100644 index 0000000..535c940 --- /dev/null +++ b/Hidden-lineRemoval/Vector.cpp @@ -0,0 +1,161 @@ +// Vector.cpp: implementation of the CVector class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "Test.h" +#include "Vector.h" +#include "math.h" +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CVector::CVector()//z轴正向 +{ + x=0.0; + y=0.0; + z=1.0; +} + +CVector::~CVector() +{ + +} + +CVector::CVector(const CP3 &p) +{ + x=p.x; + y=p.y; + z=p.z; +} + +CVector::CVector(double x,double y,double z) +{ + this->x=x; + this->y=y; + this->z=z; +} + +CVector::CVector(const CP3 &p0,const CP3 &p1) +{ + x=p1.x-p0.x; + y=p1.y-p0.y; + z=p1.z-p0.z; +} + +double CVector::Mag()//矢量的模 +{ + return sqrt(x*x+y*y+z*z); +} + +CVector CVector::Normalize()//归一化到单位矢量 +{ + CVector vector; + double Mag=sqrt(x*x+y*y+z*z); + if(fabs(Mag)<1e-6) + Mag=1.0; + vector.x=x/Mag; + vector.y=y/Mag; + vector.z=z/Mag; + return vector; +} + +CVector operator +(const CVector &v0,const CVector &v1)//矢量的和 +{ + CVector vector; + vector.x=v0.x+v1.x; + vector.y=v0.y+v1.y; + vector.z=v0.z+v1.z; + return vector; +} + +CVector operator -(const CVector &v0,const CVector &v1)//矢量的差 +{ + CVector vector; + vector.x=v0.x-v1.x; + vector.y=v0.y-v1.y; + vector.z=v0.z-v1.z; + return vector; +} + +CVector operator *(const CVector &v,double k)//矢量与常量的积 +{ + CVector vector; + vector.x=v.x*k; + vector.y=v.y*k; + vector.z=v.z*k; + return vector; +} + +CVector operator *(double k,const CVector &v)//常量与矢量的积 +{ + CVector vector; + vector.x=v.x*k; + vector.y=v.y*k; + vector.z=v.z*k; + return vector; +} + +CVector operator /(const CVector &v,double k)//矢量数除 +{ + if(fabs(k)<1e-6) + k=1.0; + CVector vector; + vector.x=v.x/k; + vector.y=v.y/k; + vector.z=v.z/k; + return vector; +} + +CVector operator +=(CVector &v0,CVector &v1)//+=运算符重载 +{ + v1.x=v0.x+v1.x; + v1.y=v0.y+v1.y; + v1.z=v0.z+v1.z; + return v1; +} + +CVector operator -=(CVector &v0,CVector &v1)//-=运算符重载 +{ + v0.x=v0.x-v1.x; + v0.y=v0.y-v1.y; + v0.z=v0.z-v1.z; + return v0; +} + +CVector operator *=(CVector &v0,CVector &v1)//*=运算符重载 +{ + v0.x=v0.x*v1.x; + v0.y=v0.y*v1.y; + v0.z=v0.z*v1.z; + return v0; +} + +CVector operator /=(CVector &v,double k)///=运算符重载 +{ + v.x=v.x/k; + v.y=v.y/k; + v.z=v.z/k; + return v; +} + +double Dot(const CVector &v0,const CVector &v1)//矢量的点积 +{ + return(v0.x*v1.x+v0.y*v1.y+v0.z*v1.z); +} + +CVector Cross(const CVector &v0,const CVector &v1)//矢量的叉积 +{ + CVector vector; + vector.x=v0.y*v1.z-v0.z*v1.y; + vector.y=v0.z*v1.x-v0.x*v1.z; + vector.z=v0.x*v1.y-v0.y*v1.x; + return vector; +} + diff --git a/Hidden-lineRemoval/Vector.h b/Hidden-lineRemoval/Vector.h new file mode 100644 index 0000000..1d43fd3 --- /dev/null +++ b/Hidden-lineRemoval/Vector.h @@ -0,0 +1,38 @@ +// Vector.h: interface for the CVector class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_VECTOR_H__8C972371_1C22_4E15_A2A8_3CE42319C9CB__INCLUDED_) +#define AFX_VECTOR_H__8C972371_1C22_4E15_A2A8_3CE42319C9CB__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include "P3.h" + +class CVector +{ +public: + CVector(); + virtual ~CVector(); + CVector(double,double,double); + CVector(const CP3 &); + CVector(const CP3 &,const CP3 &); + double Mag();//矢量的模 + CVector Normalize();//单位矢量 + friend CVector operator +(const CVector &,const CVector &);//运算符重载 + friend CVector operator -(const CVector &,const CVector &); + friend CVector operator *(const CVector &,double); + friend CVector operator *(double,const CVector &); + friend CVector operator /(const CVector &,double); + friend CVector operator+=(CVector &,CVector &); + friend CVector operator-=(CVector &,CVector &); + friend CVector operator*=(CVector &,CVector &); + friend CVector operator/=(CVector &,double); + friend double Dot(const CVector &,const CVector &); //矢量点积 + friend CVector Cross(const CVector &,const CVector &);//矢量叉积 +public: + double x,y,z;//公有数据成员,方便外部访问 +}; + +#endif // !defined(AFX_VECTOR_H__8C972371_1C22_4E15_A2A8_3CE42319C9CB__INCLUDED_) diff --git a/Hidden-lineRemoval/resource.h b/Hidden-lineRemoval/resource.h new file mode 100644 index 0000000..cc1fb3e --- /dev/null +++ b/Hidden-lineRemoval/resource.h @@ -0,0 +1,30 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by Test.rc +// +#define IDD_ABOUTBOX 100 +#define IDR_MAINFRAME 128 +#define IDR_TESTTYPE 129 +#define IDI_ICON1 130 +#define IDI_ICON2 131 +#define IDI_ICON3 132 +#define IDI_ICON4 133 +#define IDB_BITMAP1 134 +#define IDB_ABOUT 134 +#define IDI_ICON5 138 +#define IDB_BITMAP2 139 +#define IDI_ICON6 142 +#define ID_MENUPlay 32781 +#define IDM_PLAY 32783 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_3D_CONTROLS 1 +#define _APS_NEXT_RESOURCE_VALUE 147 +#define _APS_NEXT_COMMAND_VALUE 32784 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif