Go to the documentation of this file.00001 #ifndef vimt3d_image_3d_of_txx_
00002 #define vimt3d_image_3d_of_txx_
00003
00004
00005
00006
00007
00008 #include "vimt3d_image_3d_of.h"
00009
00010 #include <vcl_string.h>
00011 #include <vcl_cassert.h>
00012 #include <vsl/vsl_indent.h>
00013 #include <vsl/vsl_vector_io.h>
00014 #include <vil3d/vil3d_print.h>
00015 #include <vil3d/io/vil3d_io_image_view.h>
00016
00017
00018
00019
00020 template<class T>
00021 void vimt3d_image_3d_of<T>::deep_copy(const vimt3d_image_3d_of& src)
00022 {
00023 world2im_ = src.world2im_;
00024 image_.deep_copy(src.image_);
00025 }
00026
00027
00028
00029
00030
00031 template<class T>
00032 bool vimt3d_image_3d_of<T>::equals(const vimt_image &im) const
00033 {
00034 assert(dynamic_cast<const vimt3d_image_3d_of<T> *>(&im));
00035 return operator==(static_cast<const vimt3d_image_3d_of<T> &>(im));
00036 }
00037
00038
00039
00040
00041
00042
00043 template<class T>
00044 void vimt3d_image_3d_of<T>::set_valid_region(int i0, unsigned ni,
00045 int j0, unsigned nj,
00046 int k0, unsigned nk)
00047 {
00048 image_.set_size(ni,nj,nk);
00049 world2im_.set_translation(-i0,-j0,-k0);
00050 }
00051
00052
00053
00054 template<class T>
00055 bool vimt3d_image_3d_of<T>::is_class(vcl_string const& s) const
00056 {
00057 return s==vimt3d_image_3d_of<T>::is_a() || vimt3d_image_3d::is_class(s);
00058 }
00059
00060
00061
00062 template<class T>
00063 short vimt3d_image_3d_of<T>::version_no() const
00064 {
00065 return 1;
00066 }
00067
00068
00069
00070 template<class T>
00071 vimt_image* vimt3d_image_3d_of<T>::deep_clone() const
00072 {
00073 vimt3d_image_3d_of<T>* new_im = new vimt3d_image_3d_of<T>();
00074 new_im->deep_copy(*this);
00075 return new_im;
00076 }
00077
00078
00079
00080 template<class T>
00081 void vimt3d_image_3d_of<T>::print_summary(vcl_ostream& os) const
00082 {
00083 os << vsl_indent() << "Transform: " << world2im_
00084 << vsl_indent() << " Image: " << image_ << '\n';
00085 }
00086
00087
00088
00089
00090 template<class T>
00091 void vimt3d_image_3d_of<T>::print_all(vcl_ostream& os) const
00092 {
00093 os<<vsl_indent();
00094 vil3d_print_all(os,image_);
00095 os<<'\n'<<vsl_indent() << "Transform: "<<world2im_<<'\n';
00096 }
00097
00098
00099
00100 template<class T>
00101 void vimt3d_image_3d_of<T>::b_write(vsl_b_ostream& bfs) const
00102 {
00103 vsl_b_write(bfs,version_no());
00104 vsl_b_write(bfs,image_);
00105 vsl_b_write(bfs,world2im_);
00106 }
00107
00108
00109
00110 template<class T>
00111 void vimt3d_image_3d_of<T>::b_read(vsl_b_istream& bfs)
00112 {
00113 if (!bfs) return;
00114
00115 short version;
00116 vsl_b_read(bfs,version);
00117 switch (version)
00118 {
00119 case (1):
00120 vsl_b_read(bfs,image_);
00121 vsl_b_read(bfs,world2im_);
00122 break;
00123 default:
00124 vcl_cerr << "I/O ERROR: vimt3d_image_3d_of<T>::b_read(vsl_b_istream&)\n"
00125 << " Unknown version number "<< version << '\n';
00126 bfs.is().clear(vcl_ios::badbit);
00127 return;
00128 }
00129 }
00130
00131
00132
00133
00134
00135
00136
00137 template<class T>
00138 bool vimt3d_image_3d_of<T>::operator==(const vimt3d_image_3d_of<T> &other) const
00139 {
00140 return image_ == other.image_ &&
00141 world2im_ == other.world2im_;
00142 }
00143
00144
00145
00146
00147
00148
00149
00150
00151 template<class T>
00152 bool vimt3d_image_3d_deep_equality(const vimt3d_image_3d_of<T>& lhs,
00153 const vimt3d_image_3d_of<T>& rhs)
00154 {
00155
00156 if (!(lhs.world2im() == rhs.world2im()))
00157 return false;
00158
00159
00160 return vil3d_image_view_deep_equality(lhs.image(), rhs.image());
00161 }
00162
00163
00164
00165
00166
00167 #define VIMT3D_IMAGE_3D_OF_INSTANTIATE(T) \
00168 VCL_DEFINE_SPECIALIZATION vcl_string vimt3d_image_3d_of<T >::is_a() const \
00169 { return vcl_string("vimt3d_image_3d_of<" #T ">"); } \
00170 template class vimt3d_image_3d_of<T >; \
00171 template bool vimt3d_image_3d_deep_equality(const vimt3d_image_3d_of<T >& lhs, \
00172 const vimt3d_image_3d_of<T >& rhs)
00173
00174 #endif // vimt3d_image_3d_of_txx_