00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef OLENA_CORE_IMAGE3D_HH
00029 # define OLENA_CORE_IMAGE3D_HH
00030
00031 # include <oln/core/point3d.hh>
00032 # include <oln/core/dpoint3d.hh>
00033 # include <oln/core/fwd_iter3d.hh>
00034 # include <oln/core/bkd_iter3d.hh>
00035 # include <oln/core/impl/image_array3d.hh>
00036 # include <oln/io/readable.hh>
00037 # include <oln/core/image.hh>
00038
00039 # include <iostream>
00040 # include <stdlib.h>
00041
00042 namespace oln {
00043
00044 template<class T, class Exact = mlc::final>
00045 class image3d;
00046
00053 template<class T, class Exact>
00054 struct image_id<image3d<T, Exact> >
00055 {
00056 enum{dim = 3};
00057 typedef T value_type;
00058 typedef typename mlc::exact_vt<image3d<T, Exact>, Exact>::ret exact_type;
00059 typedef impl::image_array3d<T> impl_type;
00060 typedef point3d point_type;
00061 typedef image3d_size size_type;
00062 };
00063
00070 template<class T, class Exact>
00071 struct image_traits<image3d<T, Exact> >:
00072 public image_traits<image<image_id<image3d<T, Exact> >::dim,
00073 typename image_id<image3d<T, Exact> >::value_type,
00074 typename image_id<image3d<T, Exact> >::impl_type,
00075 typename image_id<image3d<T, Exact> >::exact_type> >
00076 {};
00077
00078
00079
00080
00088 template<class T, class Exact>
00089 class image3d:
00090 public image<image_id<image3d<T, Exact> >::dim,
00091 typename image_id<image3d<T, Exact> >::value_type,
00092 typename image_id<image3d<T, Exact> >::impl_type,
00093 typename image_id<image3d<T, Exact> >::exact_type>
00094 {
00095
00096 public:
00097
00098 typedef image3d<T, Exact> self_type;
00099 typedef typename image_id<image3d<T, Exact> >::value_type value_type;
00100 typedef typename image_id<image3d<T, Exact> >::exact_type exact_type;
00101 typedef typename image_id<image3d<T, Exact> >::impl_type impl_type;
00102 typedef image<image_id<image3d<T, Exact> >::dim,
00103 value_type,
00104 impl_type,
00105 exact_type> super_type;
00106
00107 friend class abstract::image<exact_type>;
00108
00109 image3d() :
00110 super_type()
00111 {
00112 mlc_init_static_hierarchy(Exact);
00113 }
00114
00121 image3d(coord nslices, coord nrows, coord ncols, coord border = 2) :
00122 super_type(new impl_type(image3d_size(nslices, nrows, ncols, border)))
00123 {
00124 mlc_init_static_hierarchy(Exact);
00125 }
00126
00131 image3d(const image3d_size& size) :
00132 super_type(new impl_type(size))
00133 {
00134 mlc_init_static_hierarchy(Exact);
00135 }
00136
00146 image3d(self_type& rhs) :
00147 super_type(rhs)
00148 {
00149 mlc_init_static_hierarchy(Exact);
00150 }
00151
00152
00160 image3d(const io::internal::anything& r) : super_type()
00161 {
00162 mlc_init_static_hierarchy(Exact);
00163 r.assign(*this);
00164 }
00165
00173 image3d&
00174 operator=(const io::internal::anything& r)
00175 {
00176 return r.assign(*this);
00177 }
00178
00186 exact_type&
00187 operator=(self_type rhs)
00188 {
00189 return this->exact().assign(rhs.exact());
00190 }
00191
00192 static std::string
00193 name()
00194 {
00195 return
00196 std::string("image3d<")
00197 + ntg_name(T) + ","
00198 + Exact::name() + ">";
00199 }
00200
00202
00203 template<class U>
00204 struct mute
00205 {
00206 typedef image3d<U> ret;
00207 };
00208
00209 image3d(const self_type& rhs);
00210
00211 protected:
00212
00214 exact_type
00215 clone_() const
00216 {
00217 exact_type output(this->nslices(), this->nrows(),
00218 this->ncols(), this->border());
00219 clone_to(output.impl());
00220 return output;
00221 }
00222
00223 };
00224
00230 template <class T, class Exact>
00231 struct dim_traits<3, T, Exact>
00232 {
00233 typedef image3d<T, Exact> img_type;
00234 };
00235 }
00236
00237 #endif // ! OLENA_CORE_IMAGE3D_HH