| 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 | { | 
|---|
| 24 |  | 
|---|
| 25 | return (rect.t == t) && | 
|---|
| 26 | (rect.l == l) && | 
|---|
| 27 | (rect.b == b) && | 
|---|
| 28 | (rect.r == r); | 
|---|
| 29 |  | 
|---|
| 30 | } | 
|---|
| 31 |  | 
|---|
| 32 | /*****************************************************************************/ | 
|---|
| 33 |  | 
|---|
| 34 | bool dng_rect::IsZero () const | 
|---|
| 35 | { | 
|---|
| 36 |  | 
|---|
| 37 | return (t == 0) && (l == 0) && (b == 0) && (r == 0); | 
|---|
| 38 |  | 
|---|
| 39 | } | 
|---|
| 40 |  | 
|---|
| 41 | /*****************************************************************************/ | 
|---|
| 42 |  | 
|---|
| 43 | bool dng_rect_real64::operator== (const dng_rect_real64 &rect) const | 
|---|
| 44 | { | 
|---|
| 45 |  | 
|---|
| 46 | return (rect.t == t) && | 
|---|
| 47 | (rect.l == l) && | 
|---|
| 48 | (rect.b == b) && | 
|---|
| 49 | (rect.r == r); | 
|---|
| 50 |  | 
|---|
| 51 | } | 
|---|
| 52 |  | 
|---|
| 53 | /*****************************************************************************/ | 
|---|
| 54 |  | 
|---|
| 55 | bool dng_rect_real64::IsZero () const | 
|---|
| 56 | { | 
|---|
| 57 |  | 
|---|
| 58 | return (t == 0.0) && (l == 0.0) && (b == 0.0) && (r == 0.0); | 
|---|
| 59 |  | 
|---|
| 60 | } | 
|---|
| 61 |  | 
|---|
| 62 | /*****************************************************************************/ | 
|---|
| 63 |  | 
|---|
| 64 | dng_rect operator& (const dng_rect &a, | 
|---|
| 65 | const dng_rect &b) | 
|---|
| 66 | { | 
|---|
| 67 |  | 
|---|
| 68 | dng_rect c; | 
|---|
| 69 |  | 
|---|
| 70 | c.t = Max_int32 (a.t, b.t); | 
|---|
| 71 | c.l = Max_int32 (a.l, b.l); | 
|---|
| 72 |  | 
|---|
| 73 | c.b = Min_int32 (a.b, b.b); | 
|---|
| 74 | c.r = Min_int32 (a.r, b.r); | 
|---|
| 75 |  | 
|---|
| 76 | if (c.IsEmpty ()) | 
|---|
| 77 | { | 
|---|
| 78 |  | 
|---|
| 79 | c = dng_rect (); | 
|---|
| 80 |  | 
|---|
| 81 | } | 
|---|
| 82 |  | 
|---|
| 83 | return c; | 
|---|
| 84 |  | 
|---|
| 85 | } | 
|---|
| 86 |  | 
|---|
| 87 | /*****************************************************************************/ | 
|---|
| 88 |  | 
|---|
| 89 | dng_rect operator| (const dng_rect &a, | 
|---|
| 90 | const dng_rect &b) | 
|---|
| 91 | { | 
|---|
| 92 |  | 
|---|
| 93 | if (a.IsEmpty ()) | 
|---|
| 94 | { | 
|---|
| 95 | return b; | 
|---|
| 96 | } | 
|---|
| 97 |  | 
|---|
| 98 | if (b.IsEmpty ()) | 
|---|
| 99 | { | 
|---|
| 100 | return a; | 
|---|
| 101 | } | 
|---|
| 102 |  | 
|---|
| 103 | dng_rect c; | 
|---|
| 104 |  | 
|---|
| 105 | c.t = Min_int32 (a.t, b.t); | 
|---|
| 106 | c.l = Min_int32 (a.l, b.l); | 
|---|
| 107 |  | 
|---|
| 108 | c.b = Max_int32 (a.b, b.b); | 
|---|
| 109 | c.r = Max_int32 (a.r, b.r); | 
|---|
| 110 |  | 
|---|
| 111 | return c; | 
|---|
| 112 |  | 
|---|
| 113 | } | 
|---|
| 114 |  | 
|---|
| 115 | /*****************************************************************************/ | 
|---|
| 116 |  | 
|---|
| 117 | dng_rect_real64 operator& (const dng_rect_real64 &a, | 
|---|
| 118 | const dng_rect_real64 &b) | 
|---|
| 119 | { | 
|---|
| 120 |  | 
|---|
| 121 | dng_rect_real64 c; | 
|---|
| 122 |  | 
|---|
| 123 | c.t = Max_real64 (a.t, b.t); | 
|---|
| 124 | c.l = Max_real64 (a.l, b.l); | 
|---|
| 125 |  | 
|---|
| 126 | c.b = Min_real64 (a.b, b.b); | 
|---|
| 127 | c.r = Min_real64 (a.r, b.r); | 
|---|
| 128 |  | 
|---|
| 129 | if (c.IsEmpty ()) | 
|---|
| 130 | { | 
|---|
| 131 |  | 
|---|
| 132 | c = dng_rect_real64 (); | 
|---|
| 133 |  | 
|---|
| 134 | } | 
|---|
| 135 |  | 
|---|
| 136 | return c; | 
|---|
| 137 |  | 
|---|
| 138 | } | 
|---|
| 139 |  | 
|---|
| 140 | /*****************************************************************************/ | 
|---|
| 141 |  | 
|---|
| 142 | dng_rect_real64 operator| (const dng_rect_real64 &a, | 
|---|
| 143 | const dng_rect_real64 &b) | 
|---|
| 144 | { | 
|---|
| 145 |  | 
|---|
| 146 | if (a.IsEmpty ()) | 
|---|
| 147 | { | 
|---|
| 148 | return b; | 
|---|
| 149 | } | 
|---|
| 150 |  | 
|---|
| 151 | if (b.IsEmpty ()) | 
|---|
| 152 | { | 
|---|
| 153 | return a; | 
|---|
| 154 | } | 
|---|
| 155 |  | 
|---|
| 156 | dng_rect_real64 c; | 
|---|
| 157 |  | 
|---|
| 158 | c.t = Min_real64 (a.t, b.t); | 
|---|
| 159 | c.l = Min_real64 (a.l, b.l); | 
|---|
| 160 |  | 
|---|
| 161 | c.b = Max_real64 (a.b, b.b); | 
|---|
| 162 | c.r = Max_real64 (a.r, b.r); | 
|---|
| 163 |  | 
|---|
| 164 | return c; | 
|---|
| 165 |  | 
|---|
| 166 | } | 
|---|
| 167 |  | 
|---|
| 168 | /*****************************************************************************/ | 
|---|
| 169 |  | 
|---|