00001 // Copyright (C) 2001, 2002 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, Inc., 51 Franklin Street, Fifth Floor, 00016 // Boston, MA 02110-1301, 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_DPOINT3D_HXX 00029 # define OLENA_CORE_DPOINT3D_HXX 00030 00031 # include <oln/core/point3d.hh> 00032 # include <iostream> 00033 00034 namespace oln { 00035 00036 inline coord 00037 dpoint3d::slice() const 00038 { 00039 return nth(0); 00040 } 00041 00042 inline coord& 00043 dpoint3d::slice() 00044 { 00045 return nth(0); 00046 } 00047 00048 inline coord 00049 dpoint3d::row() const 00050 { 00051 return nth(1); 00052 } 00053 00054 inline coord& 00055 dpoint3d::row() 00056 { 00057 return nth(1); 00058 } 00059 00060 inline coord 00061 dpoint3d::col() const 00062 { 00063 return nth(2); 00064 } 00065 00066 inline coord& 00067 dpoint3d::col() 00068 { 00069 return nth(2); 00070 } 00071 00072 inline 00073 dpoint3d::dpoint3d() 00074 { 00075 slice() = 0; 00076 row() = 0; 00077 col() = 0; 00078 } 00079 00080 inline 00081 dpoint3d::dpoint3d(coord s, coord r, coord c) 00082 { 00083 slice() = s; 00084 row() = r; 00085 col() = c; 00086 } 00087 00088 inline 00089 dpoint3d::dpoint3d(const point3d& p) : super_type(p) 00090 { 00091 } 00092 00093 inline dpoint3d 00094 dpoint3d::minus() const 00095 { 00096 dpoint3d dp(-slice(), -row(), -col()); 00097 return dp; 00098 } 00099 00100 inline dpoint3d& 00101 dpoint3d::plus_assign_dp(const dpoint3d& dp) 00102 { 00103 slice() += dp.slice(); 00104 row() += dp.row(); 00105 col() += dp.col(); 00106 return *this; 00107 } 00108 00109 inline dpoint3d& 00110 dpoint3d::minus_assign_dp(const dpoint3d& dp) 00111 { 00112 slice() -= dp.slice(); 00113 row() -= dp.row(); 00114 col() -= dp.col(); 00115 return *this; 00116 } 00117 00118 inline dpoint3d 00119 dpoint3d::plus_dp(const dpoint3d& dp) const 00120 { 00121 dpoint3d tmp = *this; 00122 tmp += dp; 00123 return tmp; 00124 } 00125 00126 inline dpoint3d 00127 dpoint3d::minus_dp(const dpoint3d& dp) const 00128 { 00129 dpoint3d tmp = *this; 00130 tmp -= dp; 00131 return tmp; 00132 } 00133 00134 } // end of oln 00135 00136 inline std::ostream& 00137 operator<<(std::ostream& o, const oln::dpoint3d& dp) 00138 { 00139 return o << '(' << dp.slice() << ',' << dp.row() << ',' << dp.col() << ')'; 00140 } 00141 00142 #endif // ! OLENA_CORE_DPOINT3D_HXX