Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Быстрый алгоритм разделения и слияния при помощи мостиков / source / ConvexHull_1 / ConvexHullDoc
.cpp// ConvexHullDoc.cpp : implementation of the CConvexHullDoc class
//
#include "stdafx.h"
#include "ConvexHull.h"
#include "ConvexHullDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "TEdge.h"
UINT Stop(LPVOID pParam);
/////////////////////////////////////////////////////////////////////////////
// CConvexHullDoc
IMPLEMENT_DYNCREATE(CConvexHullDoc, CDocument)
BEGIN_MESSAGE_MAP(CConvexHullDoc, CDocument)
//{{AFX_MSG_MAP(CConvexHullDoc)
ON_COMMAND(ID_SSVERTICAL, OnSsvertical)
ON_COMMAND(ID_BUTTONPLAY, OnButtonplay)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CConvexHullDoc construction/destruction
CConvexHullDoc::CConvexHullDoc()
{
gen_info.count =10;
gen_info.max_x =150;
gen_info.max_y = 150;
gen_info.min_x =-150;
gen_info.min_y =-150;
Scene.push_back(&pointdata.UserPoints);
Scene.push_back(&IntermedPolygons);
Scene.push_back(&IntermedUpBriges);
Scene.push_back(&IntermedDownBriges);
Scene.push_back(&ResultPolygon);
InputData.push_back(&pointdata.UserPoints);
IntermedData.push_back(&IntermedPolygons);
IntermedData.push_back(&IntermedUpBriges);
IntermedData.push_back(&IntermedDownBriges);
OutputData.push_back(&ResultPolygon);
POSITION pos = GetFirstViewPosition();
Alg.SetDocument(this);
thread = NULL;
}
CConvexHullDoc::~CConvexHullDoc()
{
int i=0;
TRACE("InputData = %d\n",InputData.size() );
for (i=0;i<InputData.size();i++ ){
TGVector* tmp = InputData[i];
TRACE("TmpI = %d\n",tmp->size() );
for (int r=0;r<tmp->size();r++){
TPoint* point = (TPoint*)(*tmp)[r];
delete point;
}
}
TRACE("IntermedData = %d\n",IntermedData.size() );
for (i=0;i<IntermedData.size();i++ ){
TGVector* tmp = IntermedData[i];
//TRACE("TmpIndm = %d\n",tmp->size() );
for (int r=0;r<tmp->size();r++){
//TRACE("TYPE = %d\n",(*tmp)[r]->GetType() );
//TPolygon* poly = (TPolygon*)(*tmp)[r];
//delete poly;
//tmp->pop_back();
}
}
//TRACE("OutputData = %d\n",OutputData.size() );
for (i=0;i<OutputData.size();i++ ){
TGVector* tmp = OutputData[i];
//TRACE("TmpO = %d\n",tmp->size() );
for (int r=0;r<tmp->size();r++){
TPolygon* poly = (TPolygon*)(*tmp)[r];
poly->Destroy();
}
}
}
BOOL CConvexHullDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CConvexHullDoc serialization
void CConvexHullDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
}
else
{
//ar >> *InputData;
}
pointdata.Serialize(ar);
}
/////////////////////////////////////////////////////////////////////////////
// CConvexHullDoc diagnostics
#ifdef _DEBUG
void CConvexHullDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CConvexHullDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CConvexHullDoc commands
void CConvexHullDoc::OnSsvertical()
{
// TODO: Add your command handler code here
TRACE("\nFFDSFSD");
}
void CConvexHullDoc::OnButtonplay()
{
// TODO: Add your command handler code here
TRACE("PLAY in Doc\n");
}
void CConvexHullDoc::ClearMem()
{
int i=0;
for (i=0;i<InputData.size();i++ ){
TGVector* tmp = InputData[i];
for (int r=0;r<tmp->size();r++){
TPoint* point = (TPoint*)(*tmp)[r];
point->used = FALSE;
}
}
for (i=0;i<IntermedData.size();i++ ){
TGVector* tmp = IntermedData[i];
//TRACE("TmpIndm = %d\n",tmp->size() );
for (int r=0;r<tmp->size();r++){
//TRACE("TYPE = %d\n",(*tmp)[r]->GetType() );
}
}
//TRACE("OutputData = %d\n",OutputData.size() );
for (i=0;i<OutputData.size();i++ ){
TGVector* tmp = OutputData[i];
//TRACE("TmpO = %d\n",tmp->size() );
for (int r=0;r<tmp->size();r++){
TPolygon* poly = (TPolygon*)(*tmp)[r];
poly->Destroy();
}
}
IntermedUpBriges.clear();
IntermedPolygons.clear();
IntermedDownBriges.clear();
ResultPolygon.clear();
OutputData.clear();
InputData.clear();
IntermedData.clear();
Scene.clear();
Scene.push_back(&pointdata.UserPoints);
Scene.push_back(&IntermedPolygons);
Scene.push_back(&IntermedUpBriges);
Scene.push_back(&IntermedDownBriges);
Scene.push_back(&ResultPolygon);
InputData.push_back(&pointdata.UserPoints);
IntermedData.push_back(&IntermedPolygons);
IntermedData.push_back(&IntermedUpBriges);
IntermedData.push_back(&IntermedDownBriges);
OutputData.push_back(&ResultPolygon);
}
void CConvexHullDoc::OnCloseDocument()
{
// TODO: Add your specialized code here and/or call the base class
Alg.setRunMode(AT_ONCE);
Alg.g_eventContinue.SetEvent();
this->UpdateAllViews(NULL);
if (thread) {
TRACE("STUPID LEAK!\n");
//delete thread->;
}
else {
this->ClearMem();
}
CDocument::OnCloseDocument();
}
Соседние файлы в папке ConvexHull_1