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/Point.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.LGPL ** 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 <ICLUtils/Macros.h> 00034 #include <ostream> 00035 00036 #ifdef ICL_HAVE_IPP 00037 #include <ipp.h> 00038 #endif 00039 00040 namespace icl{ 00041 namespace utils{ 00042 #ifndef ICL_HAVE_IPP 00043 00044 struct IppiPoint { 00046 int x; 00048 int y; 00049 }; 00050 #else 00051 #endif 00052 00054 class Point32f; 00057 00058 class ICLUtils_API Point : public IppiPoint{ 00059 public: 00061 static const Point null; 00062 00064 Point(){ this->x = 0; this->y = 0; } 00065 00067 Point(const Point& p){ this->x = p.x; this->y = p.y; } 00068 00070 Point(const Point32f &p); 00071 00073 Point(int x,int y){this->x = x;this->y = y;} 00074 00076 bool isNull() const { return (*this)==null; } 00077 00079 bool operator==(const Point &s) const {return x==s.x && y==s.y;} 00080 00082 bool operator!=(const Point &s) const {return x!=s.x || y!=s.y;} 00083 00085 Point operator+(const Point &s) const {return Point(x+s.x,y+s.y);} 00086 00088 Point operator-(const Point &s) const {return Point(x-s.x,y-s.y);} 00089 00091 Point operator*(double d) const { return Point((int)(d*x),(int)(d*y));} 00092 00094 Point& operator+=(const Point &s){x+=s.x; y+=s.y; return *this;} 00095 00097 Point& operator-=(const Point &s){x-=s.x; y-=s.y; return *this;} 00098 00100 Point& operator*=(double d) {x=(int)((double)x*d); y=(int)((double)y*d); return *this;}; 00101 00103 Point transform(double xfac, double yfac) const{ 00104 return Point((int)(xfac*x),(int)(yfac*y)); 00105 } 00106 00108 float distanceTo(const Point &p) const; 00109 00111 int &operator[](int i) { return i?y:x; } 00112 00114 const int &operator[](int i) const { return i?y:x; } 00115 }; 00116 00118 ICLUtils_API std::ostream &operator<<(std::ostream &s, const Point &p); 00119 00121 ICLUtils_API std::istream &operator>>(std::istream &s, Point &p); 00122 00123 00124 } // namespace utils 00125 } // namespace icl 00126