21 #ifndef __MIA_3DDATAFIELD_HH
22 #define __MIA_3DDATAFIELD_HH 1
36 #include <miaconfig.h>
47 typedef ::std::vector<T> data_array;
49 typedef std::shared_ptr<data_array> ref_data_type;
63 static const unsigned int m_elements;
69 void make_single_ref();
76 return m_data.unique();
83 typedef typename std::vector<T>::iterator iterator;
84 typedef typename std::vector<T>::const_iterator const_iterator;
85 typedef typename std::vector<T>::const_reference const_reference;
86 typedef typename std::vector<T>::reference reference;
87 typedef typename std::vector<T>::const_pointer const_pointer;
88 typedef typename std::vector<T>::pointer pointer;
89 typedef typename std::vector<T>::value_type value_type;
90 typedef typename std::vector<T>::size_type size_type;
91 typedef typename std::vector<T>::difference_type difference_type;
92 typedef typename atomic_data<T>::type atomic_type;
131 template <
typename Out>
135 template <
typename Out>
139 template <
typename Out>
176 return m_data->size();
183 value_type get_avg();
187 value_type strip_avg();
194 const_reference
operator()(
size_t x,
size_t y,
size_t z)
const
197 if (x < m_size.
x && y < m_size.
y && z < m_size.
z) {
198 const std::vector<T>& data = *m_data;
199 return data[x+ m_size.
x * (y + m_size.
y * z)];
208 return (*
this)(l.
x,l.
y,l.
z);
216 assert(x < m_size.
x && y < m_size.
y && z < m_size.
z);
217 return (*m_data)[x + m_size.
x *(y + m_size.
y * z)];
225 return (*
this)(l.
x,l.
y,l.
z);
229 void get_data_line_x(
int y,
int z, std::vector<T>& buffer)
const;
232 void get_data_line_y(
int x,
int z, std::vector<T>& buffer)
const;
235 void get_data_line_z(
int x,
int y, std::vector<T>& buffer)
const;
238 void put_data_line_x(
int y,
int z,
const std::vector<T> &buffer);
241 void put_data_line_y(
int x,
int z,
const std::vector<T> &buffer);
244 void put_data_line_z(
int x,
int y,
const std::vector<T> &buffer);
247 template <
class TMask>
248 void mask(
const TMask& m);
263 void read_xslice_flat(
size_t x, std::vector<atomic_type>& buffer)
const;
277 void read_yslice_flat(
size_t y, std::vector<atomic_type>& buffer)
const;
291 void read_zslice_flat(
size_t z, std::vector<atomic_type>& buffer)
const;
297 void write_zslice_flat(
size_t z,
const std::vector<atomic_type>& buffer);
304 void write_yslice_flat(
size_t y,
const std::vector<atomic_type>& buffer);
310 void write_xslice_flat(
size_t x,
const std::vector<atomic_type>& buffer);
357 return m_data->begin();
363 const_iterator
begin_at(
size_t x,
size_t y,
size_t z)
const
365 return m_data->begin() + (z * m_size.
y + y) * m_size.
x + x;
374 return m_data->end();
383 return m_data->begin();
403 range_iterator_with_boundary_flag begin_range_with_boundary_flags(
const C3DBounds& begin,
const C3DBounds& end);
406 range_iterator_with_boundary_flag end_range_with_boundary_flags(
const C3DBounds& begin,
const C3DBounds& end);
410 const_range_iterator_with_boundary_flag begin_range_with_boundary_flags(
const C3DBounds& begin,
const C3DBounds& end)
const;
413 const_range_iterator_with_boundary_flag end_range_with_boundary_flags(
const C3DBounds& begin,
const C3DBounds& end)
const;
427 return m_data->begin() + (z * m_size.
y + y) * m_size.
x + x;
436 return m_data->end();
450 assert(m_data.unique());
501 template <
typename Out>
504 const std::vector<T>& data = *m_data;
505 const int sizex = m_size.x;
507 if (x - 1 < m_size.x - 2 && y - 1 < m_size.y - 2 && z - 1 < m_size.z - 2) {
510 const T *H = &data[x + m_size.x * (y + m_size.y * z)];
513 Out((H[sizex] - H[-sizex]) * 0.5),
514 Out((H[m_xy] - H[-m_xy]) * 0.5));
522 template <
typename Out>
525 const int sizex = m_size.x;
527 const T *H = &(*m_data)[hardcode];
530 Out((H[sizex] - H[-sizex]) * 0.5),
531 Out((H[m_xy] - H[-m_xy]) * 0.5));
539 template <
typename Out>
544 return T3DVector<Out> (Out(((*m_data)[hardcode + 1] - (*m_data)[hardcode -1]) * 0.5),
545 Out(((*m_data)[hardcode + m_size.x] - (*m_data)[hardcode -m_size.x]) * 0.5),
546 Out(((*m_data)[hardcode + m_xy] - (*m_data)[hardcode -m_xy]) * 0.5));
550 template <
typename Out>
554 const int sizex = m_size.x;
555 const std::vector<T>& data = *m_data;
558 size_t x = size_t (p.
x);
561 size_t y = size_t (p.
y);
564 size_t z = size_t (p.
z);
569 if (x-1 < m_size.x-3 && y -1 < m_size.y-3 && z - 1 < m_size.z-3 ) {
571 const T *H000 = &data[x + sizex * y + m_xy * z];
573 const T* H_100 = &H000[-m_xy];
574 const T* H_101 = &H_100[1];
575 const T* H_110 = &H_100[sizex];
576 const T* H_111 = &H_110[1];
578 const T* H0_10 = &H000[-sizex];
579 const T* H0_11 = &H0_10[1];
581 const T* H00_1 = &H000[-1];
582 const T* H001 = &H000[ 1];
583 const T* H002 = &H000[ 2];
586 const T* H010 = &H000[sizex];
587 const T* H011 = &H010[ 1];
588 const T* H012 = &H010[ 2];
589 const T* H01_1 = &H010[-1];
591 const T* H020 = &H010[sizex];
592 const T* H021 = &H020[ 1];
594 const T* H100 = &H000[m_xy];
596 const T* H1_10 = &H100[sizex];
597 const T* H1_11 = &H1_10[1];
599 const T* H10_1 = &H100[-1];
600 const T* H101 = &H100[ 1];
601 const T* H102 = &H100[ 2];
603 const T* H110 = &H100[sizex];
604 const T* H111 = &H110[ 1];
605 const T* H112 = &H110[ 2];
606 const T* H11_1 = &H110[-1];
608 const T* H120 = &H110[sizex];
609 const T* H121 = &H120[ 1];
611 const T* H200 = &H100[m_xy];
612 const T* H201 = &H200[1];
613 const T* H210 = &H200[sizex];
614 const T* H211 = &H210[1];
618 Out((zm * (ym * (dx * (*H002 - *H000) + xm * (*H001 - *H00_1))+
619 dy * (dx * (*H012 - *H010) + xm * (*H011 - *H01_1)))+
620 dz * (ym * (dx * (*H102 - *H100) + xm * (*H101 - *H10_1))+
621 dy * (dx * (*H112 - *H110) + xm * (*H111 - *H11_1)))) * 0.5),
623 Out((zm * (ym * (xm * (*H010 - *H0_10) + dx * (*H011 - *H0_11))+
624 dy * (xm * (*H020 - *H000) + dx * (*H021 - *H001)))+
625 dz * (ym * (xm * (*H110 - *H1_10) + dx * (*H111 - *H1_11))+
626 dy * (xm * (*H120 - *H100) + dx * (*H121 - *H101)))) * 0.5),
627 Out((zm * (ym * (xm * (*H100 - *H_100) + dx * (*H101 - *H_101))+
628 dy * (xm * (*H110 - *H_110) + dx * (*H111 - *H_111)))+
629 dz * (ym * (xm * (*H200 - *H000) + dx * (*H201 - *H001))+
630 dy * (xm * (*H210 - *H010) + dx * (*H211 - *H011)))) * 0.5));
T3DVector< Out > get_gradient(const T3DVector< float > &p) const
a 3D iterator that knows its position in the 3D grid ans supports iterating over sub-ranges ...
a 3D iterator that knows its position in the 3D grid, has a flag indicating whether it is on a bounda...
A templated class of a 3D data field.
iterator begin_at(size_t x, size_t y, size_t z)
const_iterator begin_at(size_t x, size_t y, size_t z) const
T3DDatafield< unsigned char > C3DUBDatafield
a data field of float values
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
T3DDatafield< bool > C3DBitDatafield
a data field of float values
reference operator[](int i)
CTParameter< C3DBounds > C3DBoundsParameter
3D size parameter type
const_reference operator()(const C3DBounds &l) const
T3DDatafield< unsigned int > C3DUIDatafield
a data field of 32 bit unsigned int values
Generic type of a complex paramter.
const_reference operator[](int i) const
T3DDatafield< long > C3DLDatafield
a data field of 32 bit signed int values
EXPORT_2D C2DFVectorfield get_gradient(const C2DImage &image)
CTParameter< C3DFVector > C3DFVectorParameter
3D vector parameter type
const C3DBounds & get_size() const
size_t get_plane_size_xy() const
const_reference operator()(size_t x, size_t y, size_t z) const
A class to hold data on a regular 2D grid.
const_iterator end() const
T3DDatafield< int > C3DIDatafield
a data field of 32 bit signed int values
reference operator()(size_t x, size_t y, size_t z)
reference operator()(const C3DBounds &l)
const_iterator begin() const
T3DDatafield< unsigned long > C3DULDatafield
a data field of 32 bit unsigned int values
T3DDatafield< float > C3DFDatafield
a data field of float values
bool holds_unique_data() const
#define NS_MIA_END
conveniance define to end the mia namespace