Esempio n. 1
0
// Scans the map, finds the clusters, paints them
void ProcessMap() {
	Pt p ;
	int k, rotSym ;
	int nShapes = 0 ;
	char name = 'a' ;
	for( p.y = 0 ; p.y < size.y ; p.y++ )
		for( p.x = 0 ; p.x < size.x ; p.x++ ) {
			if( get(p) == '1' ) {
				minP = maxP = p ;
				nStars = 0 ;
				FirstFill(p, -1, name) ;
				for( k = 0 ; k < nShapes ; k++ )
					if( shapes[k].nStars == nStars
						&& Compare(p, shapes[k].start, name) ) {
					// Same shape
						shapes[k].num++ ;
						Fill(p, -1, shapes[k].name) ;
						goto next ;
					}
			// New shape
				shapes[nShapes].name = name ;
				shapes[nShapes].nStars = nStars ;
				shapes[nShapes].num = 1 ;
				for( rotSym = 0 ; rotSym < 8 ; rotSym++ )
					shapes[nShapes].start[rotSym] = StartPt(rotSym, name) ;
				nShapes++ ;
				name++ ;
			}
next: ; }
//	for( k = 0 ; k < nShapes ; k++ )
//		printf("%c = %d\n", shapes[k].name, shapes[k].num) ;
}
Esempio n. 2
0
BOOL Pipe::Pick(CRect rc)
{
	if(rc.PtInRect(StartPt()) && rc.PtInRect(EndPt()))
	{
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}
Esempio n. 3
0
void Pipe::MoveStartPt(ComponentManager *pManager,CPoint &Pt,CSize sz)
{
	CPoint centerPt;
	CRect rc;
	StartPt(Pt);
	Component *pComponent = NULL;
	Jun      *pJun = NULL;
	IteratorPtr<Component> JunItPtr(pManager->CreatJunIterator());
	for(JunItPtr->Fist();!JunItPtr->IsDone();JunItPtr->Next())
	{
		pComponent = &JunItPtr->CurrentItem();
		pJun = dynamic_cast<Jun*>(pComponent);
		centerPt = pJun->CenterPt();
		rc.SetRect(centerPt-sz,centerPt+sz);
		if(rc.PtInRect(Pt))
		{
			if(pJun->AddLinkPipe(-GetKey()))
			{
				StartPt(centerPt);
				StartJun(pJun->GetKey());
			}
		}
	}
}