9 #ifndef CUBBYFLOW_ARRAY3_IMPL_H 10 #define CUBBYFLOW_ARRAY3_IMPL_H 26 Resize(size, initVal);
32 Resize(width, height, depth, initVal);
36 Array<T, 3>::Array(
const std::initializer_list<std::initializer_list<std::initializer_list<T>>>& list)
50 *
this = std::move(other);
56 for (
auto& v : m_data)
65 m_data.resize(other.m_data.size());
66 std::copy(other.m_data.begin(), other.m_data.end(), m_data.begin());
67 m_size = other.m_size;
71 void Array<T, 3>::Set(
const std::initializer_list<std::initializer_list<std::initializer_list<T>>>& list)
73 size_t depth = list.size();
74 size_t height = (depth > 0) ? list.begin()->size() : 0;
75 size_t width = (height > 0) ? list.begin()->begin()->size() : 0;
77 Resize(
Size3(width, height, depth));
79 auto depthIter = list.begin();
80 for (
size_t k = 0; k < depth; ++k)
82 assert(height == depthIter->size());
84 auto heightIter = depthIter->begin();
85 for (
size_t j = 0; j < height; ++j)
87 assert(width == heightIter->size());
89 auto widthIter = heightIter->begin();
90 for (
size_t i = 0; i < width; ++i)
92 (*this)(i, j, k) = *widthIter;
101 template <
typename T>
104 m_size =
Size3(0, 0, 0);
108 template <
typename T>
112 grid.m_data.resize(size.
x * size.
y * size.
z, initVal);
115 size_t iMin = std::min(size.
x, m_size.x);
116 size_t jMin = std::min(size.
y, m_size.y);
117 size_t kMin = std::min(size.
z, m_size.z);
119 for (
size_t k = 0; k < kMin; ++k)
121 for (
size_t j = 0; j < jMin; ++j)
123 for (
size_t i = 0; i < iMin; ++i)
125 grid(i, j, k) = At(i, j, k);
133 template <
typename T>
136 Resize(
Size3(width, height, depth), initVal);
139 template <
typename T>
142 assert(i < Width() * Height() * Depth());
146 template <
typename T>
149 assert(i < Width() * Height() * Depth());
153 template <
typename T>
156 return At(pt.
x, pt.
y, pt.
z);
159 template <
typename T>
162 return At(pt.
x, pt.
y, pt.
z);
165 template <
typename T>
168 assert(i < Width() && j < Height() && k < Depth());
169 return m_data[i + Width() * j + Width() * Height() * k];
172 template <
typename T>
175 assert(i < Width() && j < Height() && k < Depth());
176 return m_data[i + Width() * j + Width() * Height() * k];
179 template <
typename T>
185 template <
typename T>
191 template <
typename T>
197 template <
typename T>
203 template <
typename T>
206 return m_data.data();
209 template <
typename T>
212 return m_data.data();
215 template <
typename T>
218 return m_data.begin();
221 template <
typename T>
224 return m_data.cbegin();
227 template <
typename T>
233 template <
typename T>
236 return m_data.cend();
239 template <
typename T>
245 template <
typename T>
251 template <
typename T>
254 std::swap(other.m_data, m_data);
255 std::swap(other.m_size, m_size);
258 template <
typename T>
259 template <
typename Callback>
262 ConstAccessor().ForEach(func);
265 template <
typename T>
266 template <
typename Callback>
269 ConstAccessor().ForEachIndex(func);
272 template <
typename T>
273 template <
typename Callback>
276 Accessor().ParallelForEach(func);
279 template <
typename T>
280 template <
typename Callback>
283 ConstAccessor().ParallelForEachIndex(func);
286 template <
typename T>
292 template <
typename T>
298 template <
typename T>
301 assert(i < Width() && j < Height() && k < Depth());
302 return m_data[i + Width() * j + Width() * Height() * k];
305 template <
typename T>
308 assert(i < Width() && j < Height() && k < Depth());
309 return m_data[i + Width() * j + Width() * Height() * k];
312 template <
typename T>
315 assert(pt.
x < Width() && pt.
y < Height() && pt.
z < Depth());
316 return m_data[pt.
x + Width() * pt.
y + Width() * Height() * pt.
z];
319 template <
typename T>
322 assert(pt.
x < Width() && pt.
y < Height() && pt.
z < Depth());
323 return m_data[pt.
x + Width() * pt.
y + Width() * Height() * pt.
z];
326 template <
typename T>
333 template <
typename T>
340 template <
typename T>
343 m_data = std::move(other.m_data);
344 m_size = other.m_size;
345 other.m_size =
Size3();
349 template <
typename T>
356 template <
typename T>
362 template <
typename T>
365 return ConstAccessor();
3-D array accessor class.
Definition: ArrayAccessor3.h:31
3-D read-only array accessor class.
Definition: ArrayAccessor3.h:269
3-D point class.
Definition: Point3.h:26
Definition: pybind11Utils.h:24
Generic N-dimensional array class interface.
Definition: Array.h:28
T z
Z (or the third) component of the point.
Definition: Point3.h:38
T y
Y (or the second) component of the point.
Definition: Point3.h:35
T x
X (or the first) component of the point.
Definition: Point3.h:29
3-D array class.
Definition: Array3.h:45
Point3< size_t > Size3
Definition: Size3.h:16