21 #ifndef __MIA_3DDATAFIELD_HH
22 #define __MIA_3DDATAFIELD_HH 1
36 #include <miaconfig.h>
41 #define DECLARE_EXTERN_ITERATORS(TYPE) \
42 extern template class EXPORT_3D range3d_iterator<std::vector<TYPE>::iterator>; \
43 extern template class EXPORT_3D range3d_iterator<std::vector<TYPE>::const_iterator>; \
44 extern template class EXPORT_3D range3d_iterator_with_boundary_flag<std::vector<TYPE>::iterator>; \
45 extern template class EXPORT_3D range3d_iterator_with_boundary_flag<std::vector<TYPE>::const_iterator>; \
46 extern template class EXPORT_3D range2d_iterator<std::vector<TYPE>::iterator>; \
47 extern template class EXPORT_3D range2d_iterator<std::vector<TYPE>::const_iterator>;
76 typedef ::std::vector<T> data_array;
78 typedef std::shared_ptr<data_array> ref_data_type;
92 static const size_t m_elements;
99 void make_single_ref();
106 return m_data.unique();
113 typedef typename std::vector<T>::iterator iterator;
114 typedef typename std::vector<T>::const_iterator const_iterator;
115 typedef typename std::vector<T>::const_reference const_reference;
116 typedef typename std::vector<T>::reference reference;
117 typedef typename std::vector<T>::const_pointer const_pointer;
118 typedef typename std::vector<T>::pointer pointer;
119 typedef typename std::vector<T>::value_type value_type;
120 typedef typename std::vector<T>::size_type size_type;
121 typedef typename std::vector<T>::difference_type difference_type;
122 typedef typename atomic_data<T>::type atomic_type;
142 friend class T3DDatafield<T>;
161 friend class T3DDatafield<T>;
165 iterator
begin()
const;
167 iterator
end()
const;
208 template <
typename Out>
212 template <
typename Out>
216 template <
typename Out>
239 T3DDatafield&
operator = (
const T3DDatafield& org);
253 return m_data->size();
257 void swap(T3DDatafield& other);
271 const_reference
operator()(
size_t x,
size_t y,
size_t z)
const
274 if (x < m_size.
x && y < m_size.
y && z < m_size.
z) {
275 const std::vector<T>& data = *m_data;
276 return data[x+ m_size.
x * (y + m_size.
y * z)];
285 return (*
this)(l.
x,l.
y,l.
z);
293 assert(x < m_size.
x && y < m_size.
y && z < m_size.
z);
294 return (*m_data)[x + m_size.
x *(y + m_size.
y * z)];
302 return (*
this)(l.
x,l.
y,l.
z);
324 template <
class TMask>
325 void mask(
const TMask& m);
434 return m_data->begin();
440 const_iterator
begin_at(
size_t x,
size_t y,
size_t z)
const
442 return m_data->begin() + (z * m_size.
y + y) * m_size.
x + x;
451 return m_data->end();
460 return m_data->begin();
508 return m_data->begin() + (z * m_size.
y + y) * m_size.
x + x;
517 return m_data->end();
531 assert(m_data.unique());
583 template <
typename Out>
586 const std::vector<T>& data = *m_data;
587 const int sizex = m_size.x;
589 if (x - 1 < m_size.x - 2 && y - 1 < m_size.y - 2 && z - 1 < m_size.z - 2) {
592 const T *H = &data[x + m_size.x * (y + m_size.y * z)];
595 Out((H[sizex] - H[-sizex]) * 0.5),
596 Out((H[m_xy] - H[-m_xy]) * 0.5));
604 template <
typename Out>
607 const int sizex = m_size.x;
609 const T *H = &(*m_data)[hardcode];
612 Out((H[sizex] - H[-sizex]) * 0.5),
613 Out((H[m_xy] - H[-m_xy]) * 0.5));
621 template <
typename Out>
626 return T3DVector<Out> (Out(((*m_data)[hardcode + 1] - (*m_data)[hardcode -1]) * 0.5),
627 Out(((*m_data)[hardcode + m_size.x] - (*m_data)[hardcode -m_size.x]) * 0.5),
628 Out(((*m_data)[hardcode + m_xy] - (*m_data)[hardcode -m_xy]) * 0.5));
632 template <
typename Out>
636 const int sizex = m_size.x;
637 const std::vector<T>& data = *m_data;
640 size_t x = size_t (p.
x);
643 size_t y = size_t (p.
y);
646 size_t z = size_t (p.
z);
651 if (x-1 < m_size.x-3 && y -1 < m_size.y-3 && z - 1 < m_size.z-3 ) {
653 const T *H000 = &data[x + sizex * y + m_xy * z];
655 const T* H_100 = &H000[-m_xy];
656 const T* H_101 = &H_100[1];
657 const T* H_110 = &H_100[sizex];
658 const T* H_111 = &H_110[1];
660 const T* H0_10 = &H000[-sizex];
661 const T* H0_11 = &H0_10[1];
663 const T* H00_1 = &H000[-1];
664 const T* H001 = &H000[ 1];
665 const T* H002 = &H000[ 2];
668 const T* H010 = &H000[sizex];
669 const T* H011 = &H010[ 1];
670 const T* H012 = &H010[ 2];
671 const T* H01_1 = &H010[-1];
673 const T* H020 = &H010[sizex];
674 const T* H021 = &H020[ 1];
676 const T* H100 = &H000[m_xy];
678 const T* H1_10 = &H100[sizex];
679 const T* H1_11 = &H1_10[1];
681 const T* H10_1 = &H100[-1];
682 const T* H101 = &H100[ 1];
683 const T* H102 = &H100[ 2];
685 const T* H110 = &H100[sizex];
686 const T* H111 = &H110[ 1];
687 const T* H112 = &H110[ 2];
688 const T* H11_1 = &H110[-1];
690 const T* H120 = &H110[sizex];
691 const T* H121 = &H120[ 1];
693 const T* H200 = &H100[m_xy];
694 const T* H201 = &H200[1];
695 const T* H210 = &H200[sizex];
696 const T* H211 = &H210[1];
700 Out((zm * (ym * (dx * (*H002 - *H000) + xm * (*H001 - *H00_1))+
701 dy * (dx * (*H012 - *H010) + xm * (*H011 - *H01_1)))+
702 dz * (ym * (dx * (*H102 - *H100) + xm * (*H101 - *H10_1))+
703 dy * (dx * (*H112 - *H110) + xm * (*H111 - *H11_1)))) * 0.5),
705 Out((zm * (ym * (xm * (*H010 - *H0_10) + dx * (*H011 - *H0_11))+
706 dy * (xm * (*H020 - *H000) + dx * (*H021 - *H001)))+
707 dz * (ym * (xm * (*H110 - *H1_10) + dx * (*H111 - *H1_11))+
708 dy * (xm * (*H120 - *H100) + dx * (*H121 - *H101)))) * 0.5),
709 Out((zm * (ym * (xm * (*H100 - *H_100) + dx * (*H101 - *H_101))+
710 dy * (xm * (*H110 - *H_110) + dx * (*H111 - *H_111)))+
711 dz * (ym * (xm * (*H200 - *H000) + dx * (*H201 - *H001))+
712 dy * (xm * (*H210 - *H010) + dx * (*H211 - *H011)))) * 0.5));
719 #pragma GCC diagnostic push
721 #pragma GCC diagnostic ignored "-Wattributes"
725 #define DECLARE_EXTERN(TYPE) \
726 extern template class EXPORT_3D T3DDatafield<TYPE>;
746 #undef DECLARE_EXTERN
749 #pragma GCC diagnostic pop
T2DDatafield< T > get_data_plane_yz(size_t x) const
T3DDatafield< T >::range_iterator iterator
void put_data_plane_xy(size_t z, const T2DDatafield< T > &p)
range_iterator begin_range(const C3DBounds &begin, const C3DBounds &end)
T3DVector< Out > get_gradient(const T3DVector< float > &p) const
T2DDatafield< T > get_data_plane_xz(size_t y) const
a 3D iterator that knows its position in the 3D grid ans supports iterating over sub-ranges ...
void swap(T3DDatafield &other)
swap the data ofthis 3DDatafield with another one
Generic string vs. attribute translator singleton.
void write_yslice_flat(size_t y, const std::vector< atomic_type > &buffer)
void put_data_line_y(int x, int z, const std::vector< T > &buffer)
range_iterator_with_boundary_flag begin_range_with_boundary_flags(const C3DBounds &begin, const C3DBounds &end)
a 3D iterator that knows its position in the 3D grid, has a flag indicating whether it is on a bounda...
value_type get_trilin_interpol_val_at(const T3DVector< float > &p) const
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
void read_zslice_flat(size_t z, std::vector< atomic_type > &buffer) 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
void read_yslice_flat(size_t y, std::vector< atomic_type > &buffer) const
const_reference operator()(const C3DBounds &l) const
TTranslator< C3DFVector > C3DFVectorTranslator
Range get_range(const C3DBounds &start, const C3DBounds &end)
T3DDatafield< unsigned int > C3DUIDatafield
a data field of 32 bit unsigned int values
void get_data_line_z(int x, int y, std::vector< T > &buffer) const
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)
void write_xslice_flat(size_t x, const std::vector< atomic_type > &buffer)
T3DDatafield< T >::const_range_iterator iterator
CTParameter< C3DFVector > C3DFVectorParameter
3D vector parameter type
const C3DBounds & get_size() const
#define DECLARE_EXTERN(TYPE)
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.
T2DDatafield< T > get_data_plane_xy(size_t z) const
void put_data_line_z(int x, int y, const std::vector< T > &buffer)
void write_zslice_flat(size_t z, const std::vector< atomic_type > &buffer)
const_iterator end() const
#define DECLARE_EXTERN_ITERATORS(TYPE)
T3DDatafield & operator=(const T3DDatafield &org)
void read_xslice_flat(size_t x, std::vector< atomic_type > &buffer) const
void put_data_plane_xz(size_t y, const T2DDatafield< T > &p)
range_iterator_with_boundary_flag end_range_with_boundary_flags(const C3DBounds &begin, const C3DBounds &end)
void mask(const TMask &m)
T3DDatafield< int > C3DIDatafield
a data field of 32 bit signed int values
virtual ~T3DDatafield()
make sure the destructor is virtual
range_iterator end_range(const C3DBounds &begin, const C3DBounds &end)
value_type get_interpol_val_at(const T3DVector< float > &p) const
void get_data_line_x(int y, int z, std::vector< T > &buffer) const
reference operator()(size_t x, size_t y, size_t z)
value_type operator()(const T3DVector< float > &pos) const
void put_data_plane_yz(size_t x, const T2DDatafield< T > &p)
void get_data_line_y(int x, int z, std::vector< T > &buffer) const
value_type get_block_avrg(const C3DBounds &Start, const C3DBounds &BlockSize) const
reference operator()(const C3DBounds &l)
const_iterator begin() const
T3DDatafield< unsigned long > C3DULDatafield
a data field of 32 bit unsigned int values
void put_data_line_x(int y, int z, const std::vector< T > &buffer)
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