ChastePoint.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2010
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 
00029 #include "ChastePoint.hpp"
00030 
00031 #include <cassert>
00032 
00034 // Implementation
00036 
00037 template<unsigned DIM>
00038 ChastePoint<DIM>::ChastePoint(double v1, double v2, double v3)
00039 {
00040     if (DIM>0)
00041     {
00042         mLocation[0] = v1;
00043     }
00044     if (DIM>1)
00045     {
00046         mLocation[1] = v2;
00047     }
00048     if (DIM>2)
00049     {
00050         mLocation[2] = v3;
00051     }
00052 }
00053 
00054 template<unsigned DIM>
00055 ChastePoint<DIM>::ChastePoint(std::vector<double> coords)
00056 {
00057     for (unsigned i=0; i<DIM; i++)
00058     {
00059         mLocation(i) = coords.at(i);
00060     }
00061 }
00062 
00063 template<unsigned DIM>
00064 ChastePoint<DIM>::ChastePoint(c_vector<double, DIM> location)
00065     : mLocation(location)
00066 {
00067 }
00068 
00069 template<unsigned DIM>
00070 c_vector<double, DIM>& ChastePoint<DIM>::rGetLocation()
00071 {
00072     return mLocation;
00073 }
00074 
00075 template<unsigned DIM>
00076 double ChastePoint<DIM>::operator[] (unsigned i) const
00077 {
00078     assert(i<DIM);
00079     return mLocation(i);
00080 }
00081 
00082 template<unsigned DIM>
00083 void ChastePoint<DIM>::SetCoordinate(unsigned i, double value)
00084 {
00085     assert(i<DIM);
00086     mLocation(i) = value;
00087 }
00088 
00089 template<unsigned DIM>
00090 bool ChastePoint<DIM>::IsSamePoint(const ChastePoint<DIM>& rPoint) const
00091 {
00092     bool returned_value = true;
00093     for (unsigned dim = 0; dim < DIM ; dim++)
00094     {
00095         if (rPoint[dim] != mLocation[dim])
00096         {
00097             returned_value = false;
00098             break;
00099         }
00100     }
00101     return returned_value;
00102 }
00103 
00105 // Explicit instantiation
00107 
00108 template class ChastePoint<1>;
00109 template class ChastePoint<2>;
00110 template class ChastePoint<3>;

Generated on Mon Nov 1 12:35:23 2010 for Chaste by  doxygen 1.5.5