DocumentationOverviewBuilding ASL Documentation Library Wiki Docs Indices Browse Perforce More InfoRelease NotesWiki Site Search License Success Stories Contributors MediaDownloadPerforce Depots SupportASL SourceForge HomeMailing Lists Discussion Forums Report Bugs Suggest Features Contribute to ASL RSSShort-text newsFull-text news File releases Other Adobe ProjectsAdobe AirAdobe GIL Adobe Labs Adobe Media Gallery Adobe XMP Tamarin project (Mozilla Foundation) Other ResourcesBoostRIAForge SGI STL |
dng_rect.h00001 /*****************************************************************************/ 00002 // Copyright 2006-2007 Adobe Systems Incorporated 00003 // All Rights Reserved. 00004 // 00005 // NOTICE: Adobe permits you to use, modify, and distribute this file in 00006 // accordance with the terms of the Adobe license agreement accompanying it. 00007 /*****************************************************************************/ 00008 00009 /* $Id: //mondo/dng_sdk_1_2/dng_sdk/source/dng_rect.h#1 $ */ 00010 /* $DateTime: 2008/03/09 14:29:54 $ */ 00011 /* $Change: 431850 $ */ 00012 /* $Author: tknoll $ */ 00013 00014 /*****************************************************************************/ 00015 00016 #ifndef __dng_rect__ 00017 #define __dng_rect__ 00018 00019 /*****************************************************************************/ 00020 00021 #include "dng_types.h" 00022 #include "dng_point.h" 00023 #include "dng_utils.h" 00024 00025 /*****************************************************************************/ 00026 00027 class dng_rect 00028 { 00029 00030 public: 00031 00032 int32 t; 00033 int32 l; 00034 int32 b; 00035 int32 r; 00036 00037 public: 00038 00039 dng_rect () 00040 : t (0) 00041 , l (0) 00042 , b (0) 00043 , r (0) 00044 { 00045 } 00046 00047 dng_rect (int32 tt, int32 ll, int32 bb, int32 rr) 00048 : t (tt) 00049 , l (ll) 00050 , b (bb) 00051 , r (rr) 00052 { 00053 } 00054 00055 dng_rect (uint32 h, uint32 w) 00056 : t (0) 00057 , l (0) 00058 , b (h) 00059 , r (w) 00060 { 00061 } 00062 00063 dng_rect (const dng_point &size) 00064 : t (0) 00065 , l (0) 00066 , b (size.v) 00067 , r (size.h) 00068 { 00069 } 00070 00071 void Clear () 00072 { 00073 *this = dng_rect (); 00074 } 00075 00076 bool operator== (const dng_rect &rect) const; 00077 00078 bool operator!= (const dng_rect &rect) const 00079 { 00080 return !(*this == rect); 00081 } 00082 00083 bool IsZero () const; 00084 00085 bool NotZero () const 00086 { 00087 return !IsZero (); 00088 } 00089 00090 bool IsEmpty () const 00091 { 00092 return (t >= b) || (l >= r); 00093 } 00094 00095 bool NotEmpty () const 00096 { 00097 return !IsEmpty (); 00098 } 00099 00100 uint32 W () const 00101 { 00102 return (r >= l ? (uint32) (r - l) : 0); 00103 } 00104 00105 uint32 H () const 00106 { 00107 return (b >= t ? (uint32) (b - t) : 0); 00108 } 00109 00110 dng_point TL () const 00111 { 00112 return dng_point (t, l); 00113 } 00114 00115 dng_point TR () const 00116 { 00117 return dng_point (t, r); 00118 } 00119 00120 dng_point BL () const 00121 { 00122 return dng_point (b, l); 00123 } 00124 00125 dng_point BR () const 00126 { 00127 return dng_point (b, r); 00128 } 00129 00130 dng_point Size () const 00131 { 00132 return dng_point (H (), W ()); 00133 } 00134 00135 }; 00136 00137 /*****************************************************************************/ 00138 00139 class dng_rect_real64 00140 { 00141 00142 public: 00143 00144 real64 t; 00145 real64 l; 00146 real64 b; 00147 real64 r; 00148 00149 public: 00150 00151 dng_rect_real64 () 00152 : t (0.0) 00153 , l (0.0) 00154 , b (0.0) 00155 , r (0.0) 00156 { 00157 } 00158 00159 dng_rect_real64 (real64 tt, real64 ll, real64 bb, real64 rr) 00160 : t (tt) 00161 , l (ll) 00162 , b (bb) 00163 , r (rr) 00164 { 00165 } 00166 00167 dng_rect_real64 (real64 h, real64 w) 00168 : t (0) 00169 , l (0) 00170 , b (h) 00171 , r (w) 00172 { 00173 } 00174 00175 dng_rect_real64 (const dng_point_real64 &size) 00176 : t (0) 00177 , l (0) 00178 , b (size.v) 00179 , r (size.h) 00180 { 00181 } 00182 00183 dng_rect_real64 (const dng_rect &rect) 00184 : t ((real64) rect.t) 00185 , l ((real64) rect.l) 00186 , b ((real64) rect.b) 00187 , r ((real64) rect.r) 00188 { 00189 } 00190 00191 void Clear () 00192 { 00193 *this = dng_point_real64 (); 00194 } 00195 00196 bool operator== (const dng_rect_real64 &rect) const; 00197 00198 bool operator!= (const dng_rect_real64 &rect) const 00199 { 00200 return !(*this == rect); 00201 } 00202 00203 bool IsZero () const; 00204 00205 bool NotZero () const 00206 { 00207 return !IsZero (); 00208 } 00209 00210 bool IsEmpty () const 00211 { 00212 return (t >= b) || (l >= r); 00213 } 00214 00215 bool NotEmpty () const 00216 { 00217 return !IsEmpty (); 00218 } 00219 00220 real64 W () const 00221 { 00222 return Max_real64 (r - l, 0.0); 00223 } 00224 00225 real64 H () const 00226 { 00227 return Max_real64 (b - t, 0.0); 00228 } 00229 00230 dng_point_real64 TL () const 00231 { 00232 return dng_point_real64 (t, l); 00233 } 00234 00235 dng_point_real64 TR () const 00236 { 00237 return dng_point_real64 (t, r); 00238 } 00239 00240 dng_point_real64 BL () const 00241 { 00242 return dng_point_real64 (b, l); 00243 } 00244 00245 dng_point_real64 BR () const 00246 { 00247 return dng_point_real64 (b, r); 00248 } 00249 00250 dng_point_real64 Size () const 00251 { 00252 return dng_point_real64 (H (), W ()); 00253 } 00254 00255 dng_rect Round () const 00256 { 00257 return dng_rect (Round_int32 (t), 00258 Round_int32 (l), 00259 Round_int32 (b), 00260 Round_int32 (r)); 00261 } 00262 00263 }; 00264 00265 /*****************************************************************************/ 00266 00267 dng_rect operator& (const dng_rect &a, 00268 const dng_rect &b); 00269 00270 dng_rect operator| (const dng_rect &a, 00271 const dng_rect &b); 00272 00273 /*****************************************************************************/ 00274 00275 dng_rect_real64 operator& (const dng_rect_real64 &a, 00276 const dng_rect_real64 &b); 00277 00278 dng_rect_real64 operator| (const dng_rect_real64 &a, 00279 const dng_rect_real64 &b); 00280 00281 /*****************************************************************************/ 00282 00283 inline dng_rect operator+ (const dng_rect &a, 00284 const dng_point &b) 00285 { 00286 00287 return dng_rect (a.t + b.v, 00288 a.l + b.h, 00289 a.b + b.v, 00290 a.r + b.h); 00291 00292 } 00293 00294 /*****************************************************************************/ 00295 00296 inline dng_rect_real64 operator+ (const dng_rect_real64 &a, 00297 const dng_point_real64 &b) 00298 { 00299 00300 return dng_rect_real64 (a.t + b.v, 00301 a.l + b.h, 00302 a.b + b.v, 00303 a.r + b.h); 00304 00305 } 00306 00307 /*****************************************************************************/ 00308 00309 inline dng_rect operator- (const dng_rect &a, 00310 const dng_point &b) 00311 { 00312 00313 return dng_rect (a.t - b.v, 00314 a.l - b.h, 00315 a.b - b.v, 00316 a.r - b.h); 00317 00318 } 00319 00320 /*****************************************************************************/ 00321 00322 inline dng_rect_real64 operator- (const dng_rect_real64 &a, 00323 const dng_point_real64 &b) 00324 { 00325 00326 return dng_rect_real64 (a.t - b.v, 00327 a.l - b.h, 00328 a.b - b.v, 00329 a.r - b.h); 00330 00331 } 00332 00333 /*****************************************************************************/ 00334 00335 #endif 00336 00337 /*****************************************************************************/ | |||
