int DatapathGElementOutput::adjustL2(SDL_Line* l2, std::set<SDL_Line*>& hvals){

	int diff = 0;
	bool overlap = false;

	do{
		l2->end.y   -= diff;
		l2->start.y -= diff;

		for(auto it = hvals.begin() ; it != hvals.end(); ++it){
			SDL_Line* l_ = *it;
			overlap = isOverLap(l2,l_);
			if(overlap) break;
		}
		diff+= 3;
	}while(overlap&&(l2->start.y > l2->prev->start.y));

	if(!overlap) {
		l2->prev->end.y = l2->start.y;
		l2->next->start.y =l2->start.y;
		return 1;
	}
	else{
		printf("adjustL2 failed !\n");
		exit(0);
	}
}
int DatapathGElementOutput::adjustL1(SDL_Line* l1, std::set<SDL_Line*>& vlines){

	int diff = 0;
	bool overlap = false;

	do{
		l1->end.y -= diff;
		if(l1->end.y < l1->start.y)  break;
		for(auto it = vlines.begin() ; it != vlines.end(); ++it){
			SDL_Line* l_ = *it;
			overlap = isOverLap(l1,l_);
			if(overlap) break;
		}
		diff+= 3;


	}while(overlap);

	//printf("l1.end.y %d, l1.start.y %d \n",l1->end.y,l1->start.y);
	if(!overlap) {
		l1->next->start.y = l1->end.y;
		l1->next->end.y   = l1->end.y;
		l1->next->next->start.y = l1->end.y;
		return 1;
	}
	else{
		printf("adjustL1 failed !\n");
		exit(0);
	}
}
int DatapathGElementOutput::adjustL4(SDL_Line* l4, const int lowerbound, std::set<SDL_Line*>& hlines){

	int diff = 0;
	bool overlap = true;
	int ytmp = l4->start.y;

	do{
		l4->start.y =ytmp;
		l4->end.y   =ytmp;
		l4->start.y +=diff;
		l4->end.y   +=diff;
		for(auto it = hlines.begin();it!=hlines.end() ;++it){
			SDL_Line* l = *it;
			overlap = isOverLap(l4,l);
			if(overlap) break;
		}

		l4->start.y =ytmp;
		l4->end.y   =ytmp;
		l4->start.y -=diff;
		l4->end.y   -=diff;
		for(auto it = hlines.begin();it!=hlines.end() ;++it){
			SDL_Line* l = *it;
			overlap = isOverLap(l4,l);
			if(overlap) break;
		}
		diff+= 3;
	}while(overlap && (l4->start.y < lowerbound));

	if(!overlap){
		l4->next->start.y =	l4->end.y ;
		l4->prev->end.y   = l4->start.y;
		return 1;
	}
	else{
		{
			printf("adjustL4 failed !\n");
			exit(0);
		}
	}
}
int DatapathGElementOutput::adjustL3(SDL_Line* l3, std::set<SDL_Line*>& vlines, bool left){

	int diff = 0;
	bool overlap = false;
	int xtmp = l3->start.x;
	do{
		l3->start.x = xtmp;
		l3->end.x = xtmp;

		if(left){
			l3->start.x -= diff;
			l3->end.x   -= diff;
		}
		else{
			l3->start.x += diff;
			l3->end.x   += diff;
		}

		for(auto it = vlines.begin() ; it != vlines.end(); ++it){
			SDL_Line* l_ = *it;
			overlap = isOverLap(l3,l_);
			if(overlap) break;
		}
		diff+= 6;
	}while(overlap);

	if(!overlap) {
		l3->next->start.x =l3->start.x ;
		l3->prev->end.x  = l3->start.x ;
		return 1;
	}
	else{
		printf("adjustL3 failed !\n");
		exit(0);
	}
}
Esempio n. 5
0
bool sageRect::isOverLap(sageRect &rect)
{
   sageRect dummy;
   return isOverLap(rect, dummy);
}