|
#pragma once
//----------------------------------------------------------------------------//
//�����㷨��
//----------------------------------------------------------------------------//
namespace mycell{
//����lprc1,lprc2�Ƿ��ڽ�
inline BOOL rect_adjoin(LPCRECT lprc1,LPCRECT lprc2)
{
return (lprc1->right==lprc2->left || lprc1->left==lprc2->right)
&& lprc1->bottom>=lprc2->top
&& lprc1->top<=lprc2->bottom
|| (lprc1->bottom==lprc2->top || lprc1->top==lprc2->bottom)
&& lprc1->right>=lprc2->left
&& lprc1->left<=lprc2->right;
}
//�������Ƿ����
inline BOOL rect_equal(LPCRECT lprc1,LPCRECT lprc2)
{
return lprc1->left==lprc2->left
&& lprc1->right==lprc2->right
&& lprc1->top==lprc2->top
&& lprc1->bottom==lprc2->bottom;
}
//�������Ƿ����루û���ص����֣�
inline BOOL rect_disjoin(LPCRECT lprc1,LPCRECT lprc2)
{
return lprc1->left > lprc2->right
|| lprc1->right< lprc2->left
|| lprc1->top > lprc2->bottom
|| lprc1->bottom<lprc2->top;
}
//����lprc1�Ƿ���lprc2���ڲ�
inline BOOL rect_internal(LPCRECT lprc1,LPCRECT lprc2)
{
return lprc1->left>=lprc2->left && lprc1->right<=lprc2->right
&& lprc1->top>=lprc2->top && lprc1->bottom<=lprc2->bottom;
}
//����lprc1�Ƿ����lprc2
inline BOOL rect_contain(LPCRECT lprc1,LPCRECT lprc2)
{
return rect_internal(lprc2,lprc1);
//return lprc1->left<=lprc2->left && lprc1->right>=lprc2->right
// && lprc1->top<=lprc2->top && lprc1->bottom>=lprc2->bottom;
}
//��Կ�����ཻ���п�������RRS_EUQAL,RRS_CONTAIN,RRS_INTERNAL
inline BOOL intersect(LPCRECT lprc1,LPCRECT lprc2)
{
return !(
lprc1->left >= lprc2->right
|| lprc1->right <= lprc2->left
|| lprc1->top >= lprc2->bottom
|| lprc1->bottom <= lprc2->top);
}
inline eRectRelationShip get_RectRelationShip(LPCRECT lprc1,LPCRECT lprc2)
{
if(rect_equal(lprc1,lprc2))
return RRS_EQUAL;
if(rect_disjoin(lprc1,lprc2))
return RRS_DISJOIN;
if(rect_internal(lprc1,lprc2))
return RRS_INTERNAL;
if(rect_contain(lprc1,lprc2))
return RRS_CONTAIN;
return RRS_INTERSECT;
}
}//namespace mycell
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
My name is Yanxueming,i live in Chengdu China.Graduated from UESTC in 1999.