00001
00002
00008 #if !defined(__numerical_interpolation_linear_h__)
00009 #define __numerical_interpolation_linear_h__
00010
00011 #include "../defs.h"
00012
00013 #include "../../ads/array/Array.h"
00014 #include "../../geom/grid/RegularGrid.h"
00015
00016 #include <functional>
00017
00018 BEGIN_NAMESPACE_NUMERICAL
00019
00021
00028 template<int N, typename F = double, bool A = true, typename T = double>
00029 class LinInterpGrid :
00030
00031
00032 public std::unary_function<
00033 const typename geom::RegularGrid<N,T>::Point&,
00034 typename Loki::TypeTraits<F>::ParameterType> {
00035
00036
00037
00038
00039 private:
00040
00042 typedef std::unary_function<
00043 const typename geom::RegularGrid<N,T>::Point&,
00044 typename Loki::TypeTraits<F>::ParameterType>
00045 base_type;
00046
00047
00048
00049
00050
00051 public:
00052
00054 typedef typename base_type::argument_type argument_type;
00056 typedef typename base_type::result_type result_type;
00057
00059 typedef T Number;
00061 typedef F Field;
00062
00064 typedef geom::RegularGrid<N,Number> Grid;
00066 typedef ads::Array<N,Field,A> FieldArray;
00067
00069 typedef typename Grid::Point Point;
00071 typedef typename Grid::BBox BBox;
00072
00074 typedef typename FieldArray::index_type index_type;
00076 typedef typename FieldArray::size_type size_type;
00077
00079 typedef typename FieldArray::unqualified_value_type
00080 unqualified_Field;
00081
00082
00083
00084
00085
00086 private:
00087
00089 FieldArray _fields;
00091 Grid _grid;
00092
00093 public:
00094
00095
00098
00100 LinInterpGrid() :
00101 _fields(),
00102 _grid()
00103 {}
00104
00106
00110 template <bool A2>
00111 LinInterpGrid(const ads::Array<N,Field,A2>& fields,
00112 const BBox domain) :
00113 _fields(fields),
00114 _grid(_fields.extents(), domain)
00115 {}
00116
00118
00122 template <bool A2>
00123 void
00124 build(const ads::Array<N,Field,A2>& fields, const BBox domain) {
00125 _fields = fields;
00126 _grid = Grid(_fields.extents(), domain);
00127 }
00128
00130 LinInterpGrid(const LinInterpGrid& x) :
00131 _fields(x._fields),
00132 _grid(x._grid)
00133 {}
00134
00136 LinInterpGrid&
00137 operator=(const LinInterpGrid& x) {
00138 if (this != &x) {
00139 _fields = x._fields;
00140 _grid = x._grid;
00141 }
00142 return *this;
00143 }
00144
00146 ~LinInterpGrid()
00147 {}
00148
00150
00153
00155 result_type
00156 operator()(argument_type x) const;
00157
00159
00162
00164 static
00165 int
00166 space_dimension() {
00167 return N;
00168 }
00169
00171
00174
00176 const FieldArray&
00177 fields() const {
00178 return _fields;
00179 }
00180
00182 const BBox&
00183 domain() const {
00184 return _grid.domain();
00185 }
00186
00188
00191
00193
00197 FieldArray&
00198 fields() {
00199 return _fields;
00200 }
00201
00203 void
00204 set_domain(const BBox& domain);
00205
00207 void
00208 resize(const index_type& extents);
00209
00211 };
00212
00213 END_NAMESPACE_NUMERICAL
00214
00215 #define __numerical_interpolation_LinInterpGrid_ipp__
00216 #include "LinInterpGrid.ipp"
00217 #undef __numerical_interpolation_LinInterpGrid_ipp__
00218
00219 #endif