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>; 51 #pragma GCC diagnostic push 53 #pragma GCC diagnostic ignored "-Wattributes" 76 #pragma GCC diagnostic pop 86 typedef ::std::vector<typename __holder_type_dispatch<T>::type> data_array;
88 typedef std::shared_ptr<data_array> ref_data_type;
95 void make_single_ref();
102 return m_data.unique();
109 typedef typename data_array::iterator iterator;
110 typedef typename data_array::const_iterator const_iterator;
111 typedef typename data_array::const_reference const_reference;
112 typedef typename data_array::reference reference;
113 typedef typename data_array::const_pointer const_pointer;
114 typedef typename data_array::pointer pointer;
115 typedef typename data_array::value_type value_type;
116 typedef typename data_array::size_type size_type;
117 typedef typename data_array::difference_type difference_type;
118 typedef typename atomic_data<value_type>::type atomic_type;
161 iterator
begin()
const;
163 iterator
end()
const;
204 template <
typename Out>
208 template <
typename Out>
212 template <
typename Out>
249 return m_data->size();
267 const_reference
operator()(
size_t x,
size_t y,
size_t z)
const 270 if (x < m_size.x && y < m_size.y && z < m_size.z) {
271 const data_array& data = *m_data;
272 return data[x+ m_size.x * (y + m_size.y * z)];
281 return (*
this)(l.
x,l.
y,l.
z);
289 assert(x < m_size.x && y < m_size.y && z < m_size.z);
290 return (*m_data)[x + m_size.x *(y + m_size.y * z)];
298 return (*
this)(l.
x,l.
y,l.
z);
320 template <
class TMask>
321 void mask(
const TMask& m);
430 return m_data->begin();
436 const_iterator
begin_at(
size_t x,
size_t y,
size_t z)
const 438 return m_data->begin() + (z * m_size.y + y) * m_size.x + x;
447 return m_data->end();
456 return m_data->begin();
504 return m_data->begin() + (z * m_size.y + y) * m_size.x + x;
513 return m_data->end();
527 assert(m_data.unique());
546 ref_data_type m_data;
549 static const value_type Zero;
551 static const size_t m_elements;
595 template <
typename Out>
598 const std::vector<T>& data = *m_data;
599 const int sizex = m_size.x;
601 if (x - 1 < m_size.x - 2 && y - 1 < m_size.y - 2 && z - 1 < m_size.z - 2) {
604 const T *H = &data[x + m_size.x * (y + m_size.y * z)];
607 Out((H[sizex] - H[-sizex]) * 0.5),
608 Out((H[m_xy] - H[-m_xy]) * 0.5));
616 template <
typename Out>
619 const int sizex = m_size.x;
621 const T *H = &(*m_data)[hardcode];
624 Out((H[sizex] - H[-sizex]) * 0.5),
625 Out((H[m_xy] - H[-m_xy]) * 0.5));
633 template <
typename Out>
638 return T3DVector<Out> (Out(((*m_data)[hardcode + 1] - (*m_data)[hardcode -1]) * 0.5),
639 Out(((*m_data)[hardcode + m_size.x] - (*m_data)[hardcode -m_size.x]) * 0.5),
640 Out(((*m_data)[hardcode + m_xy] - (*m_data)[hardcode -m_xy]) * 0.5));
644 template <
typename Out>
648 const int sizex = m_size.x;
649 const std::vector<T>& data = *m_data;
652 size_t x = size_t (p.
x);
655 size_t y = size_t (p.
y);
658 size_t z = size_t (p.
z);
663 if (x-1 < m_size.x-3 && y -1 < m_size.y-3 && z - 1 < m_size.z-3 ) {
665 const T *H000 = &data[x + sizex * y + m_xy * z];
667 const T* H_100 = &H000[-m_xy];
668 const T* H_101 = &H_100[1];
669 const T* H_110 = &H_100[sizex];
670 const T* H_111 = &H_110[1];
672 const T* H0_10 = &H000[-sizex];
673 const T* H0_11 = &H0_10[1];
675 const T* H00_1 = &H000[-1];
676 const T* H001 = &H000[ 1];
677 const T* H002 = &H000[ 2];
680 const T* H010 = &H000[sizex];
681 const T* H011 = &H010[ 1];
682 const T* H012 = &H010[ 2];
683 const T* H01_1 = &H010[-1];
685 const T* H020 = &H010[sizex];
686 const T* H021 = &H020[ 1];
688 const T* H100 = &H000[m_xy];
690 const T* H1_10 = &H100[sizex];
691 const T* H1_11 = &H1_10[1];
693 const T* H10_1 = &H100[-1];
694 const T* H101 = &H100[ 1];
695 const T* H102 = &H100[ 2];
697 const T* H110 = &H100[sizex];
698 const T* H111 = &H110[ 1];
699 const T* H112 = &H110[ 2];
700 const T* H11_1 = &H110[-1];
702 const T* H120 = &H110[sizex];
703 const T* H121 = &H120[ 1];
705 const T* H200 = &H100[m_xy];
706 const T* H201 = &H200[1];
707 const T* H210 = &H200[sizex];
708 const T* H211 = &H210[1];
712 Out((zm * (ym * (dx * (*H002 - *H000) + xm * (*H001 - *H00_1))+
713 dy * (dx * (*H012 - *H010) + xm * (*H011 - *H01_1)))+
714 dz * (ym * (dx * (*H102 - *H100) + xm * (*H101 - *H10_1))+
715 dy * (dx * (*H112 - *H110) + xm * (*H111 - *H11_1)))) * 0.5),
717 Out((zm * (ym * (xm * (*H010 - *H0_10) + dx * (*H011 - *H0_11))+
718 dy * (xm * (*H020 - *H000) + dx * (*H021 - *H001)))+
719 dz * (ym * (xm * (*H110 - *H1_10) + dx * (*H111 - *H1_11))+
720 dy * (xm * (*H120 - *H100) + dx * (*H121 - *H101)))) * 0.5),
721 Out((zm * (ym * (xm * (*H100 - *H_100) + dx * (*H101 - *H_101))+
722 dy * (xm * (*H110 - *H_110) + dx * (*H111 - *H_111)))+
723 dz * (ym * (xm * (*H200 - *H000) + dx * (*H201 - *H001))+
724 dy * (xm * (*H210 - *H010) + dx * (*H211 - *H011)))) * 0.5));
731 #pragma GCC diagnostic push 733 #pragma GCC diagnostic ignored "-Wattributes" 737 #define DECLARE_EXTERN(TYPE) \ 738 extern template class EXPORT_3D T3DDatafield<TYPE>; 761 extern template class EXPORT_3D TAttribute<C3DFVector>;
764 #undef DECLARE_EXTERN 767 #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
Class of an attribute that holds data of type T.
#define NS_MIA_END
conveniance define to end the mia namespace