Скачиваний:
14
Добавлен:
01.05.2014
Размер:
2.23 Кб
Скачать
namespace SubsidiaryClasses
{
/** Точка */
class TPoint
{
private:
	int m_iX;
	int m_iY;
	int m_iID;
public:
	TPoint();
	TPoint(int id,int x, int y)
	{
		m_iID = id;
		m_iX = x;
		m_iY = y;
		
	};

	TPoint(TPoint &p)
	{
		m_iID = p.getID();
		m_iX = p.getX();
		m_iY = p.getY();		
	};

	~TPoint()
	{
	};

	friend bool operator== (const TPoint &a,const TPoint &b)
	{
		return (a.m_iID == b.m_iID);
	}

	friend bool operator!= (const TPoint &a,const TPoint &b)
	{
		return (a.m_iID != b.m_iID);
	}

	friend bool operator> (const TPoint &a,const TPoint &b)
	{
		return (a.m_iID > b.m_iID);
	}
	
	friend bool operator< (const TPoint &a,const TPoint &b)
	{
		return (a.m_iID < b.m_iID);
	}

	void setX(int x);
	void setY(int y);
	void setID(int id);
	int getX();
	int getY();
	int getID();
};


/** Линия */
struct CLine { 
	CPoint p1;
	CPoint p2;
};


/** Класс дерево - для реализации пошагового режима*/
class TTree {
	double prioritet;
public:
	TPoint *val;
	TTree *parent;
	TTree *lchild;
	TTree *rchild;
	TTree *next;
	TTree *prev;
	TTree *minimum()
	{	TTree *m=this;			
		while(m->lchild) 
			m=m->lchild;
		return m;
	}

	TTree *maximum()
	{	
		TTree *m=this;			
		while(m->rchild) 
			m=m->rchild;
		return m;
	}
	
	TPoint *getVal()
	{	return val;}

	double priority()
	{	return prioritet;}

	void priority(double prior)
	{	prioritet = prior;}

	int depthOfTree(TTree *uz, int count, int tmp_count)
	{
		if (uz != NULL)
		{
			tmp_count++;
			if (uz->lchild !=NULL)
				count = depthOfTree(uz->lchild, count, tmp_count);
			if (uz->rchild !=NULL)
				count = depthOfTree(uz->rchild, count, tmp_count);
		}
		if (tmp_count > count)
			count = tmp_count;
		tmp_count--;
		return count;
	}

	//Возвращает глубину дерева
	int depthOfTree(TTree *tt)
	{	if (!tt) return -1; 
		return depthOfTree(tt, 0, 0);
	}
};

/** Структура для сохранения последовательности шагов */
class StepStruct {
public:
	StepStruct();
	StepStruct(TTree *R,TTree *Sel,int Sit,int St)
	{
		root=R;
		seltree=Sel;
		situation=Sit;
		stage=St;
	}
	TTree * root;
	TTree * seltree;
	int		situation;
	int		stage;
};

}
Соседние файлы в папке Source