4 #include <KrisLibrary/structs/array2d.h> 5 #include <KrisLibrary/math3d/AABB2D.h> 7 #include <KrisLibrary/utils/indexing.h> 24 inline const T& operator *()
const {
return *it; }
25 inline T& operator *() {
return *it; }
26 inline const IntPair& getIndex()
const {
return index; }
28 inline bool isDone()
const {
return index.a > hi.a; }
29 inline void getCell(
AABB2D& cell)
const 30 { cell.bmin=cellCorner; cell.bmax=cellCorner+cellSize; }
31 inline void getCellCenter(
Vector2& c)
const { c=cellCorner+cellSize*Half; }
63 bool IsEmpty()
const {
return value.empty(); }
64 void Resize(
int m,
int n) { value.resize(m,n); }
65 void ResizeByResolution(
const Vector2& res);
70 void GetCell(
int i,
int j,
AABB2D& cell)
const;
71 void GetCellCenter(
int i,
int j,
Vector2& center)
const;
73 void GetIndex(
const Vector2& pt,
int& i,
int& j)
const;
76 inline void GetCell(
const IntPair& index,
AABB2D& cell)
const { GetCell(index.a,index.b,cell); }
77 inline void GetCenter(
const IntPair& index,
Vector2& center)
const { GetCellCenter(index.a,index.b,center); }
78 inline void GetIndex(
const Vector2& pt,
IntPair& index)
const { GetIndex(pt,index.a,index.b); }
79 inline void SetValue(
int i,
int j,
const T& v) { value(i,j)=v; }
80 inline void SetValue(
const Vector2& pt,
const T& v) {
int i,j; GetIndex(pt,i,j); value(i,j)=v; }
81 inline T GetValue(
int i,
int j)
const {
return value(i,j); }
82 inline T GetValue(
const Vector2& pt)
const {
int i,j; GetIndex(pt,i,j);
return value(i,j); }
85 T BilinearInterpolate(
const Vector2& pt)
const;
87 T Average(
const AABB2D& range)
const;
89 void ResampleBilinear(
const MyT& grid);
91 void ResampleAverage(
const MyT& grid);
93 void Gradient_ForwardDifference(
const IntPair& index,
Vector2& grad)
const;
95 void Gradient_CenteredDifference(
const IntPair& index,
Vector2& grad)
const;
99 void Add(
const MyT& grid);
100 void Subtract(
const MyT& grid);
101 void Multiply(
const MyT& grid);
102 void Max(
const MyT& grid);
103 void Min(
const MyT& grid);
105 void Multiply(T val);
110 iterator getIterator()
const {
return iterator(value,bb); }
121 in>>grid.bb.bmin>>grid.bb.bmax;
127 std::ostream& operator << (std::ostream& out,const AreaGridTemplate<T>& grid)
129 out<<grid.bb.bmin<<
" "<<grid.bb.bmax<<std::endl;
130 out<<grid.value<<std::endl;
140 value.resize(grid.value.m,grid.value.n);
147 return (grid.value.m == value.m && grid.value.n == value.n) && (bb.bmin == grid.bb.bmin && bb.bmax == grid.bb.bmax);
152 :cells(_cells),bb(_bb),it(&cells)
154 cellSize.x = (bb.bmax.x-bb.bmin.x)/Real(cells.m);
155 cellSize.y = (bb.bmax.y-bb.bmin.y)/Real(cells.n);
157 hi.set(_cells.m-1,_cells.n-1);
159 cellCorner = bbMin = bb.bmin;
168 bbMin.x += Real(lo.a)*cellSize.x;
169 bbMin.y += Real(lo.b)*cellSize.y;
181 cellCorner.y+=cellSize.y;
184 cellCorner.y=bbMin.y;
186 cellCorner.x+=cellSize.x;
188 Assert(index == it.getElement());
The namespace for all classes/functions in the Meshing package.
Definition: AnyGeometry.h:11
Iterator over a 2D area grid.
Definition: AreaGrid.h:20
A 2D array over an axis-aligned 2D box, containing Real values.
Definition: AreaGrid.h:58
A lightweight integer 2-tuple class.
Definition: IntPair.h:9
Class declarations for useful 3D math types.
A two-dimensional m x n array.
Definition: array2d.h:30
Contains all the definitions in the Math3D package.
Definition: AnyGeometry.h:13
A 2D lattice of regular ranges.
Definition: utils/indexing.h:116
A 2D vector class.
Definition: math3d/primitives.h:41
A 2D axis-aligned bounding box.
Definition: AABB2D.h:13