Image Component Library (ICL)
|
00001 /******************************************************************** 00002 ** Image Component Library (ICL) ** 00003 ** ** 00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** 00005 ** Neuroinformatics Group ** 00006 ** Website: www.iclcv.org and ** 00007 ** http://opensource.cit-ec.de/projects/icl ** 00008 ** ** 00009 ** File : ICLUtils/src/ICLUtils/Size32f.h ** 00010 ** Module : ICLUtils ** 00011 ** Authors: Christof Elbrechter ** 00012 ** ** 00013 ** ** 00014 ** GNU LESSER GENERAL PUBLIC LICENSE ** 00015 ** This file may be used under the terms of the GNU Lesser General ** 00016 ** Public License version 3.0 as published by the ** 00017 ** ** 00018 ** Free Software Foundation and appearing in the file LICENSE.GPL ** 00019 ** included in the packaging of this file. Please review the ** 00020 ** following information to ensure the license requirements will ** 00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** 00022 ** ** 00023 ** The development of this software was supported by the ** 00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** 00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** 00026 ** Forschungsgemeinschaft (DFG) in the context of the German ** 00027 ** Excellence Initiative. ** 00028 ** ** 00029 ********************************************************************/ 00030 00031 #pragma once 00032 00033 #include <iostream> 00034 #include <ICLUtils/Size.h> 00035 00036 namespace icl{ 00037 namespace utils{ 00039 class Size32f{ 00040 00041 public: 00042 // width variable 00043 float width; 00044 00045 // height variable 00046 float height; 00047 00049 static const Size32f null; 00050 00052 inline Size32f(const Size32f &s=null){ this->width = s.width;this->height = s.height; } 00053 00055 inline Size32f(float width,float height){ this->width = width; this->height = height; } 00056 00058 inline Size32f(const Size &other):width(other.width),height(other.height){} 00059 00061 bool isNull() const { return (*this)==null; } 00062 00064 bool operator==(const Size32f &s) const {return width==s.width && height==s.height;} 00065 00067 bool operator!=(const Size32f &s) const {return width!=s.width || height!=s.height;} 00068 00070 Size32f operator+(const Size32f &s) const {return Size32f(width+s.width,height+s.height);} 00071 00073 Size32f operator-(const Size32f &s) const {return Size32f(width-s.width,height-s.height);} 00074 00076 Size32f operator*(double d) const { return Size32f(d*width,d*height);} 00077 00079 Size32f operator/(double d) const { return (*this)*(1.0/d); } 00080 00082 Size32f& operator+=(const Size32f &s){width+=s.width; height+=s.height; return *this;} 00083 00085 Size32f& operator-=(const Size32f &s){width-=s.width; height-=s.height; return *this;} 00086 00088 Size32f& operator*=(double d) {width*=d; height*=d; return *this; } 00089 00091 Size32f& operator/=(double d) { return (*this)*=(1.0/d); } 00092 00094 float getDim() const {return width*height;} 00095 }; 00096 00098 std::ostream &operator<<(std::ostream &os, const Size32f &s); 00099 00101 std::istream &operator>>(std::istream &is, Size32f &s); 00102 00103 } // namespace utils 00104 }// namespace icl 00105