point3d.hxx

00001 // Copyright (C) 2001, 2002, 2004  EPITA Research and Development Laboratory
00002 //
00003 // This file is part of the Olena Library.  This library is free
00004 // software; you can redistribute it and/or modify it under the terms
00005 // of the GNU General Public License version 2 as published by the
00006 // Free Software Foundation.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this library; see the file COPYING.  If not, write to
00015 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
00016 // MA 02111-1307, USA.
00017 //
00018 // As a special exception, you may use this file as part of a free
00019 // software library without restriction.  Specifically, if other files
00020 // instantiate templates or use macros or inline functions from this
00021 // file, or you compile this file and link it with other files to
00022 // produce an executable, this file does not by itself cause the
00023 // resulting executable to be covered by the GNU General Public
00024 // License.  This exception does not however invalidate any other
00025 // reasons why the executable file might be covered by the GNU General
00026 // Public License.
00027 
00028 #ifndef OLENA_CORE_POINT3D_HXX
00029 # define OLENA_CORE_POINT3D_HXX
00030 
00031 # include <oln/core/point2d.hh>
00032 # include <oln/core/dpoint3d.hh>
00033 # include <iostream>
00034 
00035 
00036 namespace oln {
00037 
00038 
00039   inline
00040   point3d::point3d()
00041   {
00042     nth(0) = 0;
00043     nth(1) = 0;
00044     nth(2) = 0;
00045   }
00046 
00047   inline
00048   point3d::point3d(coord slice, coord row, coord col)
00049   {
00050     nth(0) = slice;
00051     nth(1) = row;
00052     nth(2) = col;
00053   }
00054 
00055   inline
00056   point3d::point3d(const point2d& p, coord slice)
00057   {
00058     nth(0) = slice;
00059     nth(1) = p.row();
00060     nth(2) = p.col();
00061   }
00062 
00063   inline coord
00064   point3d::slice() const
00065   {
00066     return nth(0);
00067   }
00068 
00069   inline coord&
00070   point3d::slice()
00071   {
00072     return nth(0);
00073   }
00074 
00075   inline coord
00076   point3d::row() const
00077   {
00078     return nth(1);
00079   }
00080 
00081   inline coord&
00082   point3d::row()
00083   {
00084     return nth(1);
00085   }
00086 
00087   inline coord
00088   point3d::col() const
00089   {
00090     return nth(2);
00091   }
00092 
00093   inline coord&
00094   point3d::col()
00095   {
00096     return nth(2);
00097   }
00098 
00099   inline point3d&
00100   point3d::plus_assign_dp(const dpoint3d& dp)
00101   {
00102     slice() += dp.slice();
00103     row() += dp.row();
00104     col() += dp.col();
00105     return *this;
00106   }
00107 
00108   inline point3d&
00109   point3d::minus_assign_dp(const dpoint3d& dp)
00110   {
00111     slice() -= dp.slice();
00112     row() -= dp.row();
00113     col() -= dp.col();
00114     return *this;
00115   }
00116 
00117   inline dpoint3d
00118   point3d::minus_p(const point3d& p) const
00119   {
00120     dpoint3d dp(slice() - p.slice(),
00121                 row() - p.row(),
00122                 col() - p.col());
00123     return dp;
00124   }
00125 
00126   inline point3d
00127   point3d::plus_dp(const dpoint3d& dp) const
00128   {
00129     point3d p = *this;
00130     p += dp;
00131     return p;
00132   }
00133 
00134   inline point3d
00135   point3d::minus_dp(const dpoint3d& dp) const
00136   {
00137     point3d p = *this;
00138     p -= dp;
00139     return p;
00140   }
00141 
00142   inline point3d
00143   point3d::minus() const
00144   {
00145     point3d p(-slice(), -row(), -col());
00146     return p;
00147   }
00148 
00149 } // end of oln
00150 
00151 
00152 inline std::ostream&
00153 operator<<(std::ostream& o, const oln::point3d& p)
00154 {
00155   return o << '(' << p.slice() << ',' << p.row() << ',' << p.col() << ')';
00156 }
00157 
00158 
00159 
00160 #endif // ! OLENA_CORE_POINT3D_HXX

Generated on Thu Apr 15 20:13:14 2004 for Olena by doxygen 1.3.6-20040222