-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangleTest.cpp
More file actions
94 lines (79 loc) · 2.3 KB
/
Copy pathRectangleTest.cpp
File metadata and controls
94 lines (79 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "myheader.h"
#include "groundtruth.h"
#include "ui_groundtruth.h"
/*------------------------------------------------------------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------------------------------*/
/**
* @Function: PointRectangleTest
* @brief : Take 1 rectangle and a Point as input
* @brief : Test whether the Given Point is inside the Given Rectangle or Inside
* @return : 0: Point is Outside of Rectangle
* 1: Point is inside the given Rectangle
* */
int IITkgp_functions::RectangleTest::PointRectangleTest(Rect GivenRect, Point GivenPoint)
{
Point tl,br;
tl = GivenRect.tl();
br = GivenRect.br();
int flag;
/*
if((GivenPoint.x>=tl.x && GivenPoint.x<=br.x) && (GivenPoint.y<=tl.y && GivenPoint.y>=br.y))
{
flag = 1;
printf("point inside\n");
return(flag);
}
*/
if((GivenPoint.x>=tl.x && GivenPoint.x<=br.x) && (GivenPoint.y>=tl.y && GivenPoint.y<=br.y))
{
flag = 1;
//printf("point inside\n");
return(flag);
}
else
{
flag = 0;
return(flag);
}
}
/**
* @Function: FindOverlappingRectangles
* @brief : Take 2 rectangle as an input
* @return : 0: Rect 1 and Rect 2 are disjoint
* 1: Rect 1 is inside Rect 2
* 2: Rect 2 is inside Rect 1
* 3: Rect 1 and 2 are partly overlapped
*
*
* */
int IITkgp_functions::RectangleTest::FindOverlappingRectangles(Rect first, Rect second)
{
Point tl1,tl2,br1,br2;
int flag;
tl1 = first.tl();
tl2 = second.tl();
br1 = first.br();
br2 = second.br();
if(PointRectangleTest(first,tl2) == 0 && PointRectangleTest(first,br2) == 0)
{
flag = 0;
//return (flag);
}
if(PointRectangleTest(first,tl2) == 1 || PointRectangleTest(first,br2) ==1 || PointRectangleTest(second,tl1) == 1 || PointRectangleTest(second,br1) == 1)
{
flag = 3;
//return (flag);
}
if(PointRectangleTest(first,tl2) == 1 && PointRectangleTest(first,br2) == 1)
{
flag = 2;
//return (flag);
}
if(PointRectangleTest(second,tl1) == 1 && PointRectangleTest(second,br1) == 1)
{
flag = 1;
//return (flag);
}
return (flag);
}
/*-------------------------------------------------------------------------------------------------------------------------------------------*/