|
|
PDS_JP2
|
00001 /* Dimensions 00002 00003 HiROC CVS ID: Dimensions.hh,v 1.4 2007/07/16 10:41:53 castalia Exp 00004 00005 Copyright (C) 2007 Arizona Board of Regents on behalf of the 00006 Planetary Image Research Laboratory, Lunar and Planetary Laboratory at 00007 the University of Arizona. 00008 00009 This library is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU Lesser General Public License, version 2.1, 00011 as published by the Free Software Foundation. 00012 00013 This library is distributed in the hope that it will be useful, but 00014 WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public License 00019 along with this library; if not, write to the Free Software Foundation, 00020 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 00021 */ 00022 00023 #ifndef _Dimensions_ 00024 #define _Dimensions_ 00025 00026 00027 namespace UA 00028 { 00029 namespace HiRISE 00030 { 00031 //****************************************************************************** 00037 struct Point_2D 00038 { 00040 int 00041 X; 00043 int 00044 Y; 00045 00046 /*============================================================================== 00047 Constructors: 00048 */ 00050 Point_2D (); 00051 00053 Point_2D (const int& x,const int& y); 00054 00059 Point_2D (const Point_2D& point); 00060 00065 Point_2D& operator= (const Point_2D& point); 00066 00067 /*============================================================================== 00068 Accessors: 00069 */ 00074 inline int x () const 00075 {return X;} 00076 00082 inline Point_2D& x (const int& x_position) 00083 {X = x_position; return *this;} 00084 00089 inline int y () const 00090 {return Y;} 00091 00097 inline Point_2D& y (const int& y_position) 00098 {Y = y_position; return *this;} 00099 00100 }; // End of Point_2D class. 00101 00102 //****************************************************************************** 00108 struct Size_2D 00109 { 00111 unsigned int 00112 Width; 00114 unsigned int 00115 Height; 00116 00117 /*============================================================================== 00118 Constructors: 00119 */ 00124 Size_2D (); 00125 00131 Size_2D (const unsigned int& width, const unsigned int& height); 00132 00138 Size_2D (const unsigned int& side); 00139 00144 Size_2D (const Size_2D& size); 00145 00150 Size_2D& operator= (const Size_2D& size); 00151 00152 /*============================================================================== 00153 Accessors: 00154 */ 00159 inline unsigned int width () const 00160 {return Width;} 00161 00167 inline Size_2D& width (const unsigned int& width) 00168 {Width = width; return *this;} 00169 00174 inline unsigned int height () const 00175 {return Height;} 00176 00182 inline Size_2D& height (const unsigned int& height) 00183 {Height = height; return *this;} 00184 00189 inline unsigned long area () const 00190 {return Width * Height;} 00191 00192 }; // End of Size_2D class. 00193 00194 //****************************************************************************** 00202 struct Rectangle 00203 : public Point_2D, 00204 public Size_2D 00205 { 00206 /*============================================================================== 00207 Constructors: 00208 */ 00213 Rectangle (); 00214 00220 Rectangle (const Point_2D& position, const Size_2D& size); 00221 00226 Rectangle (const Size_2D& size); 00227 00235 Rectangle 00236 ( 00237 const int x, 00238 const int y, 00239 const unsigned int width = 0, 00240 const unsigned int height = 0 00241 ); 00242 00247 Rectangle (const Rectangle& rectangle); 00248 00255 Rectangle& operator= (const Rectangle& rectangle); 00256 00257 /*============================================================================== 00258 Accessors: 00259 */ 00265 inline Point_2D position () const 00266 {return Point_2D (X, Y);} 00267 00273 inline Rectangle& position 00274 ( 00275 const Point_2D& point 00276 ) 00277 { 00278 X = point.X; 00279 Y = point.Y; 00280 } 00281 00288 inline Rectangle& position 00289 ( 00290 const int x, 00291 const int y 00292 ) 00293 { 00294 X = x; 00295 Y = y; 00296 return *this; 00297 } 00298 00304 inline Size_2D size () const 00305 {return Size_2D (Width, Height);} 00306 00312 inline Rectangle& size 00313 ( 00314 const Size_2D& size 00315 ) 00316 { 00317 Width = size.Width; 00318 Height = size.Height; 00319 return *this; 00320 } 00321 00328 inline Rectangle& size 00329 ( 00330 const unsigned int width, 00331 const unsigned int height 00332 ) 00333 { 00334 Width = width; 00335 Height = height; 00336 return *this; 00337 } 00338 00339 /*============================================================================== 00340 Manipulators: 00341 */ 00350 Rectangle& operator&= (const Rectangle& rectangle); 00351 00352 }; // End of Rectangle class. 00353 00354 } // namespace HiRISE 00355 } // namespace UA 00356 #endif
1.4.6