/src/dng_sdk/source/dng_rect.cpp
Line | Count | Source |
1 | | /*****************************************************************************/ |
2 | | // Copyright 2006-2007 Adobe Systems Incorporated |
3 | | // All Rights Reserved. |
4 | | // |
5 | | // NOTICE: Adobe permits you to use, modify, and distribute this file in |
6 | | // accordance with the terms of the Adobe license agreement accompanying it. |
7 | | /*****************************************************************************/ |
8 | | |
9 | | /* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_rect.cpp#1 $ */ |
10 | | /* $DateTime: 2012/05/30 13:28:51 $ */ |
11 | | /* $Change: 832332 $ */ |
12 | | /* $Author: tknoll $ */ |
13 | | |
14 | | /*****************************************************************************/ |
15 | | |
16 | | #include "dng_rect.h" |
17 | | |
18 | | #include "dng_utils.h" |
19 | | |
20 | | /*****************************************************************************/ |
21 | | |
22 | | bool dng_rect::operator== (const dng_rect &rect) const |
23 | 7.35M | { |
24 | | |
25 | 7.35M | return (rect.t == t) && |
26 | 6.17M | (rect.l == l) && |
27 | 6.05M | (rect.b == b) && |
28 | 5.88M | (rect.r == r); |
29 | | |
30 | 7.35M | } |
31 | | |
32 | | /*****************************************************************************/ |
33 | | |
34 | | bool dng_rect::IsZero () const |
35 | 352k | { |
36 | | |
37 | 352k | return (t == 0) && (l == 0) && (b == 0) && (r == 0); |
38 | | |
39 | 352k | } |
40 | | |
41 | | /*****************************************************************************/ |
42 | | |
43 | | bool dng_rect_real64::operator== (const dng_rect_real64 &rect) const |
44 | 0 | { |
45 | | |
46 | 0 | return (rect.t == t) && |
47 | 0 | (rect.l == l) && |
48 | 0 | (rect.b == b) && |
49 | 0 | (rect.r == r); |
50 | | |
51 | 0 | } |
52 | | |
53 | | /*****************************************************************************/ |
54 | | |
55 | | bool dng_rect_real64::IsZero () const |
56 | 0 | { |
57 | |
|
58 | 0 | return (t == 0.0) && (l == 0.0) && (b == 0.0) && (r == 0.0); |
59 | |
|
60 | 0 | } |
61 | | |
62 | | /*****************************************************************************/ |
63 | | |
64 | | dng_rect operator& (const dng_rect &a, |
65 | | const dng_rect &b) |
66 | 33.5M | { |
67 | | |
68 | 33.5M | dng_rect c; |
69 | | |
70 | 33.5M | c.t = Max_int32 (a.t, b.t); |
71 | 33.5M | c.l = Max_int32 (a.l, b.l); |
72 | | |
73 | 33.5M | c.b = Min_int32 (a.b, b.b); |
74 | 33.5M | c.r = Min_int32 (a.r, b.r); |
75 | | |
76 | 33.5M | if (c.IsEmpty ()) |
77 | 7.68M | { |
78 | | |
79 | 7.68M | c = dng_rect (); |
80 | | |
81 | 7.68M | } |
82 | | |
83 | 33.5M | return c; |
84 | | |
85 | 33.5M | } |
86 | | |
87 | | /*****************************************************************************/ |
88 | | |
89 | | dng_rect operator| (const dng_rect &a, |
90 | | const dng_rect &b) |
91 | 0 | { |
92 | | |
93 | 0 | if (a.IsEmpty ()) |
94 | 0 | { |
95 | 0 | return b; |
96 | 0 | } |
97 | | |
98 | 0 | if (b.IsEmpty ()) |
99 | 0 | { |
100 | 0 | return a; |
101 | 0 | } |
102 | | |
103 | 0 | dng_rect c; |
104 | | |
105 | 0 | c.t = Min_int32 (a.t, b.t); |
106 | 0 | c.l = Min_int32 (a.l, b.l); |
107 | | |
108 | 0 | c.b = Max_int32 (a.b, b.b); |
109 | 0 | c.r = Max_int32 (a.r, b.r); |
110 | | |
111 | 0 | return c; |
112 | | |
113 | 0 | } |
114 | | |
115 | | /*****************************************************************************/ |
116 | | |
117 | | dng_rect_real64 operator& (const dng_rect_real64 &a, |
118 | | const dng_rect_real64 &b) |
119 | 0 | { |
120 | | |
121 | 0 | dng_rect_real64 c; |
122 | | |
123 | 0 | c.t = Max_real64 (a.t, b.t); |
124 | 0 | c.l = Max_real64 (a.l, b.l); |
125 | | |
126 | 0 | c.b = Min_real64 (a.b, b.b); |
127 | 0 | c.r = Min_real64 (a.r, b.r); |
128 | | |
129 | 0 | if (c.IsEmpty ()) |
130 | 0 | { |
131 | | |
132 | 0 | c = dng_rect_real64 (); |
133 | | |
134 | 0 | } |
135 | | |
136 | 0 | return c; |
137 | | |
138 | 0 | } |
139 | | |
140 | | /*****************************************************************************/ |
141 | | |
142 | | dng_rect_real64 operator| (const dng_rect_real64 &a, |
143 | | const dng_rect_real64 &b) |
144 | 0 | { |
145 | | |
146 | 0 | if (a.IsEmpty ()) |
147 | 0 | { |
148 | 0 | return b; |
149 | 0 | } |
150 | | |
151 | 0 | if (b.IsEmpty ()) |
152 | 0 | { |
153 | 0 | return a; |
154 | 0 | } |
155 | | |
156 | 0 | dng_rect_real64 c; |
157 | | |
158 | 0 | c.t = Min_real64 (a.t, b.t); |
159 | 0 | c.l = Min_real64 (a.l, b.l); |
160 | | |
161 | 0 | c.b = Max_real64 (a.b, b.b); |
162 | 0 | c.r = Max_real64 (a.r, b.r); |
163 | | |
164 | 0 | return c; |
165 | | |
166 | 0 | } |
167 | | |
168 | | /*****************************************************************************/ |