Скачиваний:
10
Добавлен:
01.05.2014
Размер:
2.04 Кб
Скачать
#ifndef CPP007
#define CPP007

#include "cTrOnBoard.h"


cTrOnBoard::cTrOnBoard()  //constructor                  
{
 First=NULL;
 cPoint P(0,0);
 double R = 1;
 Set(P,R);
}

cTrOnBoard::cTrOnBoard(cPoint P, double R)               //constructor                  
{
 First=NULL;
 Set(P,R);
}

int cTrOnBoard::Correct(cColTriangle T) //check triangle               
{
 int A =
// ((T.GetTop(0)).Distance(GetX(),GetY()) <= GetStor() + 0.01) &&
// ((T.GetTop(1)).Distance(GetX(),GetY()) <= GetStor() + 0.01) &&
// ((T.GetTop(2)).Distance(GetX(),GetY()) <= GetStor() + 0.01);
 ((T.GetTop(0)).GetX() >= GetX()) && ((T.GetTop(0)).GetX() <= GetX()+GetStor()) && ((T.GetTop(0)).GetY() <= GetY()) && ((T.GetTop(0)).GetY() >= GetY()-GetStor()) && 
 ((T.GetTop(1)).GetX() >= GetX()) && ((T.GetTop(1)).GetX() <= GetX()+GetStor()) && ((T.GetTop(1)).GetY() <= GetY()) && ((T.GetTop(1)).GetY() >= GetY()-GetStor()) &&
 ((T.GetTop(2)).GetX() >= GetX()) && ((T.GetTop(2)).GetX() <= GetX()+GetStor()) && ((T.GetTop(2)).GetY() <= GetY()) && ((T.GetTop(2)).GetY() >= GetY()-GetStor());
 return A;
}

void cTrOnBoard::addontable(cColTriangle T) //add triangle if corret       
{
 if (Correct(T))
   add(T);
}

void cTrOnBoard::reform()  //delete incorect triangles    
{
 tobegin();
 cColTriangle T;
 if (!Empty())
 while ((*current).GetNext() != First)
 {
  GetInf(T);
  if (Correct(T))
    move();
  else
   del();
 };
 if (!Empty())
 {
  GetInf(T);
  if (!Correct(T))
   del();
 };
 tobegin();
}

void cTrOnBoard::SetNewCenter(cPoint P)  //center modification + reform 
{
 SetCenter(P);
 reform();
}

void cTrOnBoard::SetNewStor(double R) //Stor modification + reform 
{
 SetStor(R);
 reform();
}

void cTrOnBoard::boardout()  //out list on screen           
{
 cout<<"The map-board center: ";
 cPoint P(GetX(),GetY());
 P.out();
 cout<<endl<<"The map-board Stor: "<<GetStor()<<endl<<endl;
 out();
}

cTrOnBoard::~cTrOnBoard(){}  //destructor                   


#endif
Соседние файлы в папке Лабораторная работа 32