GEL
2
GEL is a library for Geometry and Linear Algebra
|
00001 #ifndef __GEOMETRY_ANCESTORGRID_H 00002 #define __GEOMETRY_ANCESTORGRID_H 00003 00004 #include "CGLA/Vec3i.h" 00005 00006 namespace Geometry 00007 { 00008 00021 template<typename T, class ChildT> 00022 class AncestorGrid 00023 { 00024 public: 00025 typedef T DataType; 00026 00027 private: 00029 CGLA::Vec3i dims; 00030 00031 public: 00032 00034 AncestorGrid(int _x_dim, int _y_dim, int _z_dim): 00035 dims(_x_dim,_y_dim,_z_dim) {} 00036 00038 AncestorGrid(const CGLA::Vec3i& _dims): dims(_dims) {} 00039 00043 bool in_domain(const CGLA::Vec3i& p) const 00044 { 00045 for(int i=0; i<3; i++) 00046 if (p[i]<0 || p[i] >= dims[i]) 00047 return false; 00048 return true; 00049 } 00050 00055 const CGLA::Vec3i& get_dims() const {return dims;} 00056 00058 const CGLA::Vec3i get_lo_corner() const {return CGLA::Vec3i(0);} 00059 00061 const CGLA::Vec3i& get_hi_corner() const {return dims;} 00062 00072 const T& operator[](const CGLA::Vec3i& p) const 00073 { 00074 return static_cast<const ChildT&>(*this)[p]; 00075 } 00076 00077 00096 void store(const CGLA::Vec3i& p, const T& t) 00097 { 00098 return static_cast<ChildT&>(*this).store(p,t); 00099 } 00100 }; 00101 } 00102 00103 #endif