// ConnectedComponent.h: interface for the CConnectedComponent class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_CONNECTEDCOMPONENT_H__9B57B146_A322_494E_AAA4_061102356BFC__INCLUDED_)
#define AFX_CONNECTEDCOMPONENT_H__9B57B146_A322_494E_AAA4_061102356BFC__INCLUDED_


#include <vector>
#include "ChipmonkTypes.h"

using namespace std;

class CConnectedComponent : public CRect{
	int m_nSize;
	BOOL m_bMatched;
	CPoint m_com; // centre of mass
	CConnectedComponent *m_pEqCC;
	
	void InitMembers();

public:
	CConnectedComponent();
	CConnectedComponent(int x, int y);
	virtual ~CConnectedComponent();
	int GetSize()const;
	void AddPoint(int nX, int nY);
	void Merge(CConnectedComponent *pCC);
	CPoint GetCom()const;
	const CConnectedComponent *GetEquivalent()const;
};


class CConnectedComponents : public vector<CConnectedComponent*> {
public:
	CConnectedComponents();
	virtual ~CConnectedComponents();
	int NewComponent(int nX, int nY);
	void Merge(int nIndx0, int nIndx1);
	void AddToComponent(int nCcIndx, short nX, short nY);
	void Clean();
};

void FindConnectedComponents(const UCHAR *pImg, int nWidth, int nHeight, CConnectedComponents & cc);

#endif // !defined(AFX_CONNECTEDCOMPONENT_H__9B57B146_A322_494E_AAA4_061102356BFC__INCLUDED_)
