Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef CELL_HH
00036 #define CELL_HH
00037
00038 #include <vector>
00039 #include <cstdio>
00040 #include <cmath>
00041
00042 namespace lslgeneric
00043 {
00044
00051 template<typename PointT>
00052 class Cell
00053 {
00054
00055 protected:
00056 PointT center_;
00057 double xsize_, ysize_, zsize_;
00058
00059 public:
00060 Cell() { }
00061 inline Cell(PointT ¢er, double &xsize, double &ysize, double &zsize)
00062 {
00063 center_ = center;
00064 xsize_ = xsize;
00065 ysize_ = ysize;
00066 zsize_ = zsize;
00067 }
00068 inline Cell(const Cell& other)
00069 {
00070 center_ = other.center_;
00071 xsize_ = other.xsize_;
00072 ysize_ = other.ysize_;
00073 zsize_ = other.zsize_;
00074 }
00075 virtual ~Cell() { }
00076
00077 inline void setCenter(const PointT &cn)
00078 {
00079 center_ = cn;
00080 }
00081 inline void setDimensions(const double &xs, const double &ys, const double &zs)
00082 {
00083 xsize_ = xs;
00084 ysize_ = ys;
00085 zsize_ = zs;
00086 }
00087
00088 inline PointT getCenter() const
00089 {
00090 return center_;
00091 }
00092 inline void getDimensions(double &xs, double &ys, double &zs) const
00093 {
00094 xs = xsize_;
00095 ys = ysize_;
00096 zs = zsize_;
00097 }
00098 inline bool isInside(const PointT pt) const
00099 {
00100 if(pt.x < center_.x-xsize_/2 || pt.x > center_.x+xsize_/2)
00101 {
00102 return false;
00103 }
00104 if(pt.y < center_.y-ysize_/2 || pt.y > center_.y+ysize_/2)
00105 {
00106 return false;
00107 }
00108 if(pt.z < center_.z-zsize_/2 || pt.z > center_.z+zsize_/2)
00109 {
00110 return false;
00111 }
00112 return true;
00113 }
00114
00116 inline virtual Cell<PointT>* clone() const
00117 {
00118 Cell<PointT> *ret = new Cell<PointT>();
00119 return(ret);
00120 }
00122 virtual Cell<PointT>* copy() const
00123 {
00124 Cell<PointT> *ret = new Cell<PointT>();
00125 ret->setDimensions(xsize_,ysize_,zsize_);
00126 ret->setCenter(center_);
00127 return(ret);
00128 }
00129
00130 virtual void addPoint(PointT &pt) { }
00131 virtual double getDiagonal() const
00132 {
00133 return std::sqrt(xsize_*xsize_+ysize_*ysize_+zsize_*zsize_);
00134 }
00135 };
00136
00137
00138 }
00139
00140
00141
00142 #endif