Jet  v1.3.3
array_samplers3.h
Go to the documentation of this file.
1 // Copyright (c) 2018 Doyub Kim
2 //
3 // I am making my contributions/submissions to this project solely in my
4 // personal capacity and am not conveying any rights to any intellectual
5 // property of any third parties.
6 
7 #ifndef INCLUDE_JET_ARRAY_SAMPLERS3_H_
8 #define INCLUDE_JET_ARRAY_SAMPLERS3_H_
9 
10 #include <jet/array_samplers.h>
11 #include <jet/array_accessor3.h>
12 #include <jet/vector3.h>
13 #include <functional>
14 
15 namespace jet {
16 
25 template <typename T, typename R>
26 class NearestArraySampler<T, R, 3> final {
27  public:
28  static_assert(
29  std::is_floating_point<R>::value,
30  "Samplers only can be instantiated with floating point types");
31 
41  const ConstArrayAccessor3<T>& accessor,
42  const Vector3<R>& gridSpacing,
43  const Vector3<R>& gridOrigin);
44 
47 
49  T operator()(const Vector3<R>& pt) const;
50 
52  void getCoordinate(const Vector3<R>& pt, Point3UI* index) const;
53 
55  std::function<T(const Vector3<R>&)> functor() const;
56 
57  private:
58  Vector3<R> _gridSpacing;
59  Vector3<R> _origin;
60  ConstArrayAccessor3<T> _accessor;
61 };
62 
64 template <typename T, typename R> using NearestArraySampler3
66 
67 
76 template <typename T, typename R>
77 class LinearArraySampler<T, R, 3> final {
78  public:
79  static_assert(
80  std::is_floating_point<R>::value,
81  "Samplers only can be instantiated with floating point types");
82 
92  const ConstArrayAccessor3<T>& accessor,
93  const Vector3<R>& gridSpacing,
94  const Vector3<R>& gridOrigin);
95 
98 
100  T operator()(const Vector3<R>& pt) const;
101 
104  const Vector3<R>& pt,
105  std::array<Point3UI, 8>* indices,
106  std::array<R, 8>* weights) const;
107 
111  const Vector3<R>& pt,
112  std::array<Point3UI, 8>* indices,
113  std::array<Vector3<R>, 8>* weights) const;
114 
116  std::function<T(const Vector3<R>&)> functor() const;
117 
118  private:
119  Vector3<R> _gridSpacing;
120  Vector3<R> _invGridSpacing;
121  Vector3<R> _origin;
122  ConstArrayAccessor3<T> _accessor;
123 };
124 
126 template <typename T, typename R> using LinearArraySampler3
128 
129 
138 template <typename T, typename R>
139 class CubicArraySampler<T, R, 3> final {
140  public:
141  static_assert(
142  std::is_floating_point<R>::value,
143  "Samplers only can be instantiated with floating point types");
144 
154  const ConstArrayAccessor3<T>& accessor,
155  const Vector3<R>& gridSpacing,
156  const Vector3<R>& gridOrigin);
157 
160 
162  T operator()(const Vector3<R>& pt) const;
163 
165  std::function<T(const Vector3<R>&)> functor() const;
166 
167  private:
168  Vector3<R> _gridSpacing;
169  Vector3<R> _origin;
170  ConstArrayAccessor3<T> _accessor;
171 };
172 
174 template <typename T, typename R> using CubicArraySampler3
176 
177 } // namespace jet
178 
179 #include "detail/array_samplers3-inl.h"
180 
181 #endif // INCLUDE_JET_ARRAY_SAMPLERS3_H_
jet::ConstArrayAccessor< T, 3 >
3-D read-only array accessor class.
Definition: array_accessor3.h:270
jet::NearestArraySampler< T, R, 3 >::operator()
T operator()(const Vector3< R > &pt) const
Returns sampled value at point pt.
jet::NearestArraySampler
Generic N-D nearest array sampler class.
Definition: array_samplers.h:22
jet::CubicArraySampler< T, R, 3 >::functor
std::function< T(const Vector3< R > &)> functor() const
Returns a funtion object that wraps this instance.
jet::LinearArraySampler< T, R, 3 >::LinearArraySampler
LinearArraySampler(const ConstArrayAccessor3< T > &accessor, const Vector3< R > &gridSpacing, const Vector3< R > &gridOrigin)
Constructs a sampler using array accessor, spacing between the elements, and the position of the firs...
jet::LinearArraySampler< T, R, 3 >::getCoordinatesAndWeights
void getCoordinatesAndWeights(const Vector3< R > &pt, std::array< Point3UI, 8 > *indices, std::array< R, 8 > *weights) const
Returns the indices of points and their sampling weight for given point.
jet::LinearArraySampler< T, R, 3 >::LinearArraySampler
LinearArraySampler(const LinearArraySampler &other)
Copy constructor.
jet::CubicArraySampler< T, R, 3 >::operator()
T operator()(const Vector3< R > &pt) const
Returns sampled value at point pt.
jet::NearestArraySampler< T, R, 3 >::getCoordinate
void getCoordinate(const Vector3< R > &pt, Point3UI *index) const
Returns the nearest array index for point x.
jet::CubicArraySampler
Generic N-D cubic array sampler class.
Definition: array_samplers.h:50
jet::NearestArraySampler< T, R, 3 >::NearestArraySampler
NearestArraySampler(const ConstArrayAccessor3< T > &accessor, const Vector3< R > &gridSpacing, const Vector3< R > &gridOrigin)
Constructs a sampler using array accessor, spacing between the elements, and the position of the firs...
jet::CubicArraySampler< T, R, 3 >::CubicArraySampler
CubicArraySampler(const ConstArrayAccessor3< T > &accessor, const Vector3< R > &gridSpacing, const Vector3< R > &gridOrigin)
Constructs a sampler using array accessor, spacing between the elements, and the position of the firs...
jet
Definition: advection_solver2.h:18
jet::LinearArraySampler< T, R, 3 >
2-D linear array sampler class.
Definition: array_samplers3.h:77
jet::CubicArraySampler< T, R, 3 >
3-D cubic array sampler class.
Definition: array_samplers3.h:139
jet::Point< T, 3 >
3-D point class.
Definition: point3.h:23
vector3.h
jet::LinearArraySampler< T, R, 3 >::functor
std::function< T(const Vector3< R > &)> functor() const
Returns a funtion object that wraps this instance.
array_accessor3.h
jet::LinearArraySampler< T, R, 3 >::operator()
T operator()(const Vector3< R > &pt) const
Returns sampled value at point pt.
jet::LinearArraySampler< T, R, 3 >::getCoordinatesAndGradientWeights
void getCoordinatesAndGradientWeights(const Vector3< R > &pt, std::array< Point3UI, 8 > *indices, std::array< Vector3< R >, 8 > *weights) const
jet::Vector< T, 3 >
3-D vector class.
Definition: vector3.h:25
jet::LinearArraySampler
Generic N-D linear array sampler class.
Definition: array_samplers.h:36
jet::NearestArraySampler< T, R, 3 >::NearestArraySampler
NearestArraySampler(const NearestArraySampler &other)
Copy constructor.
array_samplers.h
jet::NearestArraySampler< T, R, 3 >::functor
std::function< T(const Vector3< R > &)> functor() const
Returns a funtion object that wraps this instance.
jet::NearestArraySampler< T, R, 3 >
3-D nearest array sampler class.
Definition: array_samplers3.h:26
jet::CubicArraySampler< T, R, 3 >::CubicArraySampler
CubicArraySampler(const CubicArraySampler &other)
Copy constructor.