4 #include <KrisLibrary/structs/array3d.h> 5 #include <KrisLibrary/math3d/AABB3D.h> 7 #include <KrisLibrary/utils/indexing.h> 24 inline const T& operator *()
const {
return *it; }
25 inline T& operator *() {
return *it; }
26 inline const IntTriple& getIndex()
const {
return index; }
28 inline bool isDone()
const {
return index.a > hi.a; }
29 inline void getCell(
AABB3D& cell)
const 30 { cell.bmin=cellCorner; cell.bmax=cellCorner+cellSize; }
31 inline void getCellCenter(
Vector3& c)
const { c=cellCorner+cellSize*Half; }
63 bool IsEmpty()
const {
return value.empty(); }
64 void Resize(
int m,
int n,
int p) { value.resize(m,n,p); }
65 void ResizeByResolution(
const Vector3& res);
70 void GetCell(
int i,
int j,
int k,
AABB3D& cell)
const;
71 void GetCellCenter(
int i,
int j,
int k,
Vector3& center)
const;
74 void GetIndex(
const Vector3& pt,
int& i,
int& j,
int& k)
const;
80 bool GetIndexChecked(
const Vector3& pt,
int& i,
int& j,
int& k)
const;
85 inline void GetCell(
const IntTriple& index,
AABB3D& cell)
const { GetCell(index.a,index.b,index.c,cell); }
86 inline void GetCenter(
const IntTriple& index,
Vector3& center)
const { GetCellCenter(index.a,index.b,index.c,center); }
87 inline void GetIndex(
const Vector3& pt,
IntTriple& index)
const { GetIndex(pt,index.a,index.b,index.c); }
88 inline void SetValue(
int i,
int j,
int k,
const T& v) { value(i,j,k)=v; }
89 inline void SetValue(
const Vector3& pt,
const T& v) {
int i,j,k; GetIndex(pt,i,j,k); value(i,j,k)=v; }
90 inline T GetValue(
int i,
int j,
int k)
const {
return value(i,j,k); }
91 inline T GetValue(
const Vector3& pt)
const {
int i,j,k; GetIndex(pt,i,j,k);
return value(i,j,k); }
94 T TrilinearInterpolate(
const Vector3& pt)
const;
96 T MinimumFreeInterpolate(
const Vector3& pt)
const;
98 T Average(
const AABB3D& range)
const;
100 void ResampleTrilinear(
const MyT& grid);
102 void ResampleAverage(
const MyT& grid);
104 void Gradient_ForwardDifference(
const IntTriple& index,
Vector3& grad)
const;
106 void Gradient_CenteredDifference(
const IntTriple& index,
Vector3& grad)
const;
110 void Add(
const MyT& grid);
111 void Subtract(
const MyT& grid);
112 void Multiply(
const MyT& grid);
113 void Max(
const MyT& grid);
114 void Min(
const MyT& grid);
116 void Multiply(T val);
121 iterator getIterator()
const {
return iterator(value,bb); }
132 in>>grid.bb.bmin>>grid.bb.bmax;
138 std::ostream& operator << (std::ostream& out,const VolumeGridTemplate<T>& grid)
140 out<<grid.bb.bmin<<
" "<<grid.bb.bmax<<std::endl;
141 out<<grid.value<<std::endl;
151 value.resize(grid.value.m,grid.value.n,grid.value.p);
158 return (grid.value.m == value.m && grid.value.n == value.n && grid.value.p == value.p) && (bb.bmin == grid.bb.bmin && bb.bmax == grid.bb.bmax);
163 :cells(_cells),bb(_bb),it(&cells)
165 cellSize.x = (bb.bmax.x-bb.bmin.x)/Real(cells.m);
166 cellSize.y = (bb.bmax.y-bb.bmin.y)/Real(cells.n);
167 cellSize.z = (bb.bmax.z-bb.bmin.z)/Real(cells.p);
169 hi.set(_cells.m-1,_cells.n-1,_cells.p-1);
171 cellCorner = bbMin = bb.bmin;
180 bbMin.x += Real(lo.a)*cellSize.x;
181 bbMin.y += Real(lo.b)*cellSize.y;
182 bbMin.z += Real(lo.c)*cellSize.z;
195 cellCorner.z+=cellSize.z;
198 cellCorner.z=bbMin.z;
200 cellCorner.y+=cellSize.y;
203 cellCorner.y=bbMin.y;
205 cellCorner.x+=cellSize.x;
208 Assert(index == it.getElement());
A lightweight integer 3-tuple class.
Definition: IntTriple.h:9
The namespace for all classes/functions in the Meshing package.
Definition: AnyGeometry.h:11
A 3D vector class.
Definition: math3d/primitives.h:136
A 3D lattice of regular ranges.
Definition: utils/indexing.h:175
A 3D axis-aligned bounding box.
Definition: AABB3D.h:13
Class declarations for useful 3D math types.
Contains all the definitions in the Math3D package.
Definition: AnyGeometry.h:13
A 3D array over an axis-aligned 3D volume, containing Real values.
Definition: AnyGeometry.h:11
Iterator over a 3D volume grid.
Definition: VolumeGrid.h:20
A three-dimensional m x n x parray.
Definition: array3d.h:31