forked from juj/RectangleBinPack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rect.cpp
51 lines (41 loc) · 1.06 KB
/
Rect.cpp
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
/** @file Rect.cpp
@author Jukka Jylänki
This work is released to Public Domain, do whatever you want with it.
*/
#include <utility>
#include "Rect.h"
namespace rbp {
/*
#include "clb/Algorithm/Sort.h"
int CompareRectShortSide(const Rect &a, const Rect &b)
{
using namespace std;
int smallerSideA = min(a.width, a.height);
int smallerSideB = min(b.width, b.height);
if (smallerSideA != smallerSideB)
return clb::sort::TriCmp(smallerSideA, smallerSideB);
// Tie-break on the larger side.
int largerSideA = max(a.width, a.height);
int largerSideB = max(b.width, b.height);
return clb::sort::TriCmp(largerSideA, largerSideB);
}
*/
/*
int NodeSortCmp(const Rect &a, const Rect &b)
{
if (a.x != b.x)
return clb::sort::TriCmp(a.x, b.x);
if (a.y != b.y)
return clb::sort::TriCmp(a.y, b.y);
if (a.width != b.width)
return clb::sort::TriCmp(a.width, b.width);
return clb::sort::TriCmp(a.height, b.height);
}
*/
bool IsContainedIn(const Rect &a, const Rect &b)
{
return a.x >= b.x && a.y >= b.y
&& a.x+a.width <= b.x+b.width
&& a.y+a.height <= b.y+b.height;
}
}