File indexing completed on 2025-01-19 03:55:13
0001 /*****************************************************************************/ 0002 // Copyright 2006-2019 Adobe Systems Incorporated 0003 // All Rights Reserved. 0004 // 0005 // NOTICE: Adobe permits you to use, modify, and distribute this file in 0006 // accordance with the terms of the Adobe license agreement accompanying it. 0007 /*****************************************************************************/ 0008 0009 #include "dng_rect.h" 0010 0011 #include "dng_utils.h" 0012 0013 /*****************************************************************************/ 0014 0015 bool dng_rect::operator== (const dng_rect &rect) const 0016 { 0017 0018 return (rect.t == t) && 0019 (rect.l == l) && 0020 (rect.b == b) && 0021 (rect.r == r); 0022 0023 } 0024 0025 /*****************************************************************************/ 0026 0027 bool dng_rect::IsZero () const 0028 { 0029 0030 return (t == 0) && (l == 0) && (b == 0) && (r == 0); 0031 0032 } 0033 0034 /*****************************************************************************/ 0035 0036 bool dng_rect_real64::operator== (const dng_rect_real64 &rect) const 0037 { 0038 0039 return (rect.t == t) && 0040 (rect.l == l) && 0041 (rect.b == b) && 0042 (rect.r == r); 0043 0044 } 0045 0046 /*****************************************************************************/ 0047 0048 bool dng_rect_real64::IsZero () const 0049 { 0050 0051 return (t == 0.0) && (l == 0.0) && (b == 0.0) && (r == 0.0); 0052 0053 } 0054 0055 /*****************************************************************************/ 0056 0057 dng_rect operator& (const dng_rect &a, 0058 const dng_rect &b) 0059 { 0060 0061 dng_rect c; 0062 0063 c.t = Max_int32 (a.t, b.t); 0064 c.l = Max_int32 (a.l, b.l); 0065 0066 c.b = Min_int32 (a.b, b.b); 0067 c.r = Min_int32 (a.r, b.r); 0068 0069 if (c.IsEmpty ()) 0070 { 0071 0072 c = dng_rect (); 0073 0074 } 0075 0076 return c; 0077 0078 } 0079 0080 /*****************************************************************************/ 0081 0082 dng_rect operator| (const dng_rect &a, 0083 const dng_rect &b) 0084 { 0085 0086 if (a.IsEmpty ()) 0087 { 0088 return b; 0089 } 0090 0091 if (b.IsEmpty ()) 0092 { 0093 return a; 0094 } 0095 0096 dng_rect c; 0097 0098 c.t = Min_int32 (a.t, b.t); 0099 c.l = Min_int32 (a.l, b.l); 0100 0101 c.b = Max_int32 (a.b, b.b); 0102 c.r = Max_int32 (a.r, b.r); 0103 0104 return c; 0105 0106 } 0107 0108 /*****************************************************************************/ 0109 0110 dng_rect_real64 operator& (const dng_rect_real64 &a, 0111 const dng_rect_real64 &b) 0112 { 0113 0114 dng_rect_real64 c; 0115 0116 c.t = Max_real64 (a.t, b.t); 0117 c.l = Max_real64 (a.l, b.l); 0118 0119 c.b = Min_real64 (a.b, b.b); 0120 c.r = Min_real64 (a.r, b.r); 0121 0122 if (c.IsEmpty ()) 0123 { 0124 0125 c = dng_rect_real64 (); 0126 0127 } 0128 0129 return c; 0130 0131 } 0132 0133 /*****************************************************************************/ 0134 0135 dng_rect_real64 operator| (const dng_rect_real64 &a, 0136 const dng_rect_real64 &b) 0137 { 0138 0139 if (a.IsEmpty ()) 0140 { 0141 return b; 0142 } 0143 0144 if (b.IsEmpty ()) 0145 { 0146 return a; 0147 } 0148 0149 dng_rect_real64 c; 0150 0151 c.t = Min_real64 (a.t, b.t); 0152 c.l = Min_real64 (a.l, b.l); 0153 0154 c.b = Max_real64 (a.b, b.b); 0155 c.r = Max_real64 (a.r, b.r); 0156 0157 return c; 0158 0159 } 0160 0161 /*****************************************************************************/ 0162 0163 dng_rect_real64 Bounds (const dng_point_real64 &a, 0164 const dng_point_real64 &b, 0165 const dng_point_real64 &c, 0166 const dng_point_real64 &d) 0167 { 0168 0169 real64 xMin = Min_real64 (a.h, Min_real64 (b.h, Min_real64 (c.h, d.h))); 0170 real64 xMax = Max_real64 (a.h, Max_real64 (b.h, Max_real64 (c.h, d.h))); 0171 0172 real64 yMin = Min_real64 (a.v, Min_real64 (b.v, Min_real64 (c.v, d.v))); 0173 real64 yMax = Max_real64 (a.v, Max_real64 (b.v, Max_real64 (c.v, d.v))); 0174 0175 return dng_rect_real64 (yMin, 0176 xMin, 0177 yMax, 0178 xMax); 0179 0180 } 0181 0182 /*****************************************************************************/