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" 74 #pragma GCC diagnostic pop 84 typedef ::std::vector<typename __holder_type_dispatch<T>::type> data_array;
91 void make_single_ref() __attribute__((deprecated));
105 typedef typename data_array::iterator iterator;
106 typedef typename data_array::const_iterator const_iterator;
107 typedef typename data_array::const_reference const_reference;
108 typedef typename data_array::reference reference;
109 typedef typename data_array::const_pointer const_pointer;
110 typedef typename data_array::pointer pointer;
111 typedef typename data_array::value_type value_type;
112 typedef typename data_array::size_type size_type;
113 typedef typename data_array::difference_type difference_type;
114 typedef typename atomic_data<value_type>::type atomic_type;
157 iterator
begin()
const;
159 iterator
end()
const;
203 template <
typename Out>
207 template <
typename Out>
211 template <
typename Out>
242 return m_data.size();
256 const_reference
operator()(
size_t x,
size_t y,
size_t z)
const 259 if (x < m_size.x && y < m_size.y && z < m_size.z) {
260 return m_data[x+ m_size.x * (y + m_size.y * z)];
269 return (*
this)(l.
x,l.
y,l.
z);
277 assert(x < m_size.x && y < m_size.y && z < m_size.z);
278 return m_data[x + m_size.x *(y + m_size.y * z)];
286 return (*
this)(l.
x,l.
y,l.
z);
308 template <
class TMask>
309 void mask(
const TMask& m);
418 return m_data.begin();
424 const_iterator
begin_at(
size_t x,
size_t y,
size_t z)
const 426 return m_data.begin() + (z * m_size.y + y) * m_size.x + x;
443 return m_data.begin();
490 return m_data.begin() + (z * m_size.y + y) * m_size.x + x;
533 static const value_type Zero;
535 static const size_t m_elements;
588 template <
typename Out>
591 const int sizex = m_size.x;
593 if (x - 1 < m_size.x - 2 && y - 1 < m_size.y - 2 && z - 1 < m_size.z - 2) {
596 const T *H = &m_data[x + m_size.x * (y + m_size.y * z)];
599 Out((H[sizex] - H[-sizex]) * 0.5),
600 Out((H[m_xy] - H[-m_xy]) * 0.5));
608 template <
typename Out>
611 const int sizex = m_size.x;
613 const T *H = &m_data[hardcode];
616 Out((H[sizex] - H[-sizex]) * 0.5),
617 Out((H[m_xy] - H[-m_xy]) * 0.5));
625 template <
typename Out>
630 return T3DVector<Out> (Out((m_data[hardcode + 1] - m_data[hardcode -1]) * 0.5),
631 Out((m_data[hardcode + m_size.x] - m_data[hardcode -m_size.x]) * 0.5),
632 Out((m_data[hardcode + m_xy] - m_data[hardcode -m_xy]) * 0.5));
636 template <
typename Out>
640 const int sizex = m_size.x;
643 size_t x = size_t (p.
x);
646 size_t y = size_t (p.
y);
649 size_t z = size_t (p.
z);
654 if (x-1 < m_size.x-3 && y -1 < m_size.y-3 && z - 1 < m_size.z-3 ) {
656 const T *H000 = &m_data[x + sizex * y + m_xy * z];
658 const T* H_100 = &H000[-m_xy];
659 const T* H_101 = &H_100[1];
660 const T* H_110 = &H_100[sizex];
661 const T* H_111 = &H_110[1];
663 const T* H0_10 = &H000[-sizex];
664 const T* H0_11 = &H0_10[1];
666 const T* H00_1 = &H000[-1];
667 const T* H001 = &H000[ 1];
668 const T* H002 = &H000[ 2];
671 const T* H010 = &H000[sizex];
672 const T* H011 = &H010[ 1];
673 const T* H012 = &H010[ 2];
674 const T* H01_1 = &H010[-1];
676 const T* H020 = &H010[sizex];
677 const T* H021 = &H020[ 1];
679 const T* H100 = &H000[m_xy];
681 const T* H1_10 = &H100[sizex];
682 const T* H1_11 = &H1_10[1];
684 const T* H10_1 = &H100[-1];
685 const T* H101 = &H100[ 1];
686 const T* H102 = &H100[ 2];
688 const T* H110 = &H100[sizex];
689 const T* H111 = &H110[ 1];
690 const T* H112 = &H110[ 2];
691 const T* H11_1 = &H110[-1];
693 const T* H120 = &H110[sizex];
694 const T* H121 = &H120[ 1];
696 const T* H200 = &H100[m_xy];
697 const T* H201 = &H200[1];
698 const T* H210 = &H200[sizex];
699 const T* H211 = &H210[1];
703 Out((zm * (ym * (dx * (*H002 - *H000) + xm * (*H001 - *H00_1))+
704 dy * (dx * (*H012 - *H010) + xm * (*H011 - *H01_1)))+
705 dz * (ym * (dx * (*H102 - *H100) + xm * (*H101 - *H10_1))+
706 dy * (dx * (*H112 - *H110) + xm * (*H111 - *H11_1)))) * 0.5),
708 Out((zm * (ym * (xm * (*H010 - *H0_10) + dx * (*H011 - *H0_11))+
709 dy * (xm * (*H020 - *H000) + dx * (*H021 - *H001)))+
710 dz * (ym * (xm * (*H110 - *H1_10) + dx * (*H111 - *H1_11))+
711 dy * (xm * (*H120 - *H100) + dx * (*H121 - *H101)))) * 0.5),
712 Out((zm * (ym * (xm * (*H100 - *H_100) + dx * (*H101 - *H_101))+
713 dy * (xm * (*H110 - *H_110) + dx * (*H111 - *H_111)))+
714 dz * (ym * (xm * (*H200 - *H000) + dx * (*H201 - *H001))+
715 dy * (xm * (*H210 - *H010) + dx * (*H211 - *H011)))) * 0.5));
722 #pragma GCC diagnostic push 724 #pragma GCC diagnostic ignored "-Wattributes" 728 #define DECLARE_EXTERN(TYPE) \ 729 extern template class EXPORT_3D T3DDatafield<TYPE>; 749 extern template class EXPORT_3D TAttribute<C3DFVector>;
752 #undef DECLARE_EXTERN 755 #pragma GCC diagnostic pop
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)
const_reference operator()(const C3DBounds &l) const
T3DDatafield< int64_t > C3DLDatafield
a data field of 32 bit signed int values
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.
const_iterator end() const
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...
A templated class of a 3D data field.
iterator begin_at(size_t x, size_t y, size_t z)
void read_zslice_flat(size_t z, std::vector< atomic_type > &buffer) const
T3DDatafield< uint64_t > C3DULDatafield
a data field of 32 bit unsigned int values
T2DDatafield< T > get_data_plane_xz(size_t y) const
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
T3DDatafield< uint16_t > C3DUSDatafield
a data field of 32 bit unsigned int values
T3DDatafield< bool > C3DBitDatafield
a data field of float values
const_iterator begin() const
value_type get_block_avrg(const C3DBounds &Start, const C3DBounds &BlockSize) const
void get_data_line_x(int y, int z, std::vector< T > &buffer) const
reference operator[](int i)
CTParameter< C3DBounds > C3DBoundsParameter
3D size parameter type
void get_data_line_y(int x, int z, std::vector< T > &buffer) const
TTranslator< C3DFVector > C3DFVectorTranslator
Range get_range(const C3DBounds &start, const C3DBounds &end)
const_iterator begin_at(size_t x, size_t y, size_t z) const
Generic type of a complex paramter.
EXPORT_2D C2DFVectorfield get_gradient(const C2DImage &image)
T3DDatafield< int8_t > C3DSBDatafield
a data field of 8 bit int values
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
#define DECLARE_EXTERN(TYPE)
const C3DBounds & get_size() const
value_type get_interpol_val_at(const T3DVector< float > &p) const __attribute__((deprecated))
T3DDatafield< int32_t > C3DSIDatafield
a data field of 32 bit signed int values
void read_xslice_flat(size_t x, std::vector< atomic_type > &buffer) const
A class to hold data on a regular 2D grid.
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_reference operator[](int i) const
#define DECLARE_EXTERN_ITERATORS(TYPE)
T3DDatafield & operator=(const T3DDatafield &org)
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)
const_reference operator()(size_t x, size_t y, size_t z) const
T2DDatafield< T > get_data_plane_yz(size_t x) const
T3DDatafield< int16_t > C3DSSDatafield
a data field of 32 bit signed int values
void read_yslice_flat(size_t y, std::vector< atomic_type > &buffer) const
virtual ~T3DDatafield()
make sure the destructor is virtual
T3DDatafield< uint8_t > C3DUBDatafield
a data field of 8 bit int values
range_iterator end_range(const C3DBounds &begin, const C3DBounds &end)
T2DDatafield< T > get_data_plane_xy(size_t z) const
reference operator()(size_t x, size_t y, size_t z)
size_t get_plane_size_xy() const
bool holds_unique_data() const __attribute__((deprecated))
void put_data_plane_yz(size_t x, const T2DDatafield< T > &p)
reference operator()(const C3DBounds &l)
T3DVector< Out > get_gradient(const T3DVector< float > &p) const
void put_data_line_x(int y, int z, const std::vector< T > &buffer)
T3DDatafield< float > C3DFDatafield
a data field of float values
void get_data_line_z(int x, int y, std::vector< T > &buffer) const
Class of an attribute that holds data of type T.
T3DDatafield< uint32_t > C3DUIDatafield
a data field of 32 bit unsigned int values
#define NS_MIA_END
conveniance define to end the mia namespace