ArraySamplers3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: ArraySamplers3.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 3-D nearest array sampler class.
6 > Created Time: 2017/04/29
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_ARRAY_SAMPLERS3_H
10 #define CUBBYFLOW_ARRAY_SAMPLERS3_H
11 
14 #include <Core/Vector/Vector3.h>
15 
16 #include <functional>
17 
18 namespace CubbyFlow
19 {
28  template <typename T, typename R>
29  class NearestArraySampler<T, R, 3> final
30  {
31  public:
32  static_assert(std::is_floating_point<R>::value, "Samplers only can be instantiated with floating point types");
33 
42  explicit NearestArraySampler(
43  const ConstArrayAccessor3<T>& accessor,
44  const Vector3<R>& gridSpacing,
45  const Vector3<R>& gridOrigin);
46 
49 
51  T operator()(const Vector3<R>& pt) const;
52 
54  void GetCoordinate(const Vector3<R>& pt, Point3UI* index) const;
55 
57  std::function<T(const Vector3<R>&)> Functor() const;
58 
59  private:
60  Vector3<R> m_gridSpacing;
61  Vector3<R> m_origin;
62  ConstArrayAccessor3<T> m_accessor;
63  };
64 
66  template <typename T, typename R>
68 
77  template <typename T, typename R>
78  class LinearArraySampler<T, R, 3> final
79  {
80  public:
81  static_assert(std::is_floating_point<R>::value, "Samplers only can be instantiated with floating point types");
82 
91  explicit LinearArraySampler(
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 
103  void GetCoordinatesAndWeights(
104  const Vector3<R>& pt,
105  std::array<Point3UI, 8>* indices,
106  std::array<R, 8>* weights) const;
107 
110  void GetCoordinatesAndGradientWeights(
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> m_gridSpacing;
120  Vector3<R> m_invGridSpacing;
121  Vector3<R> m_origin;
122  ConstArrayAccessor3<T> m_accessor;
123  };
124 
126  template <typename T, typename R>
128 
137  template <typename T, typename R>
138  class CubicArraySampler<T, R, 3> final
139  {
140  public:
141  static_assert(std::is_floating_point<R>::value, "Samplers only can be instantiated with floating point types");
142 
151  explicit CubicArraySampler(
152  const ConstArrayAccessor3<T>& accessor,
153  const Vector3<R>& gridSpacing,
154  const Vector3<R>& gridOrigin);
155 
157  CubicArraySampler(const CubicArraySampler& other);
158 
160  T operator()(const Vector3<R>& pt) const;
161 
163  std::function<T(const Vector3<R>&)> Functor() const;
164 
165  private:
166  Vector3<R> m_gridSpacing;
167  Vector3<R> m_origin;
168  ConstArrayAccessor3<T> m_accessor;
169  };
170 
172  template <typename T, typename R>
174 }
175 
177 
178 #endif
3-D vector class.
Definition: Vector3.h:26
3-D read-only array accessor class.
Definition: ArrayAccessor3.h:269
Generic N-D nearest array sampler class.
Definition: ArraySamplers.h:22
3-D point class.
Definition: Point3.h:26
Definition: pybind11Utils.h:24
Generic N-D cubic array sampler class.
Definition: ArraySamplers.h:50
3-D cubic array sampler class.
Definition: ArraySamplers3.h:138
Generic N-D linear array sampler class.
Definition: ArraySamplers.h:36
3-D nearest array sampler class.
Definition: ArraySamplers3.h:29
3-D linear array sampler class.
Definition: ArraySamplers3.h:78