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 #ifndef MLN_WIN_CUBE3D_HH
00027 # define MLN_WIN_CUBE3D_HH
00028 
00032 
00033 # include <mln/core/internal/classical_window_base.hh>
00034 # include <mln/core/alias/dpoint3d.hh>
00035 
00036 
00037 namespace mln
00038 {
00039 
00040   mln_internal_add_classical_window_trait(cube3d);
00041 
00042 
00043   namespace win
00044   {
00045 
00069     struct cube3d : public internal::classical_window_base< dpoint3d, cube3d >
00070     {
00077       cube3d(unsigned length);
00078 
00081       unsigned length() const;
00082 
00086       unsigned delta_() const;
00087 
00088       void print_(std::ostream& ostr) const;
00089 
00090     protected:
00091       unsigned length_;
00092     };
00093 
00094 
00095 
00096 # ifndef MLN_INCLUDE_ONLY
00097 
00098     inline
00099     cube3d::cube3d(unsigned length)
00100       : length_(length)
00101     {
00102       mln_precondition(length % 2 == 1);
00103       const def::coord
00104         d       = static_cast<def::coord>(length / 2),
00105         minus_d = static_cast<def::coord>(- d);
00106       for (def::coord sli = minus_d; sli <= d; ++sli)
00107         for (def::coord row = minus_d; row <= d; ++row)
00108           for (def::coord col = minus_d; col <= d; ++col)
00109             insert(dpoint3d(sli, row, col));
00110     }
00111 
00112     inline
00113     unsigned cube3d::length() const
00114     {
00115       return length_;
00116     }
00117 
00118     inline
00119     unsigned cube3d::delta_() const
00120     {
00121       return length_ / 2;
00122     }
00123 
00124     inline
00125     void cube3d::print_(std::ostream& ostr) const
00126     {
00127       ostr << "[cube3d: length=" << length_ << ']';
00128     }
00129 
00130 # endif // ! MLN_INCLUDE_ONLY
00131 
00132   } 
00133 
00134 } 
00135 
00136 
00137 
00138 #endif // ! MLN_WIN_CUBE3D_HH