ChastePoint.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
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 #include "ChastePoint.hpp"
00029 #include "OutputFileHandler.hpp"
00030 #include <cassert>
00031 
00033 // Implementation
00035 
00036 template<unsigned DIM>
00037 ChastePoint<DIM>::ChastePoint(double v1, double v2, double v3)
00038 {
00039     if (DIM>0)
00040     {
00041         mLocation[0] = v1;
00042     }
00043     if (DIM>1)
00044     {
00045         mLocation[1] = v2;
00046     }
00047     if (DIM>2)
00048     {
00049         mLocation[2] = v3;
00050     }
00051 }
00052 
00053 template<unsigned DIM>
00054 ChastePoint<DIM>::ChastePoint(std::vector<double> coords)
00055 {
00056     for (unsigned i=0; i<DIM; i++)
00057     {
00058         mLocation(i) = coords.at(i);
00059     }
00060 }
00061 
00062 template<unsigned DIM>
00063 ChastePoint<DIM>::ChastePoint(c_vector<double, DIM> location)
00064     : mLocation(location)
00065 {
00066 }
00067 
00068 template<unsigned DIM>
00069 c_vector<double, DIM>& ChastePoint<DIM>::rGetLocation()
00070 {
00071     return mLocation;
00072 }
00073 
00074 template<unsigned DIM>
00075 double ChastePoint<DIM>::operator[] (unsigned i) const
00076 {
00077     assert(i<DIM);
00078     return mLocation(i);
00079 }
00080 
00081 template<unsigned DIM>
00082 double ChastePoint<DIM>::GetWithDefault(unsigned i, double def) const
00083 {
00084     if (i<DIM)
00085     {
00086         return mLocation(i);
00087     }
00088     else
00089     {
00090         return def;
00091     }
00092 }
00093 
00094 template<unsigned DIM>
00095 void ChastePoint<DIM>::SetCoordinate(unsigned i, double value)
00096 {
00097     assert(i<DIM);
00098     mLocation(i) = value;
00099 }
00100 
00101 template<unsigned DIM>
00102 bool ChastePoint<DIM>::IsSamePoint(const ChastePoint<DIM>& rPoint) const
00103 {
00104     bool returned_value = true;
00105     for (unsigned dim = 0; dim < DIM ; dim++)
00106     {
00107         if (rPoint[dim] != mLocation[dim])
00108         {
00109             returned_value = false;
00110             break;
00111         }
00112     }
00113     return returned_value;
00114 }
00115 
00117 // Explicit instantiation
00119 
00120 template class ChastePoint<1>;
00121 template class ChastePoint<2>;
00122 template class ChastePoint<3>;
00123 
00124 // Serialization for Boost >= 1.36
00125 #include "SerializationExportWrapperForCpp.hpp"
00126 EXPORT_TEMPLATE_CLASS_SAME_DIMS(ChastePoint)
00127 

Generated on Tue May 31 14:31:48 2011 for Chaste by  doxygen 1.5.5