• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

cube3d.hh

00001 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of Olena.
00004 //
00005 // Olena is free software: you can redistribute it and/or modify it under
00006 // the terms of the GNU General Public License as published by the Free
00007 // Software Foundation, version 2 of the License.
00008 //
00009 // Olena is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free
00018 // software project without restriction.  Specifically, if other files
00019 // instantiate templates or use macros or inline functions from this
00020 // file, or you compile this file and link it with other files to produce
00021 // an executable, this file does not by itself cause the resulting
00022 // executable to be covered by the GNU General Public License.  This
00023 // exception does not however invalidate any other reasons why the
00024 // executable file might be covered by the GNU General Public License.
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   } // end of namespace mln::win
00133 
00134 } // end of namespace mln
00135 
00136 
00137 
00138 #endif // ! MLN_WIN_CUBE3D_HH

Generated on Tue Oct 4 2011 15:23:40 for Milena (Olena) by  doxygen 1.7.1