1- Thiết kế giao diện thực hiện test các quan hệ hình học:
2 - Thiết kế giao diện cho quá trình thực hiện những ứng dụng trong việc test các quan hệ hình học, cập nhật các thơng số về kích thước vùng Client:
CMainFrame tạo màn hình vùng Client.
CApp thực hiện ứng dụng kiểu đơn tài liệu (SDI).
CView hiện thị những hiện thực cuả chương trình test quan hệ
hình học (cập nhật lại vùng Client).
CDoc xử lý lưu trữ dữ liệu.
CDIALOG nhập, xuất dữ kiện.
2- Một số kiểu dữ liệu được dùng trong chương trình:
Các đỉnh của đa giác P phẳng được lưu lần lượt trong danh sách kiểu CPoint như P[0].x, P[0].y; P[1].x,P[1].y; …. Với đỉnh cuối được nhận biết bởi chỉ số đa giác kèm theo.
Kiểu dữ liệu điểm trong ba chiều typedef struct { long x; long y; long z; } point3d ;
Cấu trúc dữ liệu mơ tả Wireframe gồm: +Danh sách đỉnh chứa tọa độ các đỉnh
+Danh sách cạnh chứa các cặp đỉnh nối cạnh đĩ. typedef struct { int NumV; int NumE; point3d vert[20]; int edge[30][2]; } Wireframe;
Kiểu dữ liệu dùng tạo danh sách cạnh từ các đỉnh liên tiếp. typedef struct
{
CPoint A; CPoint B; } TypeListEdge;
Kiểu dữ liệu lưu các điểm, cĩ kèm cờ để phân biệt các loại điểm khác nhau (điểm giao nhau giữa 2 đa giác, điểm này đã được duyệt hay chưa duyệt; hay đỉnh của đa giác) được dùng trong thủ tục kiểm tra quan hệ hai đa giác.
typedef struct {
int CFlag; } ListPoint;
3 – Tổ chức hàm:
Các hàm nêu ra dưới đây được nhĩm lại thành các nhĩm giúp cho việc theo dõi được dễ dàng hơn
- Những hàm được viết trong TestHHView.cpp // Construction/destruction lớp CView
CTestHHView:: CTestHHView() CTestHHView:: ~CTestHHView()
// Hàm tạo cửa sổ ,vẽ của lớp CView BOOL
CTestHHView::PreCreateWindow(CREATESTRUCT& cs)void CTestHHView:: OnDraw(CDC* pDC)// Debug
void CTestHHView::AssertValid() const
void CTestHHView::Dump(CDumpContext& dc) const CTestHHDoc* CTestHHView::GetDocument()
// Hàm phục vụ vẽ 2Dvoid CTestHHView::OnPoint() void CTestHHView::OnUpdatePoint(CCmdUI* pCmdUI) void CTestHHView::OnLine1()
void CTestHHView::OnUpdateLine1(CCmdUI* pCmdUI) void CTestHHView::OnLine2()
void CTestHHView::OnUpdateLine2(CCmdUI* pCmdUI) void CTestHHView::OnPolyline()
void CTestHHView::OnUpdatePolyline(CCmdUI* pCmdUI) void CTestHHView::OnPolyline2()
void CTestHHView::OnUpdatePolyline2(CCmdUI* pCmdUI)
// Hàm liên quan đến mousevoid CTestHHView::OnLButtonDown(UINT nFlags, CPoint point) void CTestHHView::OnLButtonUp(UINT nFlags, CPoint point) void CTestHHView::OnRButtonDown(UINT nFlags, CPoint point)
/// Tính Max ,Min của 2 giá trịint Max(int x,int y)int Min(int x,int y)// Test điểm P trong / ngồi đa giác
void SwapTwoPoints(CPoint &A,CPoint &B)
BOOL TestPoint_Boundary (CPoint P,UINT n,CPoint dayP[]) BOOL Giaodiem(CPoint P,UINT n,CPoint dayP[])
void CTestHHView::OnTestpoint()
// Các hàm dùng test quan hệ giữa 2 đường thẳng void CTestHHView::OnGoc()
double LengthOfASegment(CPoint A,CPoint B) void CTestHHView::OnChieu()
UINT Intersect(CPoint A,CPoint B,CPoint C,CPoint D,CPoint &M) void CTestHHView::OnLinesegment()
// Test quan hệ đoạn thẳng -đa giácvoid Trungdiem(CPoint A,CPoint B,CPoint &TDiem)
void ClippingLine(CPoint A,CPoint B,UINT nDinh,CPoint DGiac[], CPoint DsachDcat[],UINT &SoDcat) void CTestHHView::OnClipLinePolyline()
// Test Da giac loi-lom
long ToadoK(CPoint A,CPoint B)
void CTestHHView::OnTestConvexPolygon() // Tính diện tích đa giác
void CTestHHView::OnCalcPolygonArea() // Nhĩm hàm liên quan tới phép chiếu
void initProject (double &t1,double &t2,double &t3, double &t4, double &t5 , double &t6, double &t7, double &t8, float xRot, float yRot)
void Project(BOOL PhepChieu ,float xRot,float yRot, Wireframe &WF) void CTestHHView::OnProjectionPerspective()
void CTestHHView::OnUpdateProjectionPerspective(CCmdUI* pCmdUI) void CTestHHView::OnProjectionParallel()
void CTestHHView::OnUpdateProjectionParallel(CCmdUI* pCmdUI) // Hình lăng trụ
void CTestHHView::OnTool3dHeightofPrism() void CTestHHView::OnWiframe()
void CTestHHView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) // Hình chĩp
void CTestHHView::OnTool3dTopPyramide() void CTestHHView::OnPyramide()
// Hình nĩn
void CTestHHView::OnTool3d_InputCone()
void CTestHHView::OnCone() // Test đa giác đồng phẳng void CTestHHView::OnNhapDagiac()
void CTestHHView::OnPlanarity() //Tơ màu đa giác
void CTestHHView::OnFillingPolygon() // Test quan hệ giữa 2 đa giác /// Tìm 1 điểm cĩ trong 1 DSach khơng,trả về vị trí điểm được tìm thấyUINT
LookingPointInsideList( CPoint P, ListPoint List[], UINT IndexList) /// Duyệt danh sách ListSub và ListClip
void Traverse( ListPointListSub[], ListPointListClip[], UINT IndexListSub, UINT IndexListClip, CPoint DaGiac[], UINT &CSoDGiac, UINT &Arrow)
void AddToList(ListPoint ListSub[],UINT &IndexListSub,CPoint A) ///Di chuyển vị trí 1 ra sau Danh sach
void Transfer(ListPoint DSach[], UINT CSoDSach) /// Kiểm tra vị trí đầu của DSach cĩ ngồi Polygon khơng
BOOL CheckFirstPosition(ListPoint ListSub[], UINT IndexListSub, CPoint DayP[], UINT n)
long Area_Of_Intersection(CPoint DaGiac[], UINT CSoDGiac) void CTestHHView::OnWeilerAthertonClipping()
// Thể tích hình lăng trụ, hình chĩp, hình nĩn void CTestHHView::OnVolumeOfPrism() void CTestHHView::OnVolumeOfPyramide() void CTestHHView::OnVolumeOfCone()
CTestHHDoc::CTestHHDoc() CTestHHDoc::~CTestHHDoc()
BOOL CTestHHDoc::OnNewDocument() void CTestHHDoc::Serialize(CArchive& ar)