1 // This is mul/vil3d/vil3d_print.h
2 #ifndef vil3d_print_h_
3 #define vil3d_print_h_
4 //:
5 // \file
6 // \author Ian Scott, Tim Cootes.
7 
8 #include <iostream>
9 #include <vil/vil_print.h>
10 #include <vil3d/vil3d_image_view.h>
11 #ifdef _MSC_VER
12 #  include <vcl_msvc_warnings.h>
13 #endif
14 
15 #ifdef _MSC_VER
16 #  pragma warning( push )
17 #  pragma warning( disable: 4244 )  // conversion from ptrdiff_t to int, possible loss of data
18 #endif
19 
20 //: Print all image data to os in a grid (rounds output to int)
21 // \relatesalso vil3d_image_view
22 template <class T>
vil3d_print_all(std::ostream & os,const vil3d_image_view<T> & view)23 inline void vil3d_print_all(std::ostream& os,const vil3d_image_view<T>& view)
24 {
25   int width=os.width();
26   os<<view.is_a()<<' '<<view.nplanes()
27     <<" planes, each "<<view.ni()<<" x "<<view.nj()<<" x "<<view.nk()
28     <<" istep: "<<view.istep()<<' '
29     <<" jstep: "<<view.jstep()<<' '
30     <<" kstep: "<<view.kstep()<<' '
31     <<" planestep: "<<view.planestep()<<'\n' << std::flush;
32   for (unsigned int p=0;p<view.nplanes();++p)
33   {
34     if (view.nplanes()>1) os<<"Plane "<<p<<'\n';
35     for (unsigned int k=0;k<view.nk();++k)
36     {
37       if (view.nk()>1) os<<"Slice "<<k<<":\n";
38       for (unsigned int j=0;j<view.nj();++j)
39       {
40         for (unsigned int i=0;i<view.ni();++i)
41         {
42           os.width(width);
43           vil_print_value(os,view(i,j,k,p));
44           os<<' ';
45         }
46         os<<'\n';
47       }
48     }
49   }
50 }
51 
52 #ifdef _MSC_VER
53 #  pragma warning( pop )
54 #endif
55 
56 
57 #endif // vil3d_print_h_
58